Automatic Techniques to Systematically Discover New Heap Exploitation Primitives

Insu Yun, Dhaval Kapil, Taesoo Kim

TL;DR

Heap exploitation has long been considered a manual "dark art" reserved for elite hackers. This paper introduces ARCHEAP, an automated, fuzzing-based tool that systematically discovers new heap exploitation primitives by abstracting common allocator designs and tracking memory divergence, successfully uncovering five previously unknown exploit techniques in Linux's default ptmalloc.

What Problem Does This Paper Address?

Heap-related vulnerabilities (like buffer overflows or use-after-free bugs) are a massive source of critical security flaws. When attackers find these bugs, they manipulate the heap's internal management structures to create an "exploit primitive"—a reliable building block like an arbitrary memory write, which can then be used to hijack the program.

Historically, discovering these techniques required deep, manual analysis of specific heap allocators. Previous attempts to automate this process (like a tool called HeapHopper) relied on symbolic execution. However, symbolic execution suffers from state explosion and requires strict, pre-defined models of known exploits. Consequently, existing tools are good at validating known techniques but terrible at discovering completely new ones. The authors set out to build a system that can autonomously explore the heap and discover novel exploitation techniques without needing the allocator's source code or prior knowledge of specific exploit chains.

Methods

The authors built ARCHEAP, which treats the discovery of exploit primitives as a fuzzing problem, but with several clever domain-specific optimizations:

  1. Abstract Heap Models: To prevent the fuzzer from getting lost in an infinite search space of random bytes, ARCHEAP restricts its actions based on common design patterns found in almost all modern allocators: binning (grouping allocations by size), in-place metadata (storing management data right next to user data), and cardinal data (using raw pointers and sizes).
  2. Action Generation: ARCHEAP translates fuzzer output into specific heap actions: allocating memory, freeing memory, writing to buffers, and triggering specific bug types (e.g., an off-by-one overflow or a double free).
  3. Impact Detection via Shadow Memory: Instead of trying to generate a full end-to-end exploit (like popping a shell, which is too complex for a fuzzer), ARCHEAP looks for the impact of a primitive (e.g., overlapping chunks or arbitrary writes). It does this using shadow memory—it keeps a safe, isolated copy of its own internal data structures. If a heap action causes the real memory to diverge from the shadow memory, it means the allocator's internal logic was tricked into corrupting data, signaling a successful exploit primitive.
  4. Delta-Debugging: Fuzzers generate messy, redundant test cases. ARCHEAP uses delta-debugging (systematically removing one action at a time to see if the exploit still works) to strip away the noise, outputting a minimal, human-readable C Proof-of-Concept (PoC).

Datasets

Rather than traditional datasets, the authors evaluated ARCHEAP against several real-world and custom heap allocators:

  • Real-world allocators: ptmalloc (the default in Linux/glibc, tested across versions 2.15 to 2.27), tcmalloc (Google), and jemalloc (FreeBSD).
  • Custom allocators: 9 unique, custom-built heap allocators from the DARPA Cyber Grand Challenge (CGC).

Key Insights and Ideas

  • Impact over End-to-End Exploits: You don't need to synthesize a full control-flow hijack to prove a vulnerability is exploitable. By focusing purely on the "impact" (the primitive), the search space becomes manageable for a fuzzer.
  • Common Designs are a Double-Edged Sword: Because most allocators use similar tricks for performance (like in-place metadata), a generalized fuzzing model can break many different implementations. You don't need a bespoke model for every new allocator.
  • Fuzzing Beats Symbolic Execution for Discovery: While symbolic execution is great for verifying known paths, fuzzing's random exploration is far superior for stumbling into completely unknown exploit chains. ARCHEAP found techniques that required bizarre, unintuitive sequences of allocations that a strict model would never attempt.
  • Performance Upgrades Can Backfire on Security: By testing different versions of ptmalloc, the authors found that the introduction of tcache (a feature added in glibc 2.26 to speed up multi-threaded allocations) bypassed older security checks, making exploitation significantly easier and introducing new attack vectors.

Key Results

  • 5 New Primitives Discovered: ARCHEAP found five previously unknown exploitation techniques in ptmalloc, including "House of unsorted einherjar" and "Unaligned double free."
  • Cross-Allocator Success: It successfully found 4 exploitation techniques in tcmalloc and jemalloc, and found primitives for 8 out of the 9 custom DARPA CGC allocators.
  • Outperformed State-of-the-Art: Compared to HeapHopper, ARCHEAP found all the new techniques (HeapHopper found zero) and identified known techniques faster and more reliably without needing strict, exploit-specific guidance.
  • Massive PoC Reduction: The delta-debugging minimization phase was highly effective, stripping away 84.3% of redundant fuzzer actions to produce clean PoCs averaging just 26 lines of code.

Limitations and Future Work

  • Fundamental Incompleteness: Because ARCHEAP relies on randomized fuzzing, it cannot guarantee it has found all possible exploits. It is a practical tool, but not a mathematically complete one.
  • Overfitting to the Abstract Model: ARCHEAP assumes allocators use common designs (like in-place metadata). If an allocator uses a radically different architecture—such as strictly out-of-band metadata or page-based allocation (which one CGC challenge used)—ARCHEAP's assumptions fail, and it struggles to find primitives.
  • Future Work: The authors suggest that ARCHEAP's automated PoC generation could be integrated directly into CI/CD pipelines for libc maintainers, acting as a regression testing suite to ensure new performance features don't accidentally resurrect old exploit techniques.

Summary updated

BibTeX
@inproceedings{yun2020automatic,
  author = {Insu Yun and Dhaval Kapil and Taesoo Kim},
  title = {{Automatic Techniques to Systematically Discover New Heap Exploitation Primitives}},
  booktitle = {USENIX Security},
  year = {2020},
}
Figure