Skip to content

fix(security): harden SessionId path handling, secret-mask nonce, stale comment#6372

Merged
bug-ops merged 1 commit into
mainfrom
fix/6349-session-hardening
Jul 17, 2026
Merged

fix(security): harden SessionId path handling, secret-mask nonce, stale comment#6372
bug-ops merged 1 commit into
mainfrom
fix/6349-session-hardening

Conversation

@bug-ops

@bug-ops bug-ops commented Jul 17, 2026

Copy link
Copy Markdown
Owner

Summary

Bundles two small, non-blocked, defense-in-depth hardening fixes into a single PR:

  • P3 hardening: SessionId lacks path-traversal validation; stale unsafe-code-confinement claim; explicit CSPRNG for secret-mask nonce #6349 — three low-severity hardening gaps, none exploitable today:
    • SessionId::try_new validating constructor rejects /, \, .., and NUL bytes.
      Applied at the 5 HTTP handlers in src/serve/handlers.rs that take a caller-supplied
      session id (get/delete/prompt/events/fork_session_handler), each now
      returning 400 on rejection. SessionId::new is unchanged and remains the
      constructor for trusted call sites (internal generation, test fixtures, already
      DB/registry-validated round-trips) to avoid ~90-call-site churn for a
      not-exploitable-today issue.
    • SecretMaskRegistry::new's per-registry nonce now uses rand::rngs::SysRng
      (explicit OS-backed CSPRNG) instead of rand::random()'s default thread-local
      generator.
    • Corrected a stale src/main.rs comment claiming all unsafe code is confined to
      that module.
  • evaluate enabling clippy::await_holding_lock workspace-wide #6355 — enabled clippy::await_holding_lock workspace-wide in
    [workspace.lints.clippy], after verifying zero hits across every CI feature
    combination.

Notes

Closes #6349
Closes #6355

Test plan

  • cargo +nightly fmt --check
  • cargo clippy --profile ci --workspace --all-targets --features "desktop,ide,server,chat,pdf,scheduler,testing" -- -D warnings
  • cargo nextest run --config-file .github/nextest.toml --workspace --features "desktop,ide,server,chat,pdf,scheduler" --lib --bins (13985 passed, 0 failed)
  • Rustdoc gate (RUSTFLAGS="-D warnings" RUSTDOCFLAGS="--deny rustdoc::broken_intra_doc_links" cargo doc --no-deps --workspace)
  • cargo test --doc -p zeph-common -p zeph-sanitizer
  • gitleaks protect --staged — clean
  • New unit tests: 7 SessionId::try_new tests + 4 handler *_rejects_path_traversal_id tests
  • .local/testing/playbooks/security-hardening.md and coverage-status.md updated

@github-actions github-actions Bot added bug Something isn't working size/L Large PR (201-500 lines) documentation Improvements or additions to documentation rust Rust code changes dependencies Dependency updates and removed size/L Large PR (201-500 lines) labels Jul 17, 2026
@bug-ops
bug-ops enabled auto-merge (squash) July 17, 2026 04:19
…le comment

Add SessionId::try_new to reject path-traversal characters at the
five HTTP session handlers that take a caller-supplied id, switch
SecretMaskRegistry's nonce to an explicit OS-backed CSPRNG, and
correct a stale unsafe-code-confinement comment in main.rs. None of
these are exploitable today; all are defense-in-depth hardening.

Also enable clippy::await_holding_lock workspace-wide after
verifying zero hits across every CI feature combination, so the
existing manual blocking-pattern scan gets compile-time backup.

Closes #6349
Closes #6355
@bug-ops
bug-ops force-pushed the fix/6349-session-hardening branch from 4caa016 to 16faaf3 Compare July 17, 2026 04:24
@github-actions github-actions Bot added the size/L Large PR (201-500 lines) label Jul 17, 2026
@bug-ops
bug-ops merged commit cf3197e into main Jul 17, 2026
43 checks passed
@bug-ops
bug-ops deleted the fix/6349-session-hardening branch July 17, 2026 04:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working dependencies Dependency updates documentation Improvements or additions to documentation rust Rust code changes size/L Large PR (201-500 lines)

Projects

None yet

1 participant