TL;DR
Large Language Models (LLMs) are surprisingly capable of automating the creation of "fuzz drivers"—the glue code required to test software libraries for vulnerabilities. By evaluating over 700,000 generated drivers, this study demonstrates that while the best configurations can solve 91% of generation tasks, success depends heavily on iterative "generate-and-fix" loops and providing the model with high-quality code examples rather than just documentation.
What Problem Does This Paper Address?
Fuzz testing (or fuzzing) is the gold standard for finding zero-day vulnerabilities. It works by feeding massive amounts of mutated data into a program to see if it crashes. However, to fuzz a software library, you need a fuzz driver: a small piece of code that accepts the fuzzer's input and calls the library's APIs correctly.
Writing these drivers is a bottleneck. It requires deep knowledge of API dependencies and manual effort. While traditional automated tools exist, they often rely on complex program analysis that struggles with real-world code. LLMs offer a "text-based" alternative that can understand natural language documentation and code patterns, but until now, we didn't truly know how effective they were or what specific prompting strategies worked best.
Methods
The researchers conducted a massive empirical study using five state-of-the-art LLMs (including GPT-4, GPT-3.5, and open-source models like WizardCoder) across various "temperatures" (randomness settings).
They designed six distinct prompting strategies based on three key pillars:
- Information Richness: Providing basic API declarations vs. extended info like documentation or real-world usage examples.
- Repetition: Running the same query multiple times to account for LLM randomness.
- Iterative Querying: A "generate-and-fix" workflow where the model receives error feedback (compiler errors or runtime crashes) and attempts to fix the driver in subsequent rounds.
To ensure the generated drivers actually worked, they built a rigorous validation pipeline.
Datasets
- The Benchmark: A curated dataset of 86 fuzz driver generation "questions" derived from 30 popular C projects (e.g., OpenSSL, libxml2) hosted on Google's OSS-Fuzz.
- Scale: The study evaluated 736,430 generated drivers, consuming 0.85 billion tokens (costing over $8,000).
- Fuzzing Effort: They ran the resulting drivers for a total of 3.75 CPU-years to compare their performance against human-written industrial drivers.
Key Insights and Ideas
-
Complexity is the Success Killer: There is a clear inverse relationship between the complexity of an API's requirements and the LLM's success rate. As the number of unique project APIs and control flow dependencies increases, performance drops.
Figure 5: Average Query Success Rate Per Question Complex- ity Score Bucket. Data: All BACTX-K (K = 40) configurations. -
Examples Beat Documentation: Surprisingly, adding API documentation only provided minor benefits. However, providing usage examples (especially from the project's own test files) caused success rates to soar.
- The Power of the "Fix-Loop": Iterative querying is highly effective. By feeding back compiler and runtime errors, the LLM can resolve multi-level API dependencies that it missed in the first pass.
-
Diminishing Returns on Repetition: While repeating queries helps find a "lucky" correct output, the gains drop off significantly after about six attempts.
Figure 7: Statistics on the Effectiveness of Repeatedly Query.
Key Results
- Top Performance: The best configuration (
GPT-4+ALL-ITER-Kstrategy +0.5 temperature) solved 91% (78/86) of the benchmark questions. - Open Source vs. Closed: While GPT-4 remains the leader, open-source models like WizardCoder-15b performed remarkably well, even outperforming some closed-source models like Google's Text-Bison in specific tests.
- Industrial Parity: In head-to-head fuzzing trials, LLM-generated drivers achieved code coverage and crash-finding results comparable to manually written drivers used in industry for years.
- Real-world Impact: The study's insights on fixing runtime errors have already been integrated into Google’s OSS-Fuzz-Gen project, helping automate security testing for hundreds of open-source projects.
Limitations and Future Work
Despite the high success rates, the authors highlight a "semantic gap." LLMs often generate code that compiles and runs but is logically flawed—for example, passing a filename string to an API that expects the contents of a file. Currently, catching these "semantic" errors requires manual intervention or custom-written checkers.
Future work suggests moving toward hybrid approaches that combine LLMs with traditional program analysis to verify semantic correctness automatically. Additionally, fine-tuning models specifically on fuzzing-related code could improve efficiency and reduce the high token costs associated with massive repetition.
Summary updated