Top of the Heap: Efficient Memory Error Protection for Many Heap Objects

Kaiming Huang, Mathias Payer, Zhiyun Qian, Jack Sampson, Gang Tan, Trent Jaeger · DOI

Memory errors in C/C++ represent a persistent threat in software security, accounting for approximately 70-80% of all vulnerabilities. While significant progress has been made in securing the stack, the heap remains a complex frontier due to its variable object sizes, long lifetimes, and intricate type-casting patterns. This paper introduces Uriah, a system designed to break the "trilemma" of heap protection—the difficulty of achieving complete coverage, low performance overhead, and low memory cost simultaneously.

The Heap Protection Landscape

Existing defenses often fall short by either incurring prohibitive performance costs (e.g., AddressSanitizer) or providing incomplete coverage that ignores specific error classes like spatial or temporal violations. Uriah addresses this by identifying a "well-behaved" majority of heap objects that do not require heavy instrumentation.

Comparison of Uriah with state-of-the-art memory safety defenses.

The Uriah Architecture

Uriah operates on the "Happy Family" principle: while unsafe objects fail in infinite, complex ways, safe objects all follow the same predictable rules of spatial and type safety. The system functions in three distinct phases to move from static proofs to runtime enforcement:

  1. Static Safety Validation: Utilizing Static Value-Flow (SVF) analysis and Program Dependence Graphs (PDG), Uriah examines pointer accesses to identify objects that are always accessed within bounds and never cast into incompatible types.
  2. Symbolic Execution Refinement: To reduce the pessimism of static analysis, Uriah employs the S2E symbolic execution engine. It explores potentially "unsafe" paths; if a path is proven mathematically impossible, the associated object is reclassified as safe.
  3. The Isolated Safe Heap: Objects proven safe are allocated to a specialized "Safe Heap" protected by Software Fault Isolation (SFI). To mitigate temporal attacks like Use-After-Free, Uriah enforces temporal allocated-type safety, ensuring memory is only reused for objects of the same type and layout.
The Uriah workflow: from validation of aliases to runtime allocation.

Key Insights and Results

One of the paper's most significant findings is the 72% Rule: approximately 72% of heap allocation sites produce objects that can be statically proven safe. This high percentage allows Uriah to focus its defensive resources on the remaining 28% of "unhappy" objects, leading to exceptional efficiency.

Performance and Scalability

Uriah was evaluated against rigorous benchmarks (SPEC CPU2006/2017) and massive production codebases like the Firefox browser. Key results include:

  • Low Overhead: Runtime overhead is remarkably low at 2.9% for SPEC 2006 and 2.6% for SPEC 2017.
  • Memory Efficiency: Memory overhead remains modest at 9.3% and 5.4% respectively.
  • Robust Security: The system successfully mitigated all 102 heap vulnerabilities in the DARPA CGC test suite and prevented exploits for 28 real-world CVEs from 2023.

Limitations and Future Work

While Uriah represents a major step forward, it assumes the presence of Control-Flow Integrity (CFI) to prevent attackers from bypassing SFI checks. Additionally, it does not inherently protect the objects remaining in the "unsafe" pool, though its efficiency makes it an ideal companion for more expensive, heavy-duty defenses. Future work may involve more precise analysis of global aliases and addressing same-type Use-After-Free scenarios.

Summary updated

BibTeX
@inproceedings{huang2024top,
  author = {Kaiming Huang and Mathias Payer and Zhiyun Qian and Jack Sampson and Gang Tan and Trent Jaeger},
  title = {{Top of the Heap: Efficient Memory Error Protection for Many Heap Objects}},
  booktitle = {CCS},
  year = {2024},
  doi = {10.1145/3658644.3690310},
}
Figure