Safeguard
Application Security•

Detecting and Mitigating Polymorphic Code (T1027.014)

Code that rewrites itself on every run breaks signatures by design. Learn why behavior based detection is the answer and what MITRE says to watch.

Safeguard Security Team
2 min read

A signature is a fingerprint. If the program changes its fingerprint every time it runs, a library of known fingerprints is of little use.

MITRE tracks this as Polymorphic Code, technique T1027.014, a sub-technique of Obfuscated Files or Information in the Stealth tactic. It applies to Linux, macOS and Windows.

How attackers use it

Polymorphic code, also called metamorphic or mutating code, can change its runtime footprint while it executes. Each run produces a different version of itself that does the same job. This is aimed at traditional signature based defenses such as antivirus. MITRE adds that other techniques can be combined with it through mutation engines, including software packing, command obfuscation and encrypted or encoded files.

How to detect it

MITRE's strategy (DET0324) looks for the mutation itself:

  • Windows. Self-modifying executables whose hash, entropy or memory sections change during or between runs, often tied to unpacking or decryption.
  • Linux. Files or processes where running produces frequent re-creation or modification of ELF binaries or interpreter scripts, often with chmod and execve and abnormal entropy.
  • macOS. Executables or interpreter payloads, such as Mach-O or dylib files, that change across runs through scripting engines, JIT compilers or side-loaded plugins.

Instead of asking whether you have seen this file before, ask whether this program keeps changing itself.

How to reduce the risk

MITRE lists two mitigations.

  1. Behavior prevention on endpoint. On Windows 10 and later, enable Attack Surface Reduction rules to prevent execution of potentially obfuscated payloads.
  2. Antivirus and antimalware. Detect and quarantine suspicious files, and use advanced anti-malware techniques, including machine learning and behavior based mechanisms, for signature-less detection.

The common thread is to stop relying on a fixed fingerprint. Continuous monitoring that records process behavior over time is the practical way to notice a program that keeps changing.

Try it yourself

Click through it at your own pace, or open it full screen.

Quick check

Why do hash blocklists fail against polymorphic code?

Each execution produces a different version of the code, so the hash you recorded last time will not match the next one.

Sources

Never miss an update

Weekly insights on software supply chain security, delivered to your inbox.

Self-healing security runs on Safeguard.

Your first fix PR is minutes away.

No sales call required, even your agent can complete the purchase over MCP.