Go's Native Fuzzer Doesn't Solve Predicates — Your Harness Does
Go shipped fuzzing as a first-class go test mode in 1.18, and six years later it is in every Go shop's pipeline. The flag everyone tunes is -fuzztime. The fl...
Go shipped fuzzing as a first-class go test mode in 1.18, and six years later it is in every Go shop's pipeline. The flag everyone tunes is -fuzztime. The flag that actually decides whether a campaign finds anything is the shape of the comparison inside your target. I measured this on a 4-core i5-6500T with go1.24.4: the same 12-byte string predicate, three ways, three completely different outcomes.
What the Engine Actually Measures
Native Go fuzzing is coverage-guided, and the coverage is edge counters the compiler inserts into your test binary. Each execution reports which edges it took. The coordinator compares that set against everything seen so far, and keeps the input only if it found a new edge. That is the entire feedback loop.
There is no comparison tracing. AFL++ calls its version CMPLOG, LibAFL calls it Redqueen; the technique is to log the two operands of every == and memcmp the target performs, then synthesise an input that satisfies the comparison directly. Go's native engine does none of that. It does not know your code compared two strings — only which basic blocks ran.
So progress is a function of block granularity, not of how close the mutator got. Three harnesses, identical semantics:
const sentinel = "GOFUZZCMPLOG"
func FuzzCompare(f *testing.F) {
f.Add("seed")
f.Fuzz(func(t *testing.T, s string) {
if s == sentinel {
panic("reached")
}
})
}
Thirty seconds of fuzzing on four workers: 2,192,558 executions, new interesting: 0 (total: 1). The corpus never grew, because the only new edge available is the one behind the comparison. The random chance of synthesising a specific 12 bytes is 2-96. At the 70,000 execs/sec this box sustains, that is roughly 3.6×1016 years.
The interesting part is not that an unsolvable predicate stayed unsolved. It is that the engine consumed 2.2 million executions without the operator noticing anything: no warnings, no stall detection, a clean PASS at the end. A campaign that finds nothing looks exactly like a codebase that has nothing.
One Predicate, Three Shapes, Three Outcomes
Rewrite the same check as a loop over indices and the outcome does not change. Five new edges appeared, the corpus grew to 6 entries, and the crash never fired in 2,200,431 executions. A loop body is a single basic block; entering it on iteration 0 and iteration 11 produces the identical edge set, so the engine gets no signal about how deep it got.
Rewrite it as twelve chained comparisons and the crash lands in the second half of a 30-second budget — 16.4 s of wall clock including the instrumented build. Same string, same order of checks, same compiler, different block structure. Each if is its own block, so pushing past byte n is a distinct, observable event that the coordinator can reward.
func FuzzChained(f *testing.F) {
f.Add("seed")
f.Fuzz(func(t *testing.T, s string) {
if len(s) < 12 || s[0] != 'G' || s[1] != 'O' || s[2] != 'F' {
return
}
if s[3] != 'U' || s[4] != 'Z' || s[5] != 'Z' || s[6] != 'C' {
return
}
if s[7] != 'M' || s[8] != 'P' || s[9] != 'L' {
return
}
if s[10] != 'O' || s[11] != 'G' {
return
}
panic("reached")
})
}
- Single
==on 12 bytes: 2.19M execs, 0 new edges, unsolved. - Per-byte loop, same literal: 2.20M execs, 5 new edges, unsolved.
- Twelve chained
ifblocks: solved, crasher minimised to the exact 12 bytes.
That last row costs nothing in production code, which is why the finding is worth acting on. Parsers already look like this: each token, each length prefix, each terminator gets its own error return, so each one is a separate block and the fuzzer walks the grammar one decision at a time. Code that funnels everything through bytes.Equal, a regexp, or a hash is a wall — not because the check is hard, but because it is opaque.
Also note the gap between prediction and reality. Twelve bytes at roughly one useful value per attempt is about 3,000 attempts of expected work, which is fifty milliseconds at 65,000 execs/sec. The run took sixteen seconds. Mutation luck is not the cost; corpus scheduling is. The engine has to re-select the one input that got to level seven and re-mutate it, and most selections land on inputs that get nowhere.
The Corpus Is the Deliverable, Not the Run
Seed the sentinel literal through f.Add and the campaign is over before fuzzing starts: --- FAIL at 0.01 s, during baseline coverage, when the seed corpus is replayed as ordinary tests. Nothing was searched. The engine was handed the answer and dutifully reported it.
That is the mental model to hold: go test -fuzz is a corpus generator with a weak mutator bolted on, and the corpus in testdata/fuzz is the artifact you keep. Every file there is an edge case somebody now no longer has to think of, and every one of them replays under plain go test with no fuzzing flags in CI.
# crasher written by the engine, in the seed corpus format
$ cat testdata/fuzz/FuzzParse/b456f27416f443a7
go test fuzz v1
[]byte("\x00\x00\x00\x000")
# no -fuzz flag: the corpus is now a regression suite
$ go test -run=FuzzParse ./...
panic: runtime error: index out of range [5] with length 5
That file is the real output of my first TLV parser attempt, and it took 0.18 s to find. I wrote if len(data) < 5 and then read data[5]; a five-byte input of mostly zeroes walks straight into it. Shallow bugs of this kind are what a coverage-guided engine is genuinely good at: the panic is one branch away from the seed, so one mutation reaches it. It then minimised the input to exactly five bytes, which is the whole point of keeping the file — the failing case is now smaller than anything a human would have written by hand.
A realistic target behaves differently. A length-prefixed record parser with four error returns ran 3,931,964 executions in 60 s at ~65,000 execs/sec and produced 7 interesting inputs, a fuzz cache of 608 KB. That is the shape of a healthy campaign: slow corpus growth, most of it in the first seconds, then a long plateau where the engine is recombining what it already has.
func FuzzParse(f *testing.F) {
f.Add([]byte{0, 0, 0, 5, 1, 3, 'a', 'b', 'c'})
f.Add([]byte{0, 0, 0, 3, 2, 1, 'x'})
f.Fuzz(func(t *testing.T, data []byte) {
r, err := Parse(data)
if err != nil {
return
}
// assert an invariant, not a success path
if len(r.Body) >= 8 && bytes.Equal(r.Body[:8], marker) {
t.Fatalf("deep marker reached")
}
})
}
Two design rules fall out of the measurements. Seed at least one valid input, because a mutator with no valid scaffold spends its budget rediscovering the header. And assert invariants rather than the absence of errors: an error return is a legal outcome, a panic is not, and a predicate like "these two encoders agree on everything they both accept" is worth more than a thousand if err != nil { return } lines.
Throughput Is a Harness Property
The worker model is one OS process per worker, coordinated over RPC, and it scales predictably until it hits physical cores. On this 4-core box, using the unsolvable single-== target as a fixed workload: 28,120 execs/sec at -parallel=1, 51,756 at -parallel=2, and ~70,000 at the default of four workers. That is 2.5× for 4× the processes — the last doubling buys almost nothing because instrumentation and the coordinator both compete for the same cache.
Now the number that should shape your harness: a 60-second CI run buys about 4.2 million executions, which is about 222 guesses. Count the bits in your predicate before you read anything into a green run.
- One byte of structure (256 values): solved in seconds.
- Two bytes (65,536): seconds to a minute.
- Three bytes (16.7M): about four minutes.
- Four bytes (4.3×109): about 18 hours at 65,000 execs/sec.
The same arithmetic explains why the twelve-chained-if harness worked: it never had to guess twelve bytes at once, only one at a time, twelve times, and each of those is a separate 8-bit problem with its own edge to discover.
Slow targets are the other half of throughput, and this is where the engine's behaviour diverges from its documentation. A target that sleeps unconditionally for 3 s does not trip the documented one-second per-execution bound. It ran 13 executions in 15 s — under one per second across all four workers — and finished normally. The watchdog catches a worker that stops answering; it does not catch a worker that answers slowly. No allocation ceiling, no I/O guard, no warning. Your fuzz target's runtime is your campaign budget, and there is no referee.
What the Native Engine Still Cannot See
The missing comparison tracing is not an oversight, it is a maintenance decision: logging operands costs instrumentation the compiler must emit on every build, and go test is the hot path for every Go developer on earth. The cost lands on the ecosystem, so the feature lives outside the toolchain. Trail of Bits' gosentry (May 2026) is a fork of the Go toolchain that swaps the engine for LibAFL while keeping the testing.F surface — a real answer to CMPLOG-shaped predicates, at the price of owning a toolchain fork across Go upgrades.
The type system is the second gap. F.Fuzz accepts scalars only: string, []byte, the sized integers, floats, bool. Structs, slices of structs, maps, and pointers need a hand-written codec, and the codec's own branches get instrumented alongside the code under test. Go proposal 48815 names the consequence precisely: a seed generated from a PRNG stores the seed, not the structure, so a change to the generator invalidates the corpus, and uninteresting inputs get classified as interesting because the generator's coverage moved.
Three-or-four more blind spots are worth stating plainly, because each one produces a clean campaign over broken code:
// what the engine will never tell you without help
x := int32(math.MaxInt32)
x++ // overflows silently; no panic, no failure
go func() { consume(q) } // leaked goroutine; the engine sees a passing call
if err := mutexGuardedWrite(); err != nil {
return err // data race needs -race, a separate binary
}
Integer overflow needs -race-style instrumentation or an assertion; goroutine leaks need goleak or a count check; races need go test -race -fuzz, which doubles per-exec cost and therefore halves your 222 budget; and coverage instrumentation only exists on amd64 and arm64, so -fuzz is rejected outright on other platforms rather than degrading to blind mutation. Add it up and the native engine covers one failure class — reachable panics and violated invariants — extremely well, and covers arithmetic, concurrency, and lifetime bugs not at all.
Which leaves a harness that is mostly bookkeeping: bounded input sizes so one execution stays in microseconds, no shared mutable state so coverage attribution stays honest, no filesystem or network so the campaign does not stall at one exec/sec, chained comparisons so every step of progress is an edge the coordinator can see, one valid seed so the mutator does not rebuild your header from scratch, and in CI so a crash report lands in the log instead of spending a minute shrinking it. None of that is fuzzing. All of it determines whether fuzzing happens.-fuzzminimizetime 0