Rust Security — mmap-guard#
Crate-specific delta only. **Authoritative source:
AGENTS.md+GOTCHAS.md
SECURITY.md.** The generic ECC Rust-security topics (SQL injection, secret
management, HTTP error responses,tracing) do not apply — this crate has no
SQL, no secrets, and no network surface.
The unsafe boundary (this crate's entire threat model)#
- There must be exactly one
unsafeblock in the whole crate — thememmap2
call insrc/map.rs. No newunsafewithout an issue discussion first. undocumented_unsafe_blocks = "deny"— everyunsafeblock needs a// SAFETY:
comment proving the invariants hold.- The crate is not
#![forbid(unsafe_code)]— it is the boundary that lets
downstream consumers forbid unsafe. See GOTCHAS.md § Unsafe Code.
mmap hardening (what the safe API guarantees)#
- Empty files are rejected by a deliberate pre-flight check (cannot be mapped).
- A shared advisory lock is taken via
fs4::FileExt::try_lock_shared()before
mapping; contention returnsWouldBlock. Match all three arms (Ok,WouldBlock,
Error(io)). - SIGBUS from concurrent truncation is a documented, out-of-scope limitation — do
not claim to fully prevent it. See GOTCHAS.md § Platform / mmap andSECURITY.md.
Dependency & supply-chain checks#
- Run
just audit(cargo audit) andjust deny(cargo deny check) locally
before pushing.just auditis part ofjust ci-check;cargo deny checkruns
in the scheduledsecurity.ymlworkflow — neither is a hard merge/release gate. - The known
getrandomduplicate is intentionally tolerated — see
GOTCHAS.md § Clippy Lints before touchingdeny.tomlor the
multiple_crate_versionslevel.