Notes
The idea
The idea is simple. Take a piece of code that parses input: a file format reader, a protocol handler, an API. Generate or mutate huge numbers of inputs and run them through, often thousands per second. Watch for anything going wrong: a crash, a hang, an assertion failure, a memory error. Every input that breaks something is saved as a reproducer. The power is in the volume and the automation; the fuzzer explores a space of inputs far larger than any human could enumerate by hand, and it never gets bored.
- take a target that parses input
- generate or mutate huge numbers of inputs
- run them through, very fast (thousands per second)
- watch for: crashes, hangs, assertion failures, memory errors
- save every input that breaks something
Coverage-guided
The breakthrough that made fuzzing so effective is coverage guidance. Naive fuzzing sends random bytes, rejected at the first validation check, never reaching the interesting code. Coverage-guided fuzzing instruments the target to see which code each input reaches. It keeps inputs that reached new code and mutates those further, working deeper, in effect discovering the input format by exploration. AFL++ and libFuzzer work this way, which is why a fuzzer finds a bug buried behind many layers of parsing.
- naive fuzzing: random bytes; mostly rejected at the first check
- coverage-guided: measure which code each input reaches
- keep inputs that reach NEW code; mutate those further
- the fuzzer effectively learns the input format by exploration
- AFL++, libFuzzer work this way
What it finds
What does fuzzing catch? Crashes and unhandled exceptions, directly. In memory-unsafe languages like C and C plus plus, with sanitizers, it finds buffer overflows and use-after-free, the memory corruption that leads to exploits. It finds hangs and denial of service, where a crafted input loops forever or runs very slowly. And with more effort, logic bugs: you add assertions or property checks, or run two implementations and flag when they disagree on the same input, called differential fuzzing.
- crashes and unhandled exceptions
- memory safety bugs in C/C++: overflows, use-after-free (with sanitizers)
- hangs and denial of service (slow inputs, infinite loops)
- logic bugs via assertions and property checks
- differential: two parsers disagree on the same input
Where it fits
Fuzzing shines wherever code parses untrusted input with a clear boundary. File format parsers for images, documents, archives and media are classic targets, historically full of bugs. Network protocol handlers. Serialization code. Compilers and interpreters. API request parsers. Encoding and cryptographic routines. If you can write a small function that takes a byte array and feeds it to the code under test, you can fuzz it. The clearer the input boundary, the more productive the fuzzing.
- file format parsers (images, PDF, archives, media)
- network protocol handlers
- serialization / deserialization
- compilers and interpreters
- APIs and request parsers
- crypto and encoding routines
- anything taking untrusted input with a clear boundary
Writing a harness
To fuzz your own code you write a harness: a tiny function that takes the fuzzer's bytes and passes them to the code under test. Here is the shape of a libFuzzer harness in C. Go has native fuzzing in its testing package; Python has Atheris, Java has Jazzer, Rust has cargo-fuzz. You give the fuzzer a few valid inputs as seeds, which it mutates, and run it with sanitizers enabled so memory bugs are caught. Writing the harness is usually an afternoon, and the first run often finds something.
// libFuzzer-style harness
int LLVMFuzzerTestOneInput(
const uint8_t *data, size_t n) {
parse_config(data, n);
return 0;
}
// Go: func FuzzParse(f *testing.F)
// Python: Atheris; Java: Jazzer
// seed it with real valid files In practice
In practice, fuzzing is continuous, not a one-off. Many bugs only surface after hours or days, so fuzzers run constantly. Google's OSS-Fuzz does this for major open-source projects around the clock, for free, and has found tens of thousands of bugs. When crashes come in, you triage and deduplicate them, because many crashing inputs map to one underlying bug. And every fixed crash becomes a regression test: the crashing input is kept, so that bug can never silently return.
- run continuously, not once: bugs surface over hours and days
- OSS-Fuzz: Google fuzzes major open-source projects 24/7, for free
- triage and deduplicate crashes (many map to one bug)
- each fixed crash becomes a regression test (the input is the test case)
Limits
Know the limits. Fuzzing is strongest on code that parses input; it is weak on business logic and access control, where there is no crash to observe. It needs a harness and good seeds. It measures coverage, not correctness, so no crash does not mean no bugs. A crash shows something is wrong but still needs triage to judge exploitability. So fuzzing is a powerful member of the toolkit alongside static analysis, code review and dynamic testing, not a replacement.
- best at input-parsing code, weaker on business logic and access control
- needs a harness and seeds
- coverage, not correctness: no crash is not "no bugs"
- crashes still need triage to judge exploitability
- pairs with SAST, review and DAST, not a replacement
Common mistakes
Mistakes. Running a fuzzer once instead of continuously, so the deeper bugs never surface. Fuzzing without sanitizers, so memory corruption happens silently. Poor or no seed inputs, leaving the fuzzer stuck at the entrance. Ignoring hangs and timeouts, which are real denial-of-service findings. Not deduplicating crashes, so one bug looks like a thousand. Not turning a fixed crash into a regression test. And expecting fuzzing to find logic or authorization bugs.
- running it once, not continuously
- no sanitizers, so memory bugs go unseen
- poor or no seed inputs
- ignoring hangs and timeouts
- not deduplicating crashes
- no regression test from a fixed crash
- expecting it to find logic or authz bugs
Say it like this
In the interview: fuzzing feeds huge volumes of malformed input to code to find cases a human would never test. Modern fuzzers are coverage-guided: they instrument the code and evolve inputs to reach new paths, learning the input format and digging deep. I target anything that parses untrusted input, parsers, protocols, APIs, with a small harness, run with sanitizers enabled, continuously. I deduplicate and triage crashes, and keep every fixed crash as a regression test. It complements SAST, review and DAST.
- "Fuzzing feeds huge volumes of malformed input to find cases
- I would never test. Modern
- fuzzers are coverage-guided, so they evolve inputs to reach
- new code. I target parsers and protocols, write a harness, run with sanitizers, continuously, and keep each crash as a regression test."