Skip to content

fix: address security-audit findings in verify and content#14

Merged
samjanny merged 1 commit into
mainfrom
fix/verify-audit
Jun 3, 2026
Merged

fix: address security-audit findings in verify and content#14
samjanny merged 1 commit into
mainfrom
fix/verify-audit

Conversation

@samjanny
Copy link
Copy Markdown
Owner

@samjanny samjanny commented Jun 3, 2026

Fixes the five findings from a security audit of the tool. All five were confirmed against the code before fixing.

verify exit code (critical). verify printed verdict: reject but the process exited 0, so CI and scripts could treat an invalid document as valid. Commands now return an Outcome; a verify reject maps to a non-zero exit. An integration test (tests/exit_code.rs) guards the contract.

verify default --now (medium). The default time reference was a fixed 2026-05-07 date, already stale, which silently passed an expired canary. Default to the current system UTC clock (printed as a note); --now still overrides for reproducibility.

content image read (medium). Reading image files for the hash and dimensions is hardened against a hostile repository: the resolved path must stay inside the assets directory (rejecting symlinks pointing out), the target must be a regular file, and it must not exceed the 2 MiB image cap. Legitimate images are unaffected.

verify --content-index (low). --content-index without --fetched-onion silently skipped Stage 9b; now an explicit error, and the skip note covers the no-onion case.

init scaffold (low). The generated README shows build manifest --key-seed-file instead of an inline --key-seed-hex, matching the seed-handling guidance.

New tests cover the symlink and size-cap rejections and the verify exit code (17 total). fmt, clippy -D warnings, build, and test green with --locked; cargo audit clean.

Five findings from an audit of the tool.

verify exit code (critical): verify reported 'reject' but the process
exited 0, so CI and scripts could treat an invalid document as valid.
Commands now return an Outcome; a verify reject maps to a non-zero exit.
An integration test guards the contract.

verify default --now (medium): the default verified-time reference was a
fixed 2026-05-07 date, already stale, which silently passed an expired
canary. Default to the current system UTC clock instead (printed as a
note); --now still overrides for reproducibility.

content image read (medium): reading image files for the hash and
dimensions is now hardened against a hostile repository - the resolved
path must stay inside the assets directory (rejecting symlinks that point
out), the target must be a regular file, and it must not exceed the 2 MiB
image cap. Legitimate images are unaffected.

verify --content-index (low): supplying --content-index without
--fetched-onion silently skipped Stage 9b; it is now an explicit error,
and the skip note covers the no-onion case.

init scaffold (low): the generated README now shows build manifest with
--key-seed-file instead of an inline --key-seed-hex, matching the
seed-handling guidance.

Tests cover the symlink and size-cap rejections and the verify exit code.
cargo audit clean with the added time dependency.
@samjanny samjanny merged commit 2eaac8f into main Jun 3, 2026
6 checks passed
@samjanny samjanny deleted the fix/verify-audit branch June 3, 2026 14:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant