# Fuzz Target Proof Checklist From the jwatte.com article "Your Fuzz Tests Probably Pass When They Shouldn't" (November 19, 2026): https://jwatte.com/blog/fuzz-targets-that-test-nothing-theorem-oss-verify/ The rules below follow Theorem Labs' OSS Verify add-project skill (https://github.com/theorem-labs/oss-verify/blob/main/.claude/skills/add-project/SKILL.md, Apache-2.0) and its review rules (review.md). They work for private code too. You do not need to enroll anything to use them. ## 1. Checklist for each fuzz target - [ ] I can say, in one sentence, which property this target checks. "Does not crash" counts, if that is what I mean. - [ ] Each property is written as `if (!condition) abort();`. No `assert()` (NDEBUG removes it). No `return -1` (libFuzzer and the OSS Verify driver treat it as a pass). - [ ] Each property has a comment in plain words: what it checks and why it must be true. - [ ] Every expected outcome ends as `return 0`: malformed input, a size limit, an error code, a refused allocation. - [ ] The expected value comes from the input and the documented rule, not from the library under test. - [ ] Every call's result is used. A call whose result nobody reads tests only that the call does not crash. - [ ] Each count, size, loop and recursion that comes from the input has a bound. - [ ] The run depends only on the input: no threads, clock, network, environment or files other than the input and temp files. - [ ] A seed corpus reaches every check at least once. I measured it with llvm-cov, not by eye. - [ ] Each check has a breakage: a one-line change that must make it fire, plus the seed input that shows it does. - [ ] CI applies each breakage and FAILS when one is not caught. Do not rely on a tool's exit status if it only reports. - [ ] I counted the properties per target. Zero means a crash test. That is fine if intended and a bug if not. ## 2. Agent prompt for private code Paste into a coding agent started in your repository: ````text Review the fuzz targets in this repository against these rules, one target at a time. For each target, list: 1. Each property it checks (each abort() or equivalent that ends the run on a wrong value). Say "none" if it only checks that the code does not crash. 2. Any assert() used for a property (removed under NDEBUG), any `return -1` or `return 1` after a failed check, and any library call whose result is never checked. 3. Any check whose expected value comes from the library under test. 4. For each property, a one-line change to the library that should make it fire, and whether an existing seed input would catch it. If no input would, write one. Do not change library code. Propose fuzz-target changes as a diff, and do not claim a check is correct unless you name the breakage that makes it fire. ```` ## 3. The demo: four round-trip targets for cJSON v1.7.19 All four claim the same property: parse, print, parse again, compare. Three carry a planted trap. build.sh compiles rt_assert.c with -DNDEBUG, as a release build does. ### rt_common.h ````c /* Copyright 2026 J.A. Watte * SPDX-License-Identifier: Apache-2.0 * * Shared helpers for the round-trip demo fuzz targets. Not a fuzz target itself. */ #ifndef RT_COMMON_H #define RT_COMMON_H #include #include #include "cJSON.h" /* cJSON prints a number that is not finite (from input such as 1e999) as null, by design. * Such a value cannot round-trip, so the round-trip property excludes it. cJSON limits nesting * to CJSON_NESTING_LIMIT, so this walk is bounded. */ static int rt_all_finite(const cJSON *item) { for (; item != NULL; item = item->next) { if (cJSON_IsNumber(item) && !isfinite(item->valuedouble)) return 0; if (item->child != NULL && !rt_all_finite(item->child)) return 0; } return 1; } #endif ```` ### rt_good.c ````c /* Copyright 2026 J.A. Watte * SPDX-License-Identifier: Apache-2.0 * * Round trip, written the way the OSS Verify add-project skill asks: the property is * `if (!condition) abort();`, it has a breakage record, and every expected outcome returns 0. */ #include #include #include "rt_common.h" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size); int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { cJSON *a, *b; char *text; if (size > 65536) return 0; /* bound the run */ a = cJSON_ParseWithLength((const char *)data, size); if (a == NULL) return 0; /* malformed JSON is an expected outcome */ if (!rt_all_finite(a)) { cJSON_Delete(a); return 0; } text = cJSON_PrintUnformatted(a); if (text == NULL) { cJSON_Delete(a); return 0; } /* a refused allocation */ b = cJSON_Parse(text); /* Round trip: what cJSON prints, cJSON parses back to an equal value. * mutant: cJSON.c:1039 `'\"'` -> `'\\'` * input: quote */ if (b == NULL || !cJSON_Compare(a, b, 1)) abort(); cJSON_Delete(b); free(text); cJSON_Delete(a); return 0; } ```` ### rt_assert.c ````c /* Copyright 2026 J.A. Watte * SPDX-License-Identifier: Apache-2.0 * * TRAP 1: the same round trip, checked with assert(). build.sh compiles this file with -DNDEBUG, * as a release build does, so the check is compiled out and the target can never fail. */ #include #include #include #include "rt_common.h" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size); int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { cJSON *a, *b; char *text; if (size > 65536) return 0; a = cJSON_ParseWithLength((const char *)data, size); if (a == NULL) return 0; if (!rt_all_finite(a)) { cJSON_Delete(a); return 0; } text = cJSON_PrintUnformatted(a); if (text == NULL) { cJSON_Delete(a); return 0; } b = cJSON_Parse(text); assert(b != NULL && cJSON_Compare(a, b, 1)); /* gone under NDEBUG */ cJSON_Delete(b); free(text); cJSON_Delete(a); return 0; } ```` ### rt_minus1.c ````c /* Copyright 2026 J.A. Watte * SPDX-License-Identifier: Apache-2.0 * * TRAP 2: the same round trip, but a failed property returns -1. libFuzzer reads -1 as * "do not keep this input", and the OSS Verify driver counts it as a pass. */ #include #include #include "rt_common.h" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size); int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { cJSON *a, *b; char *text; int ok; if (size > 65536) return 0; a = cJSON_ParseWithLength((const char *)data, size); if (a == NULL) return 0; if (!rt_all_finite(a)) { cJSON_Delete(a); return 0; } text = cJSON_PrintUnformatted(a); if (text == NULL) { cJSON_Delete(a); return 0; } b = cJSON_Parse(text); ok = (b != NULL && cJSON_Compare(a, b, 1)); cJSON_Delete(b); free(text); cJSON_Delete(a); if (!ok) return -1; /* looks like a failure, counts as a pass */ return 0; } ```` ### rt_unused.c ````c /* Copyright 2026 J.A. Watte * SPDX-License-Identifier: Apache-2.0 * * TRAP 3: the same calls, but the comparison's result is thrown away. The target exercises * the code and tests nothing beyond "does not crash". */ #include #include #include "rt_common.h" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size); int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { cJSON *a, *b; char *text; if (size > 65536) return 0; a = cJSON_ParseWithLength((const char *)data, size); if (a == NULL) return 0; if (!rt_all_finite(a)) { cJSON_Delete(a); return 0; } text = cJSON_PrintUnformatted(a); if (text == NULL) { cJSON_Delete(a); return 0; } b = cJSON_Parse(text); (void)cJSON_Compare(a, b, 1); /* called, result ignored */ cJSON_Delete(b); free(text); cJSON_Delete(a); return 0; } ```` ### build.sh (as run, four targets) ````bash #!/bin/bash -eu # Copyright 2026 J.A. Watte # SPDX-License-Identifier: Apache-2.0 # # Builds cJSON statically, then the four round-trip demo fuzz targets into $OUT. # Library build copied in form from projects/cjson/build.sh (Theorem Labs, Apache-2.0). build=$SRC/cjson-rtdemo mkdir -p "$build/cmk" cd "$build/cmk" cmake "$build/src" -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=OFF \ -DENABLE_CJSON_TEST=OFF -DENABLE_CUSTOM_COMPILER_FLAGS=OFF make -j"$(nproc)" for t in rt_good rt_minus1 rt_unused; do $CC $CFLAGS -I"$build/src" -c "$SRC/$t.c" -o "$WORK/$t.o" $CC $CFLAGS "$WORK/$t.o" -o "$OUT/$t" $LIB_FUZZING_ENGINE "$build/cmk/libcjson.a" -lm done # The assert() trap is compiled as a release build compiles it. $CC $CFLAGS -DNDEBUG -I"$build/src" -c "$SRC/rt_assert.c" -o "$WORK/rt_assert.o" $CC $CFLAGS "$WORK/rt_assert.o" -o "$OUT/rt_assert" $LIB_FUZZING_ENGINE "$build/cmk/libcjson.a" -lm ```` ### Seed corpus (six files, same for each target) - `quote`: `{"a\"b":"c\"d"}` - `mixed`: `{"name":"cafe","n":[1,2.5,-3e2,true,false,null],"o":{}}` - `nested`: `[[[{"x":"\u00e9\n\t"}]]]` - `nonfinite`: `{"big":1e999}` - `malformed`: `{"broken":` - `scalar`: `"just a string"` ## 4. The two breakage patches ### escape-quote.patch (caught only by rt_good) ````diff Breaks the round-trip check of rt_good.c (a string holding a double quote prints as a backslash). Caught by the seed input "quote" of each round-trip target whose check survives the build. diff --git a/cJSON.c b/cJSON.c --- a/cJSON.c +++ b/cJSON.c @@ -1036,7 +1036,7 @@ static cJSON_bool print_string_ptr(const unsigned char * const input, printbuffe *output_pointer = '\\'; break; case '\"': - *output_pointer = '\"'; + *output_pointer = '\\'; break; case '\b': *output_pointer = 'b'; ```` ### compare-true.patch (caught by none of the four) ````diff Breaks cJSON_Compare, the function the round-trip check trusts: every pair of items compares equal. A check that takes its expected value from the library cannot see this. diff --git a/cJSON.c b/cJSON.c index 6e4fb0d..f008069 100644 --- a/cJSON.c +++ b/cJSON.c @@ -3056,9 +3056,9 @@ CJSON_PUBLIC(cJSON_bool) cJSON_IsRaw(const cJSON * const item) CJSON_PUBLIC(cJSON_bool) cJSON_Compare(const cJSON * const a, const cJSON * const b, const cJSON_bool case_sensitive) { - if ((a == NULL) || (b == NULL) || ((a->type & 0xFF) != (b->type & 0xFF))) + if (1) { - return false; + return true; } /* check if type is valid */ ```` ## 5. What we measured (November 19, 2026) | Run | Targets | Breakages | Report | Exit | |---|---|---|---|---| | cJSON's own enrolled target | cjson_read_fuzzer | none | 0 property checks | 0 | | Traps, no breakage | rt_assert, rt_minus1, rt_unused | none | 0 property checks, nothing flagged | 0 | | Traps with breakage | rt_assert, rt_minus1, rt_unused | escape-quote | escape-quote not caught | 0 | | All four | all four | escape-quote | escape-quote caught by rt_good; 1 property check in total | 0 | | Good target, both breakages | rt_good | escape-quote, compare-true | compare-true not caught | 0 | Licences: the demo files above are by J.A. Watte under Apache-2.0. cJSON is MIT-licensed (https://github.com/DaveGamble/cJSON). The patches are deliberate breakages for testing and fix nothing.