polymorphic virus

term

security

Kept in this browser · My desk

A virus, or any malware, that changes its own code in every copy, typically by encrypting its body with a new key and generating a new decryption routine, so that no fixed string of bytes identifies it.

Scanners of the 1980s looked for fixed strings. Encrypted viruses such as Cascade left only a small decryptor in clear; polymorphic ones made the decryptor change too. Virus Bulletin called the 1260 virus of 1990 the first nail in the coffin of virus-specific detection, and Dark Avenger's Mutation Engine of 1992, a module any virus could call, turned the technique into a product. Europol still described Emotet in 2021 as polymorphic, changing its code each time it is called up.

The step from encryption to polymorphism is the decryptor. An encrypted virus hides its body but must carry a decryption routine in clear, and scanners learned to look for that. In Cascade the clear part was about thirty unchanging bytes, enough for a search pattern. The 1260 virus, described in Virus Bulletin in March 1990 as built on the Vienna virus printed in Ralf Burger's 1987 book and later credited to Mark Washburn, inserted random useless instructions among the decoding ones, so that, in the magazine's words, extracting a reliable search pattern became virtually impossible. Peter Lammer's comment in the April 1990 issue gave the numbers: the longest unchanging sequence in 1260's decryptor was three bytes, while ten bytes was the practical minimum for a search pattern and sixteen was advised to keep false positives down. Tequila, written in Switzerland, used variable encryption and infected both boot records and executables.

What the standards call it. The 2005 malware guide of the National Institute of Standards and Technology (NIST), Special Publication (SP) 800-83, sets out the ladder. Self-encryption hides the body, and random keys make each instance look different. Polymorphism is a robust form of self-encryption that also changes the encryption settings and the decryption code, while the body underneath stays the same. Metamorphism goes further and alters the body itself, adding unneeded code or reordering it, so that the result looks fundamentally different; in 2005 NIST judged the older techniques generally handled by antivirus products and metamorphism still considerably harder. MITRE ATT&CK (Adversarial Tactics, Techniques, and Common Knowledge) added Polymorphic Code as sub-technique T1027.014 of Obfuscated Files or Information on 27 September 2024, under the Stealth tactic, and treats polymorphic, metamorphic and mutating code as one thing: code that changes its runtime footprint while keeping its purpose. Readers comparing sources should know that the two vocabularies draw the line in different places.

The Mutation Engine (MtE) of 1992 was the turning point. Fridrik Skulason's analysis in Virus Bulletin in April 1992 describes an object module of about 2 KB, version 0.91, released by the author calling himself Dark Avenger with documentation, a sample virus and support through a Bulgarian bulletin board system, which encrypted the calling virus with a different key every time and generated a different decryptor of variable length; detection with signature strings was, he wrote, totally impractical, and the same issue's table listed two viruses already using it, Dedicated and Fear, with the note that no search pattern was possible. The engine itself was not a virus; it was a toolkit any writer could link in, which made polymorphism available to people who could not have written it. Virus Bulletin saw it as the logical extension of 1260: the first nail in the coffin of virus-specific detection, and for simple scanners perhaps the final one.

The answer was to stop looking for strings. Lammer's 1990 comment already proposed it: identify a virus by everything known about it rather than by a byte pattern. A virus has to recognize its own copies or it reinfects files until they grow too large to load, as one Jerusalem variant did, so it leaves a marker; 1260 set the seconds field of the file's timestamp to 62 and began each infected .COM file with a jump to a point 1,260 bytes before its end. Vendors moved to algorithmic detection, which F-Secure notes can produce false alarms, and to emulation, running the decryptor in a sandbox until the constant body appears; later still, behaviour-based detection watched what the program did rather than what it looked like. ATT&CK's mitigations for T1027.014 point the same way: anti-malware that uses machine learning and behaviour rather than indicators, and attack surface reduction rules on Windows, with detection looking for executables whose hash, entropy or memory sections change between or during runs. Fred Cohen's proof that virus detection is undecidable explains why each answer only moved the race.

Where it lives today. Europol counted Emotet in 2021 among the polymorphic botnets that change their code each time they are called up, which makes signature detection difficult. Palo Alto Networks' Unit 42 reported in February 2021 that BendyBear, shellcode of more than 10,000 bytes that it linked to the BlackTech espionage group, used polymorphic code to change its runtime footprint, thwart memory analysis and evade signatures, decrypting its function blocks only as needed. The practical lesson for defenders is that a file hash identifies one copy, not a family: a blocklist of hashes misses the next copy of anything polymorphic. Neighbours: stealth, armoring and tunneling, the other obfuscation techniques in NIST's list, and, in ATT&CK's terms, software packing and encrypted or encoded files, which are often used together with it. The history is in the Learn article on viruses and trojan horses.

Also known as: polymorphic malware, polymorphism (malware), mutation engine, mte, vírus polimórfico, malware polimórfico

Sources

← Back to P Back to the glossary