Mpchecker: Use-After-Free Vulnerabilities Protection Based on Multi-Level Pointers

Weizhong Qiang, Weifeng Li, Hai Jin, Jayachander SurbiryalaIEEE Access 2019

Abstract

Use-After-Free (UAF) vulnerabilities remain a critical threat to software written in memory-unsafe languages like C and C++. Existing defenses often struggle with comprehensive coverage, performance overhead in multi-threaded environments, or tracking pointers through type-unsafe operations. This paper presents MPChecker, a dynamic defense system that utilizes a multi-level pointer indirection strategy. By decoupling application pointers from heap objects via an intermediate "base-level pointer" (basePtr), MPChecker can invalidate all references to a memory region the moment it is deallocated. Evaluation shows that MPChecker effectively blocks UAF exploits with competitive performance overhead and excellent scalability.

Introduction

In languages where developers manually manage memory, UAF vulnerabilities occur when a program continues to use a pointer after the memory it references has been freed. These "dangling pointers" can be exploited by attackers to gain control over program execution or leak sensitive information. While many tools attempt to track pointer lifecycles, they often fail when pointers are copied via raw memory functions like memcpy() or when pointers reside in the stack or global memory segments. Furthermore, the performance cost of tracking every pointer propagation in high-concurrency environments often makes such tools impractical for production use.

System Architecture

MPChecker addresses these challenges through a combination of static instrumentation and a robust runtime protection layer. The system is built on the LLVM compiler infrastructure, allowing it to intercept memory operations at the intermediate representation (IR) level.

System Architecture

As shown in the architecture overview, the process begins with Static Instrumentation. MPChecker identifies memory allocations, deallocations, and dereferences, replacing standard library calls with secured versions (secMPMalloc and secMPFree). At Runtime, the system maintains a heap object manager and a pointer tracker. These components manage the lifecycle of the intermediate indirection layer, ensuring that every pointer access is validated against a live memory object.

The Multi-Level Pointer Mechanism

The core innovation of MPChecker is the introduction of the base-level pointer (basePtr). Instead of a standard direct reference (Ptr -> Object), MPChecker instruments the code so that pointers point to a basePtr, which in turn points to the actual object (Ptr -> basePtr -> Object).

The Indirection Mechanism

This indirection serves as a security primitive. When an object is deallocated, MPChecker immediately invalidates the associated basePtr (e.g., by setting it to NULL or inverting its bits). Because all copies of a pointer—including those created through type-unsafe operations like memcpy—still reference the same basePtr, they are all neutralized simultaneously. Any subsequent attempt to dereference a dangling pointer will trigger a safe segmentation fault rather than allowing an exploit to proceed.

To maintain efficiency, MPChecker utilizes the unused high bits of 64-bit addresses as metadata flags. This allows the ptrCheck() function to quickly distinguish between protected and unprotected pointers at runtime without expensive lookups.

Evaluation and Results

MPChecker was evaluated using standard benchmarks and real-world applications to measure its security efficacy and performance impact.

  • Security: The system successfully blocked UAF and double-free exploits in the HCTF 2016 capture-the-flag challenge and various real-world applications like redis and grep.
  • Performance: On the SPEC CPU2006 suite, MPChecker introduced an average overhead of 62%. While higher than simple bounds-checkers, this is competitive with other comprehensive UAF defenses like DangNULL and FreeSentry, especially considering MPChecker's broader protection scope (including stack and global pointers).
  • System and Scalability: In system-level tests (UnixBench), the overhead was significantly lower, averaging roughly 3.5%. Testing on the PARSEC 3.0 suite demonstrated that MPChecker scales well in multi-threaded environments, thanks to a lock-free design for basePtr value access.

Conclusion and Limitations

MPChecker provides a robust defense against UAF exploits by leveraging multi-level pointer indirection. Its ability to track pointers through type-unsafe operations and its scalability in multi-threaded contexts represent significant improvements over prior work. However, the system requires access to source code for LLVM instrumentation and incurs a memory overhead of approximately 2.06x. Future work will focus on optimizing the ptrCheck() function to further reduce performance costs for high-throughput production environments.

Summary updated

BibTeX
@article{qiang2019mpchecker,
  author = {Weizhong Qiang and Weifeng Li and Hai Jin and Jayachander Surbiryala},
  title = {{Mpchecker: Use-After-Free Vulnerabilities Protection Based on Multi-Level Pointers}},
  journal = {IEEE Access},
  year = {2019},
  doi = {10.1109/access.2019.2908022},
}
Figure