HOPPER: Interpretative Fuzzing for Libraries

Peng Chen, Yuxuan Xie, Yunlong Lyu, Yuxiao Wang, Hao Chen · DOI

Abstract

Software libraries are foundational components of modern systems, yet their security testing via fuzzing remains challenging due to the need for manual fuzz drivers and the complexity of API constraints. We present Hopper, an interpretative fuzzer that automates library testing by treating API calls as a domain-specific language (DSL). Hopper dynamically learns intra- and inter-API constraints through feedback, eliminating the need for manual driver creation. In evaluations across 11 widely-used C/C++ libraries, Hopper discovered 25 previously unknown bugs and significantly outperformed both manual drivers and state-of-the-art automated tools in code coverage and API reach.

Introduction

Fuzzing—the process of feeding random inputs to a program to find crashes—is a standard practice for finding software vulnerabilities. While highly effective for standalone applications, libraries (such as image parsers or database engines) present a unique challenge: they lack a single entry point. To fuzz a library, developers must create "fuzz drivers," which are small wrapper programs that translate fuzzer-generated bytes into valid API call sequences.

This manual process is a significant bottleneck. Manual drivers often cover only a small fraction of a library's functionality and struggle to maintain the complex constraints required by the API. For example, a library might require a specific initialization function to be called before any data processing, or an integer argument might need to exactly match the length of a provided buffer. Violating these rules leads to "spurious crashes" that waste computational resources. Hopper addresses these challenges through a paradigm shift known as interpretative fuzzing.

Methodology

Hopper replaces the traditional "compile-run-crash" cycle with a lightweight interpreter linked directly against the target library. This approach allows for faster iteration and more granular control over the execution environment.

The Hopper DSL and Mutation

Hopper generates "programs" in a custom Domain-Specific Language (DSL) that describes sequences of API calls, variable loads, and assertions. The fuzzer is grammar-aware, utilizing information from the library's header files (structs, enums, pointers) to perform type-safe mutations. For instance, it can intelligently swap pointers of the same type or flip bits in primitive values while maintaining the overall structure of the API call.

Dynamic Constraint Learning

Hopper’s core innovation is its ability to learn constraints through trial and error without prior manual documentation:

  • Intra-API Constraints: If an API call crashes due to a null pointer, Hopper identifies the offending argument and adds a NON-NULL constraint. It also uses memory "canaries" to detect buffer overflows and automatically infers if a numerical argument represents a buffer's length.
  • Inter-API Constraints: Hopper tracks which sequences of calls reach new code. If calling Function A before Function B increases code coverage, Hopper learns that A provides the necessary context or state for B. This allows the fuzzer to "stitch" together complex API chains, such as passing an opaque database handle from an opener function to a query function.

Evaluation

The authors evaluated Hopper against 11 prominent, real-world C/C++ libraries across various domains, including data utilities (cJSON, zlib), networking/databases (c-ares, sqlite3), and multimedia (libpng, libvpx). Hopper was compared against manually crafted fuzzers (MCF) from the Google OSS-Fuzz project and state-of-the-art automated tools like FuzzGen and GraphFuzz.

Key Results

Hopper demonstrated significant improvements over existing methodologies in several key metrics:

  • Bug Discovery: Hopper uncovered 25 previously unknown bugs, 17 of which were confirmed by developers. These included null pointer dereferences, buffer overflows, and an infinite loop in the widely-used zlib library.
  • Code Coverage: Hopper significantly outperformed manual drivers. In the cJSON library, it achieved 47% higher line coverage than the official manual fuzzers.
  • API Reach: On average, Hopper successfully invoked 93.5% of the available APIs in the test libraries. In contrast, manual drivers covered only 18.6%, and the best automated competitor, GraphFuzz, reached 41.4%.
  • Constraint Accuracy: Hopper learned 973 intra-API constraints with 96.5% precision, proving that dynamic feedback is a viable substitute for manual documentation.

Discussion and Limitations

While Hopper represents a major advancement, some limitations remain. The current implementation handles C-style APIs effectively but struggles with complex C++ features like templates and classes. Additionally, some learned constraints are approximations; while they prevent spurious crashes, they may occasionally be too restrictive, potentially missing edge cases. Finally, Hopper faces challenges with "deep" semantic bugs that require very specific, long-range logical dependencies.

Future work will focus on extending Hopper’s support for complex C++ features and providing mechanisms for users to "seed" the fuzzer with known complex constraints to further boost efficiency.

Summary updated

BibTeX
@inproceedings{chen2023hopper,
  author = {Peng Chen and Yuxuan Xie and Yunlong Lyu and Yuxiao Wang and Hao Chen},
  title = {{HOPPER: Interpretative Fuzzing for Libraries}},
  booktitle = {CCS},
  year = {2023},
  doi = {10.1145/3576915.3616610},
}
Figure