Definition
Fuzzing, also called fuzz testing, is an automated testing method that runs a program on a very large number of generated or modified inputs and watches every run for a failure. A fuzzer is the tool that produces the inputs, runs the target program and records failures. The test oracle §10.5, the check that decides whether a run failed, can detect a crash, a hang, a memory error or the violation of a rule the tester wrote down. Fuzzing searches for failures; it does not prove their absence.
The idea
A program that reads outside input must handle every possible input, but its tests cover only the inputs its authors thought of. Malformed, truncated, oversized and contradictory inputs are where unexpected behavior hides, and an attacker chooses exactly those. A fuzzer does not need to think of them: it tries millions of inputs, far more than anyone writes by hand, and keeps the ones that cause a failure. Barton Miller and his students at the University of Wisconsin introduced the method; their 1990 study fed random characters to Unix command-line programs and made many of them crash or hang [491].
Modern fuzzers do much more than send random bytes. They change example inputs (mutation-based fuzzing §10.10) or build inputs from a description of the format (generation-based fuzzing §10.11), and many of them watch which parts of the program each input reaches and keep the inputs that reach new code (coverage-guided fuzzing §10.12). Fuzzing is best pictured as a search through the space of inputs, steered by feedback, for an input that the oracle flags. The search can find only what the oracle is able to see.
How it works
A fuzzing campaign, one sustained run of a fuzzer against one target, has six parts.
Fuzz harness §10.13. A small program that takes one input from the fuzzer, puts the target into a defined starting state, calls the target’s entry point with the input, and cleans up so that the next input starts from the same state. With libFuzzer §10.26, a fuzzing library distributed with the Clang §12.17 compiler for C and C++, the harness is one function,
LLVMFuzzerTestOneInput, which receives a pointer to the input bytes and their number.Input production. Mutate inputs taken from a seed corpus §10.14, a set of example inputs, or generate inputs from a model of the format.
Execution with limits. Run the target with a time limit per input and a memory limit, so that a hang or a runaway memory request is detected instead of stalling the campaign.
Oracle. Decide after each run whether it failed. The target is often built with a sanitizer §10.21, a set of checks that the compiler adds to report errors that do not crash the program, such as AddressSanitizer §10.22 for reads and writes outside an object.
Feedback. In coverage-guided fuzzing, keep each input that reached code no earlier input reached, and mutate it further.
Evidence. Save every failing input, group the failures by cause, shrink each input to a small one that still fails, and confirm that it fails again when replayed on its own.
The oracle decides what counts as a bug, and a crash is only the easiest signal to see. An oracle can also flag memory errors that do not crash, undefined behavior §4.12, hangs, resource use above a stated bound, memory leaks §4.8, wrong results, violated security rules, and state that wrongly carries over from one run to the next; the answer at the end of this entry describes each class. Every class needs an explicit check and a stated bound, and each one is a bug only if a requirement forbids it. A malformed input that the target rejects with an error is the expected result, not a bug.
Worked example
A device accepts commands of bytes: a 1-byte command number, a 4-byte value, and a 16-byte authentication §1.6 tag, a message authentication code §5.7 (MAC) computed with a secret key over the first 5 bytes. The requirement is: a command whose tag is wrong must leave the stored value unchanged. The parser has a defect: it compares only the first byte of the tag.
A fuzzer with a crash-only oracle mutates commands for runs. Suppose every input carries a random tag. A random tag matches the first byte of the correct tag with probability , so about forged commands are accepted and change the stored value. None of them crashes the parser, so the crash-only oracle reports nothing.
Now the harness holds the test key, so it can compute the correct tag itself, and it applies a second oracle: if the tag of the input differs from the correct tag, the stored value after the run must equal the stored value before it. The first accepted forgery violates this check. With probability per input, the expected number of inputs up to and including the first acceptance is 256, so the defect is reported within the first few hundred runs.
The same oracle handles the other direction correctly. An input of 20 bytes is one byte too short; the parser rejects it with an error and changes nothing. That is the required behavior, and the oracle does not report it.
Stated precisely
A fuzzing result is a statement about one configuration: the target and its exact build (compiler, options, sanitizers), the harness and its starting state, the oracle, the seed corpus, the fuzzer and its settings, the duration and the number of executions. A reported failure is a concrete input for which the oracle flagged a violation. If the oracle is sound, meaning that it flags only real violations of a requirement, and fails again when replayed, then proves a bug in that configuration.
No result proves the absence of bugs. Suppose that each input triggers a given bug independently with probability . After inputs the bug is missed with probability , which is close to when is small; here is the base of the natural logarithm. A bug that needs one specific 4-byte value has , and it survives purely random inputs with probability . Real fuzzers do not draw independently, and is unknown, so no such number can be attached to a finished campaign. The calculation shows why blind search stalls at checks for exact values, and why fuzzers add feedback that learns such values.
The number of executions does not measure what was tested. A million inputs that differ only in bytes the target ignores test less than a hundred inputs that cross every length limit, version number and state of the target. Coverage metrics §10.18, which count the parts of the code that the inputs reached, are better, but they still measure where the inputs went, not whether the results were right.
Limits and common mistakes
A finite campaign without findings proves neither the absence of bugs nor memory safety. It shows that this oracle flagged none of these inputs in this configuration.
A harness can create false alarms §1.22. It can call the target in a state that the real program never reaches, or with inputs that the real caller has already rejected. Check every finding against a path that the real program can take.
A harness can also hide bugs. If it resets state that the real program keeps, bugs that need a history of inputs are out of reach.
Fuzzing a build for a desktop computer does not test the target device. The desktop build can differ in integer widths, byte order §4.21, memory layout, the scheduling of concurrent tasks, timing and hardware behavior. State which of these the campaign covered.
An oracle that never fires may be broken. Plant a known defect as a positive control §10.30 and confirm that the campaign reports it.
Each sanitizer finds only its own classes of error and slows the program. AddressSanitizer does not detect wrong results, and a crash-only oracle sees nothing that does not crash.
Questions answered
What constitutes a bug beyond a crash?
Beyond a crash, a bug in fuzzing is any run in which the target violates a stated requirement in a way that a test oracle, the check that judges each run, can detect. A fuzzer runs a program on a very large number of generated inputs and reports a bug only when its oracle flags a run, so every class of bug beyond crashes needs its own explicit check.
The usual classes are:
memory errors that do not crash, such as an out-of-bounds read §4.5 or a use-after-free §4.6, which a sanitizer (checks that the compiler adds to the program) reports;
undefined behavior such as signed integer overflow §4.15, which UndefinedBehaviorSanitizer §10.23 reports;
hangs, detected by a time limit per input;
resource use above a stated bound, such as memory or stack beyond a limit, or run time that grows far faster than the input, which lets one input cause a denial of service §1.28;
a memory leak, memory that is reserved and never released, which adds up over many inputs;
wrong results, detected by comparison with another implementation (differential testing §10.6) or by a property that the result must satisfy;
security violations, such as an input with an invalid authentication tag that still changes protected state, an operation carried out without authorization §1.7, or secret data in an output;
state that wrongly survives one input and changes how later inputs are handled.
Each class needs a requirement that defines it. A malformed input that is rejected cleanly with an error is the expected behavior, not a bug. Keep each failing input together with the build, harness and starting state needed to reproduce it.
Related entries: Test oracle (§10.5), Fuzz harness (§10.13), Coverage versus correctness (§10.40), Authorization (§1.7), Coverage-guided fuzzing (§10.12), Sanitizer (§10.21), Positive control (§10.30). Further reading: [24, 491].