test(fuzz): fuzz the broker's command line and the gate's path resolution

Merged
KI
25d ago
+1218-213

Problem

The only fuzz target, broker_requests, reaches the gate through the broker with one READ | LIST grant, and fails only if a delivered descriptor reads the secret. Nothing fuzzes path resolution directly, with nested grants, create, and checks on what a success reached. Nothing fuzzes fsgate-broker's --grant and --direct parsers. fuzz.yml runs only when broker.rs changes. This is the fourth item of M10 in the roadmap.

Change

  • gate_paths runs open, create, metadata, and read_dir on arbitrary paths through one Gate.
    • Tree. Three grants: granted (READ | LIST), with granted/nested (READ) and granted/w (every right) inside it. They sit in a fixed tree with FIFOs, a sibling whose name starts with the grant's, and symlinks that stay inside, climb out, are absolute, dangle, or loop. No symlink leads out of the tree.
    • Checks. A success must reach an object, by device and inode, beneath the grant the path routes to, and a listing must be one of a directory there. A refusal must be the one the routing calls for. open never returns a directory. The tree must not change, except that a create may make or truncate the file it returns; the target then puts the tree back.
    • Input. One operation a line. A lowercase letter takes a path relative to the tree; an uppercase one takes the raw path, so it can be relative or name anything.
  • broker_args compares the parser with a restatement of its rules: each --grant and --direct spec, alone and in a command line, and the mode the options select. Arguments are split at NUL bytes. A one-byte argument such as U stands for an option such as --unconfined, so that one changed byte swaps one option for another.
  • The parser moves, unchanged, from fsgate-broker.rs into fsgate-broker/args.rs, which the target includes with #[path]. The only textual difference is rustfmt wrapping one signature that pub(super) made longer. confine.rs keeps calling super::parse_direct.
  • Seeds and dictionaries for both targets, in fuzz/seeds/ and fuzz/dicts/.
  • .cargo/mutants.toml (from #80) examines fsgate-broker/args.rs too, so the parser's mutants keep counting in their new file.
  • fuzz.yml runs every target on Linux, and gate_paths on macOS too. Each runs for 15 minutes when anything in crates/fsgate/src/ or fuzz/ changes, for an hour every Monday, and on demand. A finding uploads the input. The old broker-requests job is now broker_requests (ubuntu-latest); no check is required on main.

Safety and compatibility

The broker's behavior does not change: the parser's code moved without edits, and nothing else in the crate changed. The packaged crate includes src/bin/fsgate-broker/args.rs (cargo package --list).

Mutation testing (#80). .cargo/mutants.toml there lists the broker's files by name. Whichever of #80 and this PR merges second must add crates/fsgate/src/bin/fsgate-broker/args.rs to it, or the parser's mutants drop out of the run.

Verification

Controls. Each defect was put in on purpose and fuzzed on macOS from one or two seeds, with libFuzzer seed 1:

DefectTargetFound after
open follows the path from the root, not beneath the grantgate_paths100,511 inputs, about a minute
Routing picks the shortest covering grantgate_paths51,386 inputs, under 40 s
create follows the path from the rootgate_paths15,937 inputs, under 40 s
--direct accepts wbroker_args6,155 inputs, under 3 s
Interception mode accepts --unconfinedbroker_args303,507 inputs, under 12 s

The last one first went unfound for five minutes, twice: once with a dictionary of the option names and once with each name ending in a NUL. That led to the one-byte stand-ins. Before the controls, a traced run of the seeds showed each operation getting the answer its seed was written for.

Recorded runs on macOS 26.2 (Apple M1). No crash, hang, or check failure. Toolchain: rustc 1.102.0-nightly (f5cedb83a 2026-11-07), cargo-fuzz 0.13.2, libfuzzer-sys 0.4.13, with AddressSanitizer.

TargetSecondsInputsPer secondCorpusCoverage counters
gate_paths901371,8584129 seeds to 564 inputs1,037 to 1,095
broker_args9015,846,2336,48819 seeds to 733 inputs442 to 614

Recorded runs in CI, the fuzz jobs on 144078d, with the same toolchain. No crash, hang, or check failure.

TargetRunnerSecondsInputsPer secondCorpusCoverage counters
gate_pathsLinux 7.0.0-1019-azure x86_64901411,5764569 seeds to 405 inputs840 to 873
broker_argsLinux 7.0.0-1019-azure x86_649013,155,6533,50219 seeds to 759 inputs444 to 622
broker_requestsLinux 7.0.0-1019-azure x86_6490126,466,76629,37414 seeds to 1,376 inputs1,013 to 2,111
gate_pathsDarwin 25.6.0 arm64901385,5804279 seeds to 566 inputs1,037 to 1,098

All 12 checks passed on 144078d.

After merging main (#77 and #80), all 17 checks passed on 10ba3e2, including the three Linux fuzz jobs, gate_paths on macOS, and both mutants jobs. With args.rs examined, the totals and the misses are unchanged: Linux tested 420 mutants and missed the 29 listed, and macOS tested 278 and missed the 6 listed. Before this change, the parser's 28 mutants were counted under fsgate-broker.rs.

check failed once on 10ba3e2 in a_program_a_confined_worker_leaves_running_ends_with_it, with "the program never ran", and passed on a rerun of that job. That test is from #75 and is not touched here: it checks that a program is still running after its worker has exited, which races the broker's kill of the worker's group. The same failure showed up once in #80's mutation run.

Locally:

  • cargo fmt --all --check and cargo fmt --manifest-path fuzz/Cargo.toml --check: clean.
  • cargo clippy --all-targets -- -D warnings: clean.
  • cargo clippy --target x86_64-unknown-linux-gnu -p fsgate --all-targets -- -D warnings, with and without --features experimental-intercept: clean. These are type-checks, not runs.
  • cargo clippy --manifest-path fuzz/Cargo.toml -- -D warnings (stable, macOS): clean.
  • cargo test --locked: 106 passed, and 121 after merging main.
  • actionlint 1.7.12 (with shellcheck) and zizmor 1.32.0 on fuzz.yml: no findings.

Not verified:

  • The weekly schedule. It only runs from main, so it has not run yet.
  • The fuzz crate on Linux. Its clippy on Linux runs only in CI's check job.
  • What the tree leaves out. It has no hard links or mounts, and nothing renames while a path resolves; the threat model lists those as gaps.
  • The rules themselves. The parser's restatement follows the same rules, so it cannot find a flaw in them.

Documentation and release

  • fuzz/README.md describes both targets and their commands.
  • The threat model's gate section gets a row for arbitrary paths.
  • docs/security-review.md lists args.rs and the new targets.
  • ROADMAP.md ticks the item with the controls and every run above (2982f44).

Test and CI only, so no changelog entry and no release.