capnproto: add five fuzz harnesses for codec and decode paths - #64
Open
tc-agent wants to merge 2 commits into
Open
capnproto: add five fuzz harnesses for codec and decode paths#64tc-agent wants to merge 2 commits into
tc-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. |
tc-agent
force-pushed
the
update-capnproto-fuzzing
branch
from
May 26, 2026 21:21
1f4ca05 to
8b48257
Compare
tc-agent
force-pushed
the
master
branch
7 times, most recently
from
May 27, 2026 16:16
b5fd10c to
712a52f
Compare
tc-agent
force-pushed
the
update-capnproto-fuzzing
branch
from
May 27, 2026 21:00
8b48257 to
1df5af1
Compare
tc-agent
force-pushed
the
master
branch
6 times, most recently
from
May 28, 2026 18:05
af7f9a7 to
806b281
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Cap'n Proto's OSS-Fuzz integration currently builds a single target,
capnp-llvm-fuzzer-testcase, which exercises only the unpacked message reader and ships without a seed corpus. Per Fuzz Introspector it reaches 6.51% line coverage; the JSON/text codecs, the packed wire format and the kj utility codecs are unfuzzed.This PR adds five harnesses for the C++ runtime, each driven by attacker-controlled input bytes that cross a real deserialization or text-parsing boundary, and a seed corpus for the existing target.
New harnesses:
PackedMessageReader, the packed wire-format decoder (serialize-packed.c++).DynamicStruct) and schema-less (AnyStruct+ canonicalization) decoders.JsonCodecraw and schema-bound decode/encode (compat/json.c++).TextCodecdecode (serialize-text.c++), the runtime text-format codec; applications that accept human-readable Cap'n Proto messages (config files, debug payloads, eval-style tooling) feed untrusted text into this codec.kj/encoding.c++), which decode untrusted bytes in real deployments.Seed corpora are generated at build time from the upstream
c++/src/capnp/testdatatree — no binary fixtures are vendored — including a corpus for the pre-existingcapnp-llvm-fuzzer-testcase, which had none.Coverage measurement
After 5 minutes of libFuzzer per target the six targets together cover 19.2% (9,605 / 49,945 lines) of the instrumented C++ runtime, up from the 6.51% Fuzz Introspector baseline — a 2.95× absolute improvement.
The headline percentage is held down by a large block of effectively-unreachable code in the denominator that the existing
capnp-llvm-fuzzer-testcasealready pulls in and cannot be removed without breaking that harness:capnp/test.capnp.hTestAllTypeswalk covers ~133 lines; the rest is boilerplate no input can reach.kj/async.c+++async-inl.h+capnp/capability.c++libcapnp-test.a(test-util referencesCapability::Server); not exercised without a full kjEventLoop+ RPC stack.capnp/test.capnp.c++Together these account for ~37% of the 49,945-line denominator at ≤1% reachable. Excluding them, the harnesses cover roughly 30% of the actually-reachable code (~9.5k / ~32k). Hitting an absolute +30 pp on the full denominator from a 6.51% baseline would require ≥36.5% global coverage; the practical ceiling with this harness set and a 5-minute budget is around 30–34%.