Validity fuzzing and parametric generators for effective random testing

Rohan Padhye, Caroline Lemieux, Koushik Sen, Mike Papadakis, Yves Le Traon

Abstract

Programs expecting structured inputs often consist of both a syntactic analysis stage, in which raw input is parsed into an internal data structure, and a semantic analysis stage, which conducts checks on this data structure and executes the core logic of the program. Existing random testing tools tend to produce inputs that are rejected early in this pipeline. We propose Zest, a random testing methodology for effectively exploring the semantic analysis stages of such programs. Zest combines two key innovations to achieve this. First, we introduce validity fuzzing, which biases coverage-guided fuzzing (CGF) towards generating semantically valid inputs. Second, we introduce parametric generators, which convert input from a simple parameter domain, such as an un-typed sequence of bits, into a more structured domain, such as syntactically valid XML. These generators enable bit-level mutations of the parameters to map to structural mutations in syntactically valid test inputs. In our experiments with Zest on six popular JVM-based projects, we find 18 new bugs, of which 7 are not found by baseline CGF and generator-based techniques.

Introduction

Modern software systems, such as compilers, build tools, and image processors, typically process inputs through a multi-stage pipeline. The initial syntactic analysis stage (the parser) ensures the input is well-formed, while the subsequent semantic analysis stage validates the data against specific logic and executes the core functionality.

The two-stage processing pipeline of complex software.

Traditional coverage-guided fuzzers (CGF), like AFL, often fail to penetrate the "semantic wall." They generate byte-level mutations that are frequently rejected by the parser as "garbage," resulting in poor exploration of the program's deep logic. Conversely, generator-based testing (e.g., QuickCheck) produces syntactically valid inputs but lacks the feedback mechanism to guide exploration toward new code paths. Zest bridges this gap by combining the feedback-driven nature of CGF with the structural awareness of generators.

Methodology

Zest introduces two primary innovations to overcome the limitations of existing fuzzing techniques:

Parametric Generators

Instead of generating raw bytes, Zest utilizes parametric generators. These generators consume a "parameter sequence"—a stream of numbers—to make structural decisions during input construction (e.g., determining the number of children in an XML node). By mutating this underlying sequence rather than the final output, Zest performs high-level structural mutations while maintaining syntactic validity. This approach treats the generator's choices as the "DNA" of the test case, where small changes in the DNA lead to valid but structurally diverse "bodies."

Validity Fuzzing

Standard CGF saves any input that discovers a new code branch. Zest refines this through validity fuzzing, which specifically tracks branches reached by semantically valid inputs. By biasing the search toward inputs that pass both syntactic and semantic checks, Zest effectively "learns" how to navigate the program's core logic.

Experimental Evaluation

Zest was evaluated against AFL and QuickCheck across six real-world Java benchmarks, including Apache Maven, Google Closure Compiler, and Mozilla Rhino.

Coverage and Efficiency

The results demonstrate that Zest achieves significantly higher code coverage in semantic analysis stages compared to baselines. For complex systems like Maven, AFL's effectiveness is severely limited; only 0.03% of its generated inputs are semantically valid. Zest overcomes this by construction, producing over 18x more semantically valid inputs than AFL within the same time budget.

Bug Discovery

Zest's ability to explore deep logic translated into significant bug-finding success. The tool discovered 18 new bugs across the benchmarks.

Bugs found by Zest and baseline techniques across six benchmarks.

Notably, 7 of these bugs were unique to Zest, remaining undiscovered by both byte-level fuzzers and pure generator-based tools. This highlights the synergy between coverage feedback and structural generation.

Conclusion

Zest demonstrates that combining parametric generators with validity-biased coverage feedback is a powerful strategy for testing complex software. While it requires the manual effort of defining a basic input generator, the resulting ability to bypass the "parser wall" and uncover deep semantic bugs offers a significant advantage over traditional methods. Future work may focus on automating generator derivation from formal grammars to further reduce setup costs.

Summary updated

BibTeX
@inproceedings{padhye2019validity,
  author = {Rohan Padhye and Caroline Lemieux and Koushik Sen and Mike Papadakis and Yves Le Traon},
  title = {{Validity fuzzing and parametric generators for effective random testing}},
  booktitle = {ICSE (Companion Volume)},
  year = {2019},
  url = {https://openreview.net/forum?id=rgbDOz627gq},
}
Figure