University of Ontario Institute of Technology
Can LLM-based code mutation power the next generation of metamorphic malware?
Abstract
dc:description.abstractMetamorphic malware evades detection by rewriting its own code while preserving its malicious functionality. Traditional mutation engines rely on fixed, hand-crafted rule sets that defenders can eventually catalog and counter. Large language models trained for code synthesis can automate the mutation processed with a diversity that rule-based engines cannot match; such automation undermines detection that depends on recognizing known patterns. This thesis investigates LLM-based code mutation as an emerging threat to malware detection. We formalize code mutation as a learning task distinct from code generation and introduce mutate@k, a metric that jointly measures the functional correctness and structural diversity of generated codes using LLMs. Guided by a proposed taxonomy of behavior-preserving transformations, we build a large-scale mutation corpus and use it to fine-tune several open-source code LLMs, improving their mutate@k by up to 21.2 percentage points while retaining general code generation ability. To measure the security impact, we develop Morphic, a platform that applies the fine-tuned models to real malware and tracks detection over time. Across samples in several scripting languages, the mutated variants achieve a mean first-scan evasion rate of 78.7% against commercial detection engines, with more heavily mutated variants remaining undetected for extended periods. These results give empirical weight to a largely speculative threat and motivate detection approaches resilient to automated, LLM-driven code transformation.
Degree
thesis:*- Name thesis:degree_name
- Master of Science (MSc)
- Discipline thesis:degree_discipline
- Computer Science
- Grantor
- University of Ontario Institute of Technology
- Year dc:date.issued
- 2026
Author and committee
dc:creator, dc:contributor.*- Author dc:creator
-
- Setak, Mohammadhossein
- Advisor dc:contributor.advisor
-
- Madani, Pooria
Subjects
dc:subject × 5Rights
- Language dc:language.iso
- en
Identifiers
dc:identifier.*- Handle dc:identifier.uri
- https://hdl.handle.net/10155/2163