Fuzz testing
Fuzz testing, or fuzzing, is a test technique in which a tool feeds a program very large numbers of invalid, unexpected or random inputs and watches for crashes, hangs and failed assertions. Nobody writes an expected result for each input. The program passes while it survives, and every input that breaks it is kept as a reproducible test case.
The longer version
The name comes from a class project. Barton Miller's page at the University of Wisconsin records that the fuzz assignment was on the list of projects handed out to his graduate operating systems class in the autumn of 1988, and that the results appeared in December 1990 as An Empirical Study of the Reliability of UNIX Utilities, in Communications of the ACM. Wikipedia quotes Miller as saying he wanted a name that would evoke the feeling of random, unstructured data, and the accounts published by GitLab and Black Duck trace the idea to noise on a dial-up line that crashed the UNIX programs he was using. His description of classic fuzz testing holds the two ideas that still define the technique. The input is random, produced with no model of what the program is meant to do. The criterion is simple: an application that crashes or hangs fails the test, and otherwise it passes. The ISTQB glossary defines fuzz testing as a test technique in which high volumes of random data are used to generate test inputs, and lists fuzzing as a synonym. OWASP describes the same practice as automatically providing a program with unexpected, malformed or semi-malformed inputs. Volume does the work. A person can think of a few dozen awkward inputs, and a fuzzer keeps producing new ones for as long as it is left running.
Fuzzers differ in where their inputs come from. A mutation-based fuzzer starts from sample inputs, such as a folder of valid image files, and alters them a little at a time: bytes are changed, removed, repeated or moved. Google's fuzzing glossary calls a tool of this kind a mutation engine, one that takes a set of test cases and creates their mutated versions. A generation-based fuzzer builds each input from scratch according to rules or a grammar, which the same glossary calls a test generator, and it suits formats so strict that an altered sample is rejected at the first check. Coverage-guided fuzzing adds feedback from the program. The libFuzzer documentation describes its engine as tracking which areas of the code are reached and generating mutations on the corpus of input data in order to maximise code coverage. When a mutation triggers execution of a previously uncovered path, it is saved to the corpus for future variations. Inputs that reach somewhere new are kept and varied again, and the rest are discarded, so the fuzzer works its way past the checks that stop purely random data at the door. Fuzzers are also sorted by how much of the program they can see. Wikipedia's article describes black-box fuzzers, which treat the program as opaque and are fast but tend to find shallow bugs; white-box fuzzers, which use program analysis such as symbolic execution to reach deeper bugs more slowly; and grey-box fuzzers, which take lightweight coverage feedback, with AFL and libFuzzer as its examples.
Fuzzing belongs wherever software reads input it does not control: file uploads, image and document decoders, network protocols, API endpoints, and the query strings and form fields of a web application. Monkey testing is its relative one layer up. A monkey sends random taps and keystrokes to a user interface, and a fuzzer sends data to the code that parses it, usually with no interface involved. What a fuzzer reports is limited by what it can observe. A crash, a hang, a failed assertion or a memory error caught by checks compiled into the program is a finding. A wrong total returned without complaint is not, since nothing tells the fuzzer that the number is wrong. A run also has no natural end. By default, the libFuzzer documentation says, the fuzzing process will continue indefinitely, or at least until a bug is found, so a quiet run means only that nothing was found in the time given. Each failure is written to disk together with the input that caused it, and the report arrives with its own means of reproducing the fault.
Two neighbouring practices are often confused with fuzzing. Dynamic application security testing, or DAST, probes a running application from the outside, usually a web application through its HTTP interface, with requests designed to trigger known classes of vulnerability such as injection. A fuzzer works from no catalogue of attacks and is often pointed at a single parser inside the code, with no network in between. The two meet at the web form, where a fuzzer aimed at query strings and form fields does part of a scanner's work. Chaos testing injects failures into the infrastructure around a running system, such as a stopped server or a slow network, while fuzzing varies the data the system is handed. Most teams start from an existing engine instead of writing one, and Google announced OSS-Fuzz, a service that fuzzes open source projects continuously, in December 2016. Wikipedia also lists what a long, quiet run still misses: flaws that cause no crash, such as timing side channels, privilege escalation and logic errors.
Common questions
What is fuzz testing?
Fuzz testing, also called fuzzing, is an automated technique that runs a program against a very large number of invalid, unexpected or random inputs and records every input that makes it crash, hang or fail an internal check. The ISTQB glossary defines it as a test technique in which high volumes of random data are used to generate test inputs.
How is fuzz testing different from monkey testing?
The two differ in what they send and in what a failure leaves behind. A fuzzer sends data, such as a file, a message or a request, to the code that parses it, and each failure is saved as the one input that caused it. A monkey sends events to a user interface, and a crash may depend on the thousands of events that came before. Neither holds an expected result, so both report only that the program stopped working.
What is coverage-guided fuzzing?
Coverage-guided fuzzing is fuzzing in which the tool observes which parts of the code each input executes and keeps the inputs that reach something new. The libFuzzer documentation sets out the loop: random mutations are generated from a corpus of sample inputs, and a mutation that executes a previously uncovered path joins the corpus. Round by round, the fuzzer passes checks that random data alone would fail.
What is the difference between mutation-based and generation-based fuzzing?
Mutation-based fuzzing starts from existing sample inputs and alters them, so it needs a set of samples and no description of the format. Generation-based fuzzing builds each input from scratch according to rules or a grammar, so it needs that description and no samples. Some fuzzers combine the two: Imperva describes a generative fuzzer that splits a network packet into its fields and fuzzes each one while keeping the structure intact.
What is the difference between mutation testing and fuzz testing?
The two change opposite things. Fuzz testing leaves the program alone and changes its inputs, looking for an input that makes the program fail. Mutation testing leaves the inputs alone and changes the program, planting small faults to see whether the existing test suite notices them. A fuzzer tests the software, and mutation testing tests the tests. Mutation-based fuzzing is a kind of fuzzing and has no connection with mutation testing beyond the word.
What is the difference between DAST and fuzz testing?
DAST, dynamic application security testing, scans a running application from outside, usually over HTTP, with requests built to trigger known kinds of vulnerability such as injection and cross-site scripting. Fuzz testing generates large numbers of unexpected inputs with no list of known attacks and watches for crashes, hangs and failed checks, often against one parser in isolation. The two overlap where a fuzzer is aimed at a web application's parameters.
Why is it called fuzz testing?
The name comes from Barton Miller's 1988 class project at the University of Wisconsin, which fed random input to UNIX utilities. Wikipedia quotes Miller as saying he wanted a name that would evoke the feeling of random, unstructured data, and accounts published by GitLab and Black Duck trace the idea to noise on a dial-up line crashing the programs he was using.
What kinds of bugs does fuzz testing find?
Fuzz testing finds failures a program cannot hide: crashes, hangs, failed assertions, memory errors and unhandled exceptions. These matter for security wherever the input comes from outside. OWASP notes that fuzzers usually tend to find simple bugs. A defect that produces a wrong answer with no visible failure goes unnoticed unless the code contains an assertion that checks the answer.
Bug reports that arrive ready to triage.
Collect replay, console, network and browser context with the Free plan.