Skip to content
Anexet
Abstract illustration for «Metamorphic Virus»

Metamorphic Virus

A metamorphic virus is malware that rewrites its own code each time it replicates, so every copy looks different while doing the same thing.

Anexet Team
October 21, 2026Read 3 min

What a metamorphic virus is

A metamorphic virus is a self-replicating program that does not just hide its code, it changes it. Each new copy is produced by a built-in engine that rewrites the instructions, so the copies share behavior but almost no byte patterns. That is the whole point: classic antivirus recognizes malware by what it looks like, and a metamorphic virus never looks the same twice.

What it does once it runs is a separate question. The mutation engine is only the disguise, and the payload can be anything from file infection to a keylogger or a quiet channel for data exfiltration. A useful way to think about it: the engine decides whether you can recognize the program, the payload decides what it costs you.

How it rewrites itself

The mutation happens in a cycle that the virus carries inside itself, with no outside help.

  1. 1
    Read its own code

    The engine disassembles the virus body into a list of instructions it can understand and edit.

  2. 2
    Transform

    It applies rewrite rules, such as swapping an instruction for an equivalent one, reordering independent blocks or inserting harmless filler.

  3. 3
    Rebuild

    It reassembles the changed instructions into a new, working body with fresh addresses and jumps.

  4. 4
    Infect and repeat

    The new copy is attached to a target and, when it runs, starts the same cycle again.

Metamorphic versus polymorphic

The two are often confused. A polymorphic virus keeps the same core code and changes only its wrapper, usually an encryption layer with a different key each time. Once the wrapper is removed, the same body appears, which gives analysts something stable to match. A metamorphic virus has no stable body to find.

AspectPolymorphic virusMetamorphic virus
What changesThe encryption layer and its decryptorThe program code itself
Body after unpackingIdentical in every copyDifferent in every copy
What it carriesA mutation engine for the wrapperAn engine that disassembles and rebuilds the code
Effort to writeModerateConsiderably higher
Weak pointThe decrypted body can be matchedIts behavior and the engine's own patterns

Common mutation techniques

Metamorphic engines combine a small set of transformations. None is advanced alone, and the effect comes from stacking them across generations.

  • Instruction substitution: replacing an instruction with a different one that gives the same result.
  • Code reordering: shuffling blocks that do not depend on each other and fixing the jumps between them.
  • Register renaming: using different processor registers for the same operations.
  • Junk code insertion: adding instructions that do nothing, such as no-ops or operations that cancel out.
  • Expansion and shrinking: replacing a short sequence with a longer equivalent, or the reverse.

Why signatures fall short

Signature scanning compares a file with byte patterns taken from known samples. Metamorphism attacks that assumption directly, because a new variant carries no pattern that was ever recorded. Detection therefore moves from what the file looks like to what it does.

A related layer is file integrity monitoring. It does not recognize the virus at all: it notices that a protected file changed when nobody authorized a change, which works whatever the code looks like.

Detection approachNeeds a known byte patternSees runtime behavior
Signature matching
Static heuristics
Behavior monitoring
Sandbox or emulation

Defense in layers

Because no single check recognizes every variant, defense is built from layers that fail in different ways. Behavior-based endpoint protection, application allow-listing, and timely patching reduce the chance of infection. Most infections still begin with a person, through a message such as clone phishing or a file from removable media, so mail filtering and device rules matter as much as the scanner.

Assume that one variant will eventually run. Network segmentation, least-privilege accounts, and tested backups limit what it can touch and how long the cleanup takes.

A clean scan does not prove a clean machine: against a metamorphic sample, a signature scanner can only report that it found nothing it knew.

Where to start

Start by asking what a successful infection could reach, not how to catch every variant. Inventory the endpoints that hold sensitive data, turn on behavior-based detection there and make sure unusual file changes and outgoing transfers get noticed.

The last line of defense is the data itself. An endpoint DLP control, such as Anexet DLP, watches the channels data leaves through, so a leak can be stopped even when the program that started it was never recognized.

You cannot always recognize the intruder, but you can always watch what leaves through the door.

Anexet Team

Frequently Asked Questions

Common questions about this term and how Anexet handles it.

No. A polymorphic virus changes only its encryption wrapper and keeps the same body underneath, while a metamorphic virus rewrites the body itself. That makes metamorphic code harder to match with a fixed pattern.

Signature-only antivirus usually cannot, because each copy has a different code pattern. Behavior monitoring, heuristics, and sandbox analysis can catch it by what it does. Layered protection is more reliable than any single scanner.

They are rare. Writing a working mutation engine is difficult, so most malware uses simpler disguises such as packing or polymorphism. The idea still matters because the same evasion principles appear in newer threats.

The mutation only hides the code, and the damage depends on the payload. It can infect or corrupt files, steal credentials or send data out. That is why watching what leaves an endpoint stays useful whatever the virus looks like.

Protect your data with Anexet

See how Anexet stops data leaks, monitors employee activity, and keeps you compliant, in a quick live demo.

Request a demo