Fuzz4All: Universal Fuzzing with Large Language Models

Chunqiu Steven Xia, Matteo Paltenghi, Jia Le Tian, Michael Pradel, Lingming Zhang

TL;DR

This paper introduces Fuzz4ALL, a novel universal fuzzer that leverages Large Language Models (LLMs) to generate diverse and realistic inputs for a wide range of programming languages and systems. By employing an "autoprompting" technique and an iterative "fuzzing loop," Fuzz4ALL significantly outperforms existing language-specific fuzzers in code coverage and has discovered a substantial number of previously unknown bugs in widely used software.

What Problem Does This Paper Address?

Fuzzing is a powerful technique for finding bugs in software, particularly effective for systems that process programming or formal languages like compilers, runtime engines, and constraint solvers. However, current fuzzing tools suffer from a critical limitation: they are typically designed for a specific language or even a particular version of that language. This "language-specific" nature makes them inflexible, requiring significant effort to adapt to new languages or to test new features within existing ones. Furthermore, existing fuzzers often struggle to generate inputs that cover the full spectrum of a language's features, potentially missing bugs related to newer or less common functionalities. This leads to a constant arms race where fuzzers become less effective as software evolves.

Methods

Fuzz4ALL tackles this problem by using Large Language Models (LLMs) as its core engine for generating and mutating fuzzing inputs. The key innovations are:

  • Universal Input Generation: Instead of relying on hand-crafted grammars or mutation rules, Fuzz4ALL leverages the broad knowledge of LLMs, which are pre-trained on vast amounts of code and text, to understand and generate inputs for various languages.
  • Autoprompting: To bridge the gap between raw user input (like documentation or example code) and effective LLM prompts, Fuzz4ALL employs an "autoprompting" technique. This process distills user-provided information into concise, informative prompts that guide the LLM to generate relevant fuzzing inputs. This is achieved by using a powerful distillation LLM to generate multiple candidate prompts and then scoring them based on their ability to produce valid inputs for the target system.
  • LLM-Powered Fuzzing Loop: To ensure diversity and avoid repetitive inputs, Fuzz4ALL uses an iterative fuzzing loop. In each iteration, the LLM is guided by the initial prompt, a previously generated valid fuzzing input (as an example), and a "generation strategy" (e.g., "generate-new," "mutate-existing," "semantic-equiv"). This dynamic prompting allows Fuzz4ALL to continuously explore new input spaces and adapt to evolving software.

Datasets

The paper does not explicitly mention training datasets for the LLMs used. However, the evaluation utilizes:

  • User-provided documentation: For each System Under Test (SUT), the authors used documentation (e.g., C++ standard documentation for std::expected, Go standard library documentation, SMT2 language overviews) as input for the autoprompting stage.
  • Existing SUTs: The evaluation was performed on nine real-world systems across six languages, including GCC, Clang, Z3, CVC5, Go toolchain, OpenJDK (javac), and Qiskit.

Key Insights and Ideas

  • LLMs as Universal Fuzzing Engines: The core insight is that LLMs, with their broad understanding of programming languages, can serve as a universal engine for fuzzing, eliminating the need for language-specific fuzzer development.
  • Autoprompting for Practicality: The autoprompting mechanism is crucial for making LLM-based fuzzing practical. It automates the complex and time-consuming task of prompt engineering, allowing Fuzz4ALL to effectively utilize diverse user inputs.
  • Iterative Prompt Refinement for Diversity: The fuzzing loop's ability to iteratively update prompts with examples and strategies is key to generating diverse inputs, which is essential for discovering a wide range of bugs.
  • Targeted Fuzzing with LLMs: Fuzz4ALL demonstrates that LLMs can be effectively directed to focus on specific language features or APIs, enabling targeted fuzzing for new or evolving software components.

Key Results

  • Superior Code Coverage: Fuzz4ALL achieved higher code coverage across all six tested languages (C, C++, Go, SMT2, Java, Python) compared to state-of-the-art language-specific fuzzers, with an average improvement of 36.8%.
  • Bug Discovery: Fuzz4ALL identified a total of 98 bugs in the evaluated systems.
  • Novelty of Bugs: A significant portion of these bugs, 64 in total, were confirmed by developers as previously unknown.
  • Efficiency: Despite generating fewer valid inputs and a lower validity rate compared to some traditional fuzzers (due to LLM inference costs), Fuzz4ALL's diverse generation strategy leads to much higher coverage.
  • Targeted Fuzzing Effectiveness: In targeted fuzzing scenarios, Fuzz4ALL achieved an average hit rate of 83.0% for the specific features it was instructed to focus on, significantly outperforming general fuzzing approaches in this regard.

Limitations and Future Work

  • LLM Inference Cost: The current implementation of Fuzz4ALL is bottlenecked by the inference cost of LLMs, leading to fewer generated fuzzing inputs compared to traditional fuzzers.
  • "Hallucination" Risk: Like many LLM-based systems, Fuzz4ALL is susceptible to LLMs "hallucinating" or producing inaccurate information, which could affect the quality of generated prompts.
  • Data Shift: The effectiveness of the generation LLM might degrade over time as new language versions or features emerge that were not present in its training data. The authors suggest that the autoprompting step, by incorporating up-to-date documentation, can help mitigate this.
  • Future Work: The authors express a desire to address the "hallucination" issue and explore more efficient LLM architectures or prompting strategies. They also aim to further improve the generality and effectiveness of Fuzz4ALL.

Summary updated

BibTeX
@inproceedings{xia2024fuzz,
  author = {Chunqiu Steven Xia and Matteo Paltenghi and Jia Le Tian and Michael Pradel and Lingming Zhang},
  title = {{Fuzz4All: Universal Fuzzing with Large Language Models}},
  booktitle = {ICSE},
  year = {2024},
  doi = {10.1145/3597503.3639121},
}
Figure