ci: nightly fuzz job for fuzz/ (PR #103 harness) - fix build+run container #106

Merged
sirius merged 5 commits from wt/t_16e835ef into main 2026-09-18 11:09:13 +00:00
Owner

Rework the fuzz CI job so it passes.

Problem: The fuzz job's two CI steps ran in separate Docker containers. Step 1 installed cargo-fuzz into /usr/local/cargo/bin (ephemeral - only /usr/local/cargo/registry is volume-mounted) and built+listed the targets. Step 2 was a fresh container where cargo-fuzz was not installed, so bash run-fuzz.sh failed with error: no such command: 'fuzz'.

Fix: Merge the nightly toolchain + cargo-fuzz install + cargo fuzz build + cargo fuzz list + bash run-fuzz.sh into a single container step so the installed binary and the built targets persist across the run. Also keep the /target/tmp mkdir from 1b2c63b (rustup needs it for its temp dir when TMPDIR=/target/tmp).

This PR also contains a throwaway crash-test commit (b76bf46, panic!() injected into qr_decode) to prove acceptance criterion #2 - the job must go red when a target crashes. Revert that commit before merging.

CI result to verify: the fuzz job runs all 4 targets for 15s each with crashes=0/0/0, and cargo +nightly fuzz list lists all 4 targets.

Rework the fuzz CI job so it passes. **Problem:** The fuzz job's two CI steps ran in separate Docker containers. Step 1 installed `cargo-fuzz` into `/usr/local/cargo/bin` (ephemeral - only `/usr/local/cargo/registry` is volume-mounted) and built+listed the targets. Step 2 was a fresh container where `cargo-fuzz` was not installed, so `bash run-fuzz.sh` failed with `error: no such command: 'fuzz'`. **Fix:** Merge the nightly toolchain + cargo-fuzz install + `cargo fuzz build` + `cargo fuzz list` + `bash run-fuzz.sh` into a single container step so the installed binary and the built targets persist across the run. Also keep the `/target/tmp` mkdir from 1b2c63b (rustup needs it for its temp dir when TMPDIR=/target/tmp). This PR also contains a throwaway crash-test commit (b76bf46, `panic!()` injected into qr_decode) to prove acceptance criterion #2 - the job must go red when a target crashes. Revert that commit before merging. **CI result to verify:** the fuzz job runs all 4 targets for 15s each with crashes=0/0/0, and `cargo +nightly fuzz list` lists all 4 targets.
Four pure parsers eat untrusted peer input and had no structured fuzzing:

- ratchet_frame  -> RatchetState::from_bytes + RatchetState::decrypt
                    (the 'rat ' frame parser: prefix, version, length,
                    N/PN bounds, DH step, AEAD open)
- qr_decode      -> qr::decode on pasted/scanned invite strings
- dispatch_classify -> dispatch::classify on raw decrypted plaintext,
                    including the 'rat ' -> Kind::Ratchet routing arm
- file_decode    -> file::decode on 'fil ' chunk frames

No src/ change: every target calls the shipped public API. The fuzz crate is
its own workspace (empty [workspace] table), so no root Cargo.toml dependency
is added and cargo build/test at the root never compiles it.

Seeds in fuzz/seeds/ are committed and copied into the gitignored working
corpus by scripts/run-fuzz.sh; each target asserts properties a panic-free
decode must hold (a rejected ratchet frame leaves the state byte-identical,
a decoded invite is 32/32/onion-shaped, a decoded chunk re-encodes).

Verified: cargo +nightly fuzz list -> 4 targets; scripts/run-fuzz.sh with
FUZZ_SECS=60 FUZZ_JOBS=4 -> exit 0, oom/timeout/crash: 0/0/0 for all four,
fuzz/artifacts/* empty.
fix(ci): merge fuzz build+run into one container so cargo-fuzz persists
Some checks failed
ci / test (pull_request) Successful in 4m54s
ci / sdk (pull_request) Successful in 1m5s
ci / fuzz (pull_request) Failing after 5m56s
8949da1213
The fuzz job's two CI steps ran in separate Docker containers, so the
cargo-fuzz binary installed in step 1 was gone by step 2: `bash
/scripts/run-fuzz.sh` failed with "error: no such command: `fuzz`".

Merge the nightly toolchain + cargo-fuzz install + `cargo fuzz build` +
`cargo fuzz list` + `bash run-fuzz.sh` into a single container step so
the installed binary and the built targets survive across the run.

Also keep the /target/tmp mkdir from 1b2c63b (rustup needs it for its
temp dir when TMPDIR=/target/tmp).

Co-authored-by: agent <agent@local>
Revert "ci: crash-test — inject panic in qr_decode to prove the fuzz job fails on a crash (REVERT BEFORE MERGE)"
All checks were successful
ci / test (pull_request) Successful in 4m51s
ci / sdk (pull_request) Successful in 58s
ci / fuzz (pull_request) Successful in 4m34s
518ef30232
This reverts commit b76bf46100.
sirius merged commit 462b5765bd into main 2026-09-18 11:09:13 +00:00
sirius deleted branch wt/t_16e835ef 2026-09-18 11:09:17 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
sirius/onionwire!106
No description provided.