Problemintro
Malware detection
Also called malicious code detection.
Decide whether a program or file is malicious from its bytes, its static structure or its behavior when run.
Malware detection is the problem of deciding whether a given program or file is malicious: whether it would, when run, do something its owner did not want, such as spread to other programs, damage data or give control to a third party. A detector can look at the bytes of the file, at its static structure (headers, code, calls to the operating system), or at its behavior when run in a controlled environment. In its exact semantic form the problem is undecidable, as Cohen (1987) proved for viruses. So every practical detector decides an approximation, such as "contains a known signature" or "looks like the training malware to a classifier", and makes errors in both directions. This page is about detection. It gives no malicious code and no method to write or hide it.
In plain words
You receive a file and must say: harmful or not. You can read it without running it, or you can run it in a sealed room and watch what it does.
Reading has limits. A program can hide what it does, for example by packing its real code so that it only appears when it runs. Watching has limits too: a program can wait, or check whether it is being watched, and behave well while it is.
There is a deeper limit. No checker can be right about every possible program, because deciding what a program will do is impossible in general. So real checkers use shortcuts: they look for patterns of known harmful files, or they learn what harmful files tend to look like. These shortcuts can miss new harmful files and can flag harmless ones.
Definition
Semantic form. Fix a model of computation, such as programs for a Turing machine, and a set of forbidden behaviors, for example "writes a copy of itself into another program". A program is malicious if some run of , on some input or environment, shows a behavior in . Let be the set of malicious programs. The exact detection problem is to decide membership in .
Approximate form. A detector is a total computable function from files to . On a distribution of files with true labels, its false positive rate is and its false negative rate is . The goal is a low false negative rate at a fixed, very low false positive rate, because the benign files far outnumber the malicious ones on most systems.
Adversarial form. The authors of malware see the detector and change their files to avoid it. So the goal is stated for a class of changes, such as all renamings of registers or all reorderings of independent instructions: the detector should give the same answer on all variants of a file in the class.
Variants
- Static detection. Decide from the file without running it: byte signatures, byte n-gram features, the structure of the executable, the imported functions, the control flow graph.
- Dynamic detection. Run the file in an isolated environment and decide from its behavior: the system calls, the files it writes, its network requests. This sees through packing but only for the paths that run.
- Family classification. Given that a file is malicious, decide which known family it belongs to, or group unknown samples by similar behavior (malware behavior clustering).
- Similarity search. Find known files close to a new one, with similarity digests or binary code similarity.
- Packing detection. Decide whether a file is packed or encrypted, for example by its entropy, before other analyses run.
Examples
- Signature scan. A scanner holds a set of byte strings taken from known malicious files and reports any file that contains one. It decides the decidable property "contains a known string" exactly, and is right about malice only to the extent that the strings are specific. See misuse detection.
- Learned static detector. Kolter and Maloof (2006) trained classifiers on the presence of 500 byte 4-grams. On 1,971 benign and 1,651 malicious executables collected in 2003, with ten-fold cross-validation, boosted decision trees reached an area under the ROC curve of 0.996. This is a measurement on that collection. See byte n-gram classification.
- Changing form. A metamorphic program rewrites its own code in each copy, so that copies share no long byte string. A detector based on fixed strings misses the new copies, which motivates detection by behavior or by semantics.
Known algorithms
- Multiple-pattern matching of signatures, for example with Aho-Corasick automata.
- Byte n-gram classification, with information gain for feature selection and a standard learner.
- Semantics-aware matching. Christodorescu et al. (2005) describe malicious behavior as a template of instructions with variables, and match a program against the template up to changes that keep the meaning, such as inserted no-op code and renamed registers.
- Generic unpacking. Generic unpacking runs a packed program under observation until the original code appears in memory, and then hands that code to static detectors.
- Similarity digests. Context-triggered piecewise hashing gives digests that stay close when a file changes a little.
- Behavior clustering. Group samples by the profiles of their actions in a sandbox, and label a cluster at once.
| Algorithm | Time | Space | Properties | Code |
|---|---|---|---|---|
| Byte n-gram malware classification | O(n L log L) worst | O(n L) extra | deterministicofflineiterativesupervised | 1 language |
Bounds
- Undecidability (theorem). For the forbidden behavior "infects another program", Cohen (1987) proved that no program decides for all programs. More generally, for every nontrivial behavior of the computed function, is undecidable by Rice's theorem. See undecidability of virus detection.
- Arithmetical hierarchy (theorem). Adleman (1988) defined viruses abstractly as computable functions and placed the set of viruses high in the arithmetical hierarchy, above the halting problem. So the exact problem is not even semi-decidable.
- Static analysis against obfuscation (theorem). Moser, Kruegel and Kirda (2007) gave a transformation that hides constants such as jump targets behind computations that encode instances of 3SAT. A static analyzer that resolves these constants exactly solves an NP-hard problem. A detector that runs the code avoids this cost but sees only the paths that run.
- Base rates (theorem). If a fraction of files is malicious, the share of alarms that are real is at most one half unless the false positive rate is at most . See the base-rate fallacy.
Reductions
- From the halting problem. Given a program and input , build a program that first runs on and then, if halts, performs a forbidden behavior. It is malicious if and only if halts on . This is the core of the undecidability proof.
- To classification. With labeled samples, approximate detection is binary classification over features of the files, with the caveat that the distribution shifts as authors adapt.
- To string matching. Detection by a fixed set of signatures reduces to multiple-pattern string matching on the bytes of the file.
- To nearest-neighbor search. Family classification and similarity search reduce to finding the closest known samples under a distance on digests or features.
Applications
Antivirus scanners on endpoints and mail gateways, vetting of applications before they enter an app store, triage of large numbers of new samples in security companies, and forensic analysis after an incident. In all of them a false positive can stop a legitimate program, so the false positive rate is held very low and the rest of the effort goes into new signatures and models.
References
- Fred Cohen, Computer viruses, theory and experiments, Computers and Security 6(1), 1987, pages 22 to 35, the definition of a virus as a program that infects other programs with a possibly evolved copy of itself, and the proof that no program can decide for every program whether it is a virus
- Leonard M. Adleman, An abstract theory of computer viruses, Advances in Cryptology, CRYPTO 1988, LNCS 403, Springer, 1990, pages 354 to 374, the abstract definition of viruses as computable functions and the classification of the detection problem in the arithmetical hierarchy
- Mihai Christodorescu, Somesh Jha, Sanjit A. Seshia, Dawn Song and Randal E. Bryant, Semantics-aware malware detection, IEEE Symposium on Security and Privacy 2005, pages 32 to 46, malicious behavior as templates of instructions with variables, matched up to semantics-preserving changes of the code
- Andreas Moser, Christopher Kruegel and Engin Kirda, Limits of static analysis for malware detection, Annual Computer Security Applications Conference (ACSAC) 2007, pages 421 to 430, the obfuscation with opaque constants and the NP-hardness of resolving them statically
- J. Zico Kolter and Marcus A. Maloof, Learning to detect and classify malicious executables in the wild, Journal of Machine Learning Research 7, 2006, pages 2721 to 2744, Sections 3 to 5 (the data, the byte n-gram features and the measured detection results)
Where this leads
About this page
The build computes these levels from the evidence in the repository. Each row says what the next level needs. Read what the levels mean.
| Ladder | Level | What the next level needs |
|---|---|---|
| Human proof | H0 no proof |
|
| Lean | L0 no Lean part |
|
| Visual | V0 none |
|
| Writing | W2 basic |
|
Tag E5CKBH Edit this page History Report an error Markdown