capnproto: add packed, JSON, text and schema-parser fuzz harnesses#57
capnproto: add packed, JSON, text and schema-parser fuzz harnesses#57tc-agent wants to merge 2 commits into
Conversation
Fuzzing Coverage ReportTested: project
Per-harness
Δ = (after − before) / before, to accommodate that denominators may change. "new" when before is 0; "deleted" when after is 0. |
aa5ede1 to
1d30fed
Compare
|
CI status: every per-engine project build (
|
2c22875 to
07a0cf6
Compare
1d30fed to
59e7321
Compare
d25286d to
ed731ba
Compare
59e7321 to
5b4ec9f
Compare
c540264 to
b54c0d2
Compare
d425517 to
68ef8ef
Compare
9a36aa8 to
6a4a93d
Compare
6125235 to
e512e7e
Compare
68ef8ef to
cad93a0
Compare
b5fd10c to
712a52f
Compare
cad93a0 to
83bf809
Compare
a7587cd to
b952f62
Compare
af7f9a7 to
806b281
Compare
Motivation
capnprotocurrently ships a single fuzz harness (capnp-llvm-fuzzer-testcase) that exercises only the unpacked binary message reader. Per the Fuzz Introspector profile, reported line coverage sits at 6.51 % (2 451 / 37 649 lines). The packed-message decoder, JSON codec, text codec and schema-language compiler are unfuzzed.Changes
Four new harnesses are added alongside the existing one. All take attacker-controlled bytes as input:
capnp-packed-fuzzerdrivescapnp::PackedMessageReader(the packed-encoding decoder inserialize-packed.c++).capnp-json-fuzzerdrivescapnp::JsonCodec::decodeRaw(parser-only) andcapnp::JsonCodec::decodeagainstTestAllTypes(parser + schema-bound binding logic incompat/json.c++), then re-encodes to also exercise the encoder.capnp-text-fuzzerdrivescapnp::TextCodec::decodeagainstTestAllTypes, exercisingserialize-text.c++and the lexer it shares with the schema language.capnp-schema-parser-fuzzerdrivescapnp::SchemaParser::parseFilevia a tiny in-memorySchemaFilesubclass (no kj filesystem allocation, avoiding a known cleanup-order leak), hitting the full schema-language pipeline:compiler/lexer.c++,compiler/parser.c++,compiler/node-translator.c++,compiler/compiler.c++, andschema-parser.c++.build.shis extended to compile the new harnesses against the.la-builtlibcapnp*/libcapnpc.a/libkj*archives produced by the existingmakestep. TheDockerfileCOPYs the new sources and the (small)seeds/directory.Seed corpora
build.shbuilds each seed corpus directly from the upstream tree atc++/src/capnp/testdata/so no binary fixtures are vendored:capnp-packed-fuzzer:packed,packedflat,segmented-packed— packed-encodedTestAllTypesmessages produced upstream bycapnp encode.capnp-json-fuzzer:short.json,pretty.json,annotated.json.capnp-text-fuzzer:short.txt,pretty.txt.capnp-schema-parser-fuzzer: real upstream.capnpsource files (c++.capnp,persistent.capnp,stream.capnp,compiler/grammar.capnp,compiler/lexer.capnp) plus one tiny hand-written schema (seeds/capnp-schema-parser-fuzzer/tiny.capnp, 14 lines, the only file underseeds/in the diff) covering structs, unions, lists, enums and interfaces.Coverage
Restricted to the set of files Fuzz Introspector measures, the new combined coverage is 8 862 / 38 344 = 23.11 % (vs the 6.51 % baseline, +16.6 pp). Linking
libcapnpc.aadds the schema-compiler translation units to the instrumented denominator, so against the full new set of files coverage is 14 401 / 59 352 = 24.26 %.Per-harness, after running all five harnesses concurrently for 5 minutes wall-clock each and producing an
llvm-covreport from the resulting corpora:capnp-llvm-fuzzer-testcasecapnp-packed-fuzzer(new)capnp-json-fuzzer(new)capnp-text-fuzzer(new)capnp-schema-parser-fuzzer(new)Absolute lines covered grows from 2 451 → 14 402 — 5.9 × the Fuzz Introspector baseline.