Algorithm Search⌘K

Techniqueresearch

Automatic exploit generation

Also called AEG.

The research problem of finding a bug by program analysis and deciding whether some input turns it into an attack, studied to measure attacker ability and to guide defenses.

Automatic exploit generation (AEG) is the research problem of taking a program, finding a bug in it by program analysis, and deciding automatically whether some input turns the bug into an attack, with that input as the evidence. Avgerinos, Cha, Lim and Brumley (NDSS 2011) stated it as a verification problem: an exploit is an input that satisfies the path condition to a bug, the condition of the bug itself, and a condition that says that the attacker gains control. They solved the conjunction with symbolic execution and a constraint solver. Their system needed source code, handled two classic classes of memory errors, and did not try to work against address space layout randomization or non-executable memory. On 14 open-source projects it produced 16 working exploits, two of them for flaws that were not known before. The authors drew two lessons: the belief that only experts can turn bugs into attacks is unfounded, and the same analysis helps defenders rank bugs and build input filters. This page describes the threat model, the conditions, the history and the defenses, with an abstract model in place of any real target. It gives no procedure, parameters or details of software.

In plain words

A crash in a program is a sign of a bug. Some bugs only stop the program. Others let an attacker take control of it. Telling the two apart used to take an expert many hours.

Automatic exploit generation asks a computer to do this. A tool explores the program, finds an input that causes the bug, and then asks a solver whether some input of that path also gives control to the attacker. If the solver finds one, the bug is dangerous, and the input proves it.

Researchers built such tools to learn how strong attackers can be. The answer changed what defenders do. A bug must be fixed even if nobody has shown an attack, and defenses such as random memory layouts and control-flow checks make the solver fail.

When it applies

The research systems need all of these conditions. Each defense removes one.

  • A reachable memory error. The program has a bug that an input can reach, such as a buffer overflow or a format string vulnerability. Memory-safe languages, bounds checks and testing with sanitizers remove the bug before an attacker sees it.
  • A tractable path. Symbolic execution can reach the bug within its budget, which the path explosion problem limits. This is a limit of the analysis, not a defense: a hard path delays a tool but does not protect the program.
  • Control over a protected value. At the bug, the input decides a value that later controls the program, such as the target of a return. A shadow stack or control-flow integrity checks that value before it is used.
  • A condition that does not depend on a secret. The condition for control can be written without knowing a random value of the defense. ASLR and stack canaries add a secret, and data execution prevention removes a class of conditions. The 2011 system did not handle these.
  • A useful effect. Control of the process gives the attacker something. Least privilege and system call filtering limit what a controlled process can do.

The template

The block names the stages of the published method at the level of the paper's abstract, with the defense that breaks each stage. It is not a procedure.

  1. AEG-STAGES(program P)
  2. 1stage 1: search the paths of P for one that reaches a bug, with the path condition π ▷ memory safety, sanitizers and fuzzing by the defender: no bug to reach
  3. 2stage 2: restrict the search to inputs of a ⟨precondition⟩ that make a bug more likely ▷ input validation narrows the inputs that reach the code
  4. 3stage 3: at the bug, decide whether the input controls a ⟨protected value⟩ ▷ shadow stack, CFI: the value is checked before use
  5. 4stage 4: state the exploit condition ε and conjoin it with π and the bug condition β ▷ ASLR, canaries, DEP: ε needs a secret or has no solution
  6. 5stage 5: solve π ∧ β ∧ ε; check a solution by a concrete run, or report no exploit ▷ least privilege, sandboxing: a working input gains little

Walk-through. Line L1 is ordinary bug finding by symbolic or concolic execution; the defender can run the same search first. Line L2 is the idea that the 2011 paper called preconditioned symbolic execution: give up completeness to reach likely bugs sooner. Line L3 separates crashes that only stop the program from those that give control, which is the question of exploitability. Line L4 is where defenses enter the formula: they add conditions that the attacker cannot satisfy without a secret, or remove the kinds of control that the formula describes. Line L5 makes every reported result a checked fact rather than a guess, which is why the output is useful as evidence.

Example: an abstract model. Replace the program by an abstract function PP on inputs x∈Σnx \in \Sigma^n, with made-up predicates: π(x)\pi(x) is the path condition to a bug, β(x)\beta(x) the condition of the bug, and εD(x)\varepsilon_D(x) the condition that the attacker gains control when defense DD is in place. Let U={x:π(x)∧β(x)}U = \{x : \pi(x) \wedge \beta(x)\} be the unsafe inputs and ED={x∈U:εD(x)}E_D = \{x \in U : \varepsilon_D(x)\} the exploits. Four statements hold, all about the model and none about a real system.

  • Checked output is sound. If stage 5 reports xx only after a run of PP on xx shows the effect, then every reported xx is in EDE_D. The converse fails: an empty report does not imply ED=∅E_D = \emptyset, because stage 1 may not reach the path, and stage 2 searches only ED∩PreE_D \cap \mathit{Pre} for its precondition Pre\mathit{Pre}.
  • Stronger defenses shrink the exploits. If defense D′D' implies DD in the sense that εD′(x)⇒εD(x)\varepsilon_{D'}(x) \Rightarrow \varepsilon_D(x) for all xx, then ED′⊆EDE_{D'} \subseteq E_D. A check of the protected value before every use makes εD′\varepsilon_{D'} false everywhere, so ED′=∅E_{D'} = \emptyset whatever the bug.
  • A secret limits fixed inputs. Suppose εD\varepsilon_D depends on a secret δ\delta uniform on NN values, written εD,δ\varepsilon_{D,\delta}, and each input satisfies εD,δ\varepsilon_{D,\delta} for at most one δ\delta. Then a fixed input works with probability at most 1/N1/N, and qq distinct attempts against the same δ\delta work with probability at most q/Nq/N, as on the page on ASLR derandomization.
  • Exploitability ranks bugs. For two bugs with unsafe sets U1U_1 and U2U_2, a defender who finds a checked x∈EDx \in E_D for the first and none for the second knows that the first is exploitable under DD. Nothing follows for the second, by the first statement.

Classic examples

  • AEG (2011). The first end-to-end system: given source code, it found bugs in 14 open-source projects and produced 16 checked control flow hijacks, two of them for unknown flaws. Its scope excluded ASLR and non-executable memory, and it handled stack overflows and format string flaws; the authors left heap and integer flaws as future work.
  • Patch-based exploit generation (2008). An earlier system by Brumley and colleagues derived inputs from the difference between a program and its patch; see patch-based exploit generation. It showed that the patch itself can guide the search.
  • Binary-only and hardened variants. Later work by the same group and others worked on binaries without source, as in Mayhem (IEEE S&P 2012), and studied how automatic methods fare when non-executable memory and partial randomization are on, as in Q (USENIX Security 2011). These results showed that partial deployment of the defenses leaves room for automation.
  • The Cyber Grand Challenge (2016). A DARPA contest in which fully automatic systems found flaws in purpose-built programs on a simplified operating system, proved them with inputs, and patched them, against each other. The defensive half, automatic patching, was as much a part of the contest as the search.

Variations

  • Exploitability triage. Defenders use the same analysis on crashes from fuzz testing to decide which ones to fix first, together with crash bucketing, which groups crashes by cause.
  • Signature and filter generation. A checked input feeds vulnerability signature generation, which builds a filter for all inputs that reach the same flaw; the 2011 paper names this use.
  • Data-only attacks. In the model of Szekeres et al., an attacker can change data that decides a later action without changing control at all. Conditions of this kind are harder to state, and control-flow defenses do not stop them; memory safety does.
  • Automatic repair. The contest systems turned the proof of a flaw into a patch, a case of automated program repair.

Pitfalls

These are mistakes defenders make about the class.

  • Reading "no exploit found" as "safe". A tool that reports nothing has explored a part of the paths under one precondition and one model of the defenses. Fix the bug anyway.
  • Assuming that only experts exploit bugs. The 2011 paper showed that this assumption is unfounded for classic memory errors in programs without modern defenses. Plan patching for attackers with tools.
  • Relying on one mitigation. Each defense removes one condition of the list. A leak of the secret undoes ASLR, and data-only attacks pass control-flow checks. Combine memory safety, control-flow checks, randomization and least privilege.
  • Testing without the defenses on. A build for testing that turns off canaries, randomization or non-executable memory measures a weaker program than the one shipped, and the ranking of bugs then differs.
  • Slow patching. Automation shortens the time from a known bug, or a published patch, to an attack. Ship and install fixes quickly.

Exercises

  1. In the abstract model, prove that a stage 5 that checks every candidate by a concrete run reports only elements of EDE_D. Give a model in which ED≠∅E_D \ne \emptyset and the report is empty because of the precondition Pre\mathit{Pre}.
  2. Show that if εD′(x)⇒εD(x)\varepsilon_{D'}(x) \Rightarrow \varepsilon_D(x) for all xx, then ED′⊆EDE_{D'} \subseteq E_D. Give an example of predicates in which the inclusion is strict.
  3. Let εD,δ\varepsilon_{D,\delta} depend on a secret uniform on N=2kN = 2^k values, and let each input satisfy it for exactly one δ\delta. What is the largest probability that some input of a set of qq inputs works against one fixed δ\delta? Compare it with a defense that draws a new δ\delta after every failure.
  4. A defender has a budget for one fix and two bugs. For the first, an analysis found a checked input in EDE_D. For the second, it found none after a long search. Explain why fixing the first is justified, and why the result says nothing about the safety of the second.

References

  1. Thanassis Avgerinos, Sang Kil Cha, Brent Lim Tze Hao and David Brumley, AEG: Automatic exploit generation, NDSS 2011, the abstract (16 exploits in 14 open-source projects, two for unknown flaws, the formulation as a verification problem, preconditioned symbolic execution), the scope statement (source code required, not robust against address space randomization or non-executable memory) and the discussion of future work
  2. Laszlo Szekeres, Mathias Payer, Tao Wei and Dawn Song, SoK: Eternal war in memory, IEEE Symposium on Security and Privacy 2013, pages 48-62, the model of memory corruption as a chain of steps, which places the defenses that make an exploit condition false

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.

LadderLevelWhat the next level needs
Human proofH0 no proof
  • add a proof in proofs/ (06.5)
LeanL0 no Lean part
  • name a Lean module in the lean field (07)
VisualV0 none
  • add viz/scene.ts or a figure (10)
WritingW3 standard
  • five exercises