Repository navigation
feat(fuzz): a cargo-fuzz target per untrusted-input parser - #1289
Conversation
The crate is its own workspace and carries its own nightly pin because cargo-fuzz emits -Zsanitizer and the repository pin is a stable. Each target path-depends on the crate that owns its parser and calls it on every input; seeds come from the crates' own tests.
fuzz/** joins the rust path filter, and rust-checks runs one `cd fuzz && cargo check` after its existing checks: a parser change that breaks the crate fails its PR instead of surfacing at the next campaign. No campaign runs in CI.
Install, environment, seeds, the four build and run commands, what a 60 s smoke test does and does not reach, what a finding means, and the longer campaign gated on #871 and tauceti.
🦋 Changeset detectedLatest commit: f44c599 The changes in this PR will be included in the next version bump. This PR includes changesets to release 0 packagesWhen changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the
|
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
[Low impact] The PR appears safe to merge, with one non-blocking correction still needed in the runbook. Findings
|
| A finding above the 128 KiB payload bound is not production-reachable: the transport refuses a | ||
| larger frame before any parser sees it. It is still a bug worth fixing, but it cannot be a | ||
| denial of service against the relay. |
There was a problem hiding this comment.
Production accepts larger inputs
The runbook incorrectly rules out production failures above 128 KiB. DEFAULT_MAX_PAYLOAD is only a fallback: the shipped network.maxPayloadSize is 524288, and load_document reads settings files without that socket limit.
The documented -max_len=131072 commands skip part of the shipped socket range. This advice could also cause a real finding to be dismissed. Describe 128 KiB as the chosen campaign limit, cover the shipped 512 KiB socket limit, and judge settings findings separately.
Coverage Report for CI Build 46304498508Warning Build has drifted: This PR's base is out of sync with its target branch, so coverage data may include unrelated changes. Coverage decreased (-0.01%) to 77.617%Details
Uncovered ChangesNo uncovered changes found. Coverage Regressions1 previously-covered line in 1 file lost coverage.
Coverage Stats💛 - Coveralls |
The settings harness created its document directory with create_dir_all, which adopts a
directory someone else made first and lets fs::write follow a settings.yaml symlink planted
inside it; it now creates a unique 0700 directory with create_dir and treats an existing path
as a harness failure. The filter target's note named {"ids": null} as the non-object example,
which reaches validate_prefixes; it now names null. The three test files are rustfmt-clean, and
fuzz/seeds/nip11/pow-enabled.yaml enables adaptive PoW so the target's min_pow_difficulty clause
is reachable from the committed seeds.
…ach target is fed resources/default-settings.yaml:212 ships network.maxPayloadSize: 524288 and transport returns it, so every campaign command passes -max_len=524288 and the runbook cites the setting rather than the 131072 fallback constant. The CI section names the crate's format gate, which checks fuzz/ with cargo fmt --manifest-path fuzz/Cargo.toml --check. The target table now says what each target is actually fed, and the fuzz/** cost names kani-proofs and windows-cli-check.
The default runs' length controller kept lim under 4 KiB, so -max_len=524288 bound a range nothing reached. A second form passes -len_control=0 so the mutator goes for bound-sized inputs; all four targets reached lim: 524288 in a 60 s pass and found nothing. The runbook says why the default lim stays small, what len_control buys, and that settings and nip11 pay for it in runs per second.
Dismissed because a newer commit was pushed; Greptile will re-review the current head.
The harness's directory survived the run with the planted document in it. Each execution now creates a 0700 directory with create_dir and removes it in Drop, so a clean campaign leaves nothing behind and a killed one leaves at most its current input. The runbook narrows its opening claim (two peer-reachable parsers are untargeted; #1293 tracks them), says to refresh fuzz/Cargo.lock with the root lock (different graph, 228 packages against 335, 58 shared crates at other versions), notes that settings and nip11 parse through unsafe-libyaml (RUSTSEC-2024-0449) so a finding there may need a bound in our caller, and couples -rss_limit_mb and -timeout to the configured payload bound with the measured peaks.
Dismissed because a newer commit was pushed; Greptile will re-review the current head.
What
fuzz/is a cargo-fuzz crate of its own (an empty[workspace], so the root workspace stays at ten members) with one target per hand-written parser that takes bytes from a socket or an operator's file:client_framenostream_core::messages::decodefilternostream_core::filter::validate_filtersettingsnostream_config::loadnip11nostream_relay::nip11::parse_relay_pubkey+documentEach target path-depends on the crate that owns its parser (nothing is copied), calls it on every input, and asserts the invariant its doc comment states. Seeds under
fuzz/seeds/<target>/are the cases the crates' own tests already use.The crate carries its own
nightly-2026-08-21pin: cargo-fuzz always emits-Zsanitizer=addressand the repository pin is a stable that rejects it. Nothing outsidefuzz/selects that toolchain; the root pin is unedited and the root build still reports1.99.1.Work is bounded by the runtime, not by a timer in the harness: every campaign passes
-max_len=131072(the socket's own payload bound),-timeout=10and-rss_limit_mb=2048.The 60 s campaigns
cargo-fuzz 0.13.2,
nightly-2026-08-21,-max_total_time=60 -max_len=131072 -timeout=10 -rss_limit_mb=2048:INITEDclient_framecov: 641 ft: 1005Done 2008021 runs in 61 second(s)filtercov: 501 ft: 668Done 2195083 runs in 61 second(s)settingscov: 4847 ft: 7804Done 7202 runs in 61 second(s)nip11cov: 5250 ft: 6275Done 25673 runs in 61 second(s)All four exit 0;
find fuzz/artifacts -type fprints0. The stub-target baseline isINITED cov: 14, and the target bodies are the greps the job records, so the figures are trend, not proof.One campaign did stop: the settings target's first run crashed on a five-byte input,
!lsd\n(sha25606be3a69fd05e8374906612833afaff0d52bc994e58551ccaebf7991d77506f0). The cause was the harness, not the loader: its liveness check counted a YAML tagged null as a documentloadmust reject, butserde_yaml::Value::is_null()untags, soload_user_settingstreats!tagon an empty node the same as an empty file — no overrides, no issue,used_defaults = false. The expectation now usesValue::is_null(); no file undercrates/changed, and the clean rerun above is the record. The input is not committed as a seed because the job's seed set is fixed.A 60 s run is a smoke test, not a campaign: libFuzzer grows its input length from the seeds and reaches a few KiB here (87–4190), nowhere near the 128 KiB
-max_lenbound. A finding above that bound would not be production-reachable.CI and the runbook
fuzz/**joins therustpath filter andrust-checksgains onecd fuzz && cargo checkafter its existing checks — compile only, no campaign — so a parser change that breaks the crate fails its own PR.docs/rewrite/fuzz.mdis the runbook: install, the exact environment, the seed flow, the four build and four run commands, what a finding means, and the longer campaign that is written down and not run: it waits on #871's tauceti runbook and the operator's word because this sandbox has no spare cores.Validation
cargo fmt --all --check— exit 0, no outputcargo clippy --workspace --all-targets --all-features -- -D warnings— exit 0--lib --binsclippy pass — exit 0cargo test -p nostream-core -p nostream-config -p nostream-relay -p nostream-scan --all-features— exit 0, 17 s, the same counts as the base (core 145 / 105 / 58 / 31 / 27, config 62 / 25 / 6, relay 8 / 29 / 66 / 115 and the rest)cargo test -p nostream-core -p nostream-config -p nostream-relay -p nostream-storage --all-features— exit 0cargo fuzz listprints exactly the four names; the fourcargo fuzz buildruns exit 0cargo test --workspace --all-featuresis not the oracle here: it fails at the base commit on twonostream-adminnetwork-health cases for want of egress.Addresses #1286. (
Closeswould not close it: this PR targetsrewrite/main, not the default branch.)