AI
Using Gemini and Z3 to catch bounds-checking bugs that fuzzing overlooks
A Google developer combines LLM translation and constraint solving to find slice-overflow crashes in Go code that traditional fuzz testing misses.
Google Developers Blog (AI)
Finding subtle bugs in production code remains a challenge, even with modern testing tools. A Google developer working on the agent skills program has demonstrated a novel workflow combining Gemini 4 Argon and the Z3 constraint solver to surface bounds-checking panics that standard fuzzing frequently overlooks.
How the approach works#
The method compiles Go functions to RISC-V assembly and extracts remaining bounds checks that the compiler's optimizer couldn't eliminate. Gemini 4 Argon then translates the source code and disassembly into Z3 constraints, modeling each path that could trigger a panic. Z3 checks whether those constraints can be satisfied, and any "sat" result—meaning satisfiable—comes with concrete byte values to replay against the real function. If the code panics, you have a genuine bug reproducer.
This represents a practical middle ground between pure fuzzing and full theorem proving. Rather than seeking correctness proofs (which formal verification requires), the approach trades away theoretical completeness for rapid, practical bug-finding at roughly one minute per function.
Why fuzzing misses these bugs#
Standard Go fuzzing maintains substantial spare capacity in test buffers. Analysis of 386,741 fuzz calls showed that 89% of inputs were slices into a shared ~100 MB buffer, with only 0.07% of inputs having capacity equal to length (cap == len). This spare capacity absorbs slice-overflow errors that should panic, hiding bugs indefinitely.
Two of three test bugs—ParseTwoChunkFrame and ExtractQuotedToken—involved arithmetic wraparound or off-by-one indexing that pushed access past the stated buffer length. Yet the fuzzer never triggered a panic because it sliced into excess capacity instead. Z3 found both instantly by constraining the buffer to exactly match its length.
A simple fix enables fuzzing to catch these misses:
f.Fuzz(func(t *testing.T, data []byte) {
data = data[:len(data):len(data)] // capacity now equals length
ParseTwoChunkFrame(data)
})
With this change, traditional fuzzing caught both overrun bugs in under half a second—far faster than the Gemini + Z3 pipeline. The third test case, ParseMagicPacket, panicked on a negative index regardless of capacity, so the fuzzer found it every time with or without the fix.

