fix(audit): record the normalized path when no grant covers a request

Merged
KI
1mo ago
+62-7

Problem

RFC 0002 says an audit event's path is the normalized requested path. Two denials recorded the path as requested instead: a request that no grant covers, and a grant refused after lock(). A request for /srv/data/../../etc/shadow was recorded with that path, so a consumer filtering events by prefix saw a denied request inside /srv/data. The decision itself was always correct.

The model-based test of the gate in #60 found it, in the first case it shrank to: grant a directory, then open <grant>/...

Root cause

Gate::gated emitted the caller's path for every denial made before routing, and Gate::grant did the same when the gate was locked. Every later decision already recorded the normalized path, and audit.rs::rights_exceeded_names_the_matched_grant checks that for RightsExceeded. Nothing checked these two.

Change

Both record the normalized path. A relative path has no normalized form, so NotAbsolute still records the path as requested, as RFC 0002 implies.

Safety and compatibility

Only the path field of these two events changes, to what RFC 0002 already specifies. No decision changes. Requests a broker serves go through the same code, so their events are fixed too.

Verification

On macOS 26.2 (Darwin 25.2) with Rust 1.99.1:

  • cargo test --locked -p fsgate --test audit: 12 passed. With lib.rs from main, a_denial_with_no_grant_records_the_normalized_path and lifecycle_events_cover_grant_revoke_and_lock fail, recording granted/../outside/secret.txt and granted/sub/...
  • cargo fmt --all --check and cargo clippy --all-targets -- -D warnings: clean.
  • cargo clippy --locked --target x86_64-unknown-linux-gnu -p fsgate --all-targets -- -D warnings, also with --features experimental-intercept: clean. This is a type-check, not a run.
  • cargo test --locked: 97 passed, 0 failed.

Not verified: the Linux runs. CI on this PR is their first.

Documentation and release

A changelog entry under Unreleased. No release.