fuzz: cargo-fuzz harness for the ratchet/qr/dispatch/file parsers
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.
This commit is contained in:
parent
407b11f2f8
commit
f06073e7dc
30 changed files with 6645 additions and 0 deletions
26
fuzz/README.md
Normal file
26
fuzz/README.md
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
# Fuzzing OnionWire
|
||||
|
||||
Structured fuzzing for the four parsers that eat untrusted peer input. A crash
|
||||
here is a remote-triggerable panic, so a reproducer must be fixed in `src/` and
|
||||
then folded into `fuzz/seeds/<target>/` as a regression input.
|
||||
|
||||
| target | entry points |
|
||||
|---|---|
|
||||
| `ratchet_frame` | `ratchet::RatchetState::from_bytes`, `RatchetState::decrypt` (the `rat ` frame parser) |
|
||||
| `qr_decode` | `qr::decode` (pasted/scanned invite strings) |
|
||||
| `dispatch_classify` | `dispatch::classify` (routes a `rat ` frame to the ratchet parser) |
|
||||
| `file_decode` | `file::decode` (`fil ` chunk frames) |
|
||||
|
||||
Nothing in `src/` changes for this: every target calls the shipped public API.
|
||||
|
||||
```sh
|
||||
rustup toolchain install nightly --profile minimal
|
||||
cargo install cargo-fuzz
|
||||
scripts/run-fuzz.sh # all four, 60s each
|
||||
FUZZ_SECS=300 scripts/run-fuzz.sh ratchet_frame
|
||||
```
|
||||
|
||||
`fuzz/corpus/` is gitignored (libFuzzer grows it locally); `fuzz/seeds/` is
|
||||
committed and copied in by the script. Crash reproducers land in
|
||||
`fuzz/artifacts/<target>/`. Needs rustup's `cargo` on `PATH` — the `+nightly`
|
||||
directive does not work through a distro `cargo` package.
|
||||
Loading…
Reference in a new issue