Rust Security
Rule
Use safe Rust by default and treat external input, secrets, unsafe code, FFI, filesystem
paths, subprocesses, network calls, auth, and dependencies as explicit security boundaries.
Hard Stops
Stop before:
- Introducing or modifying
unsafe, FFI, custom allocators, or raw pointer code.
- Touching real secrets, production systems, customer data, incident evidence, or destructive
operations.
- Weakening TLS, authentication, authorization, tenant isolation, audit logging, or data
retention.
- Executing user-controlled commands, accepting unbounded deserialization, or writing outside
intended directories.
- Suppressing
cargo deny, cargo audit, scanner, or review findings without risk approval.
Defaults
- Validate inputs at boundaries with explicit parsing or approved validation crates.
- Use
secrecy/zeroize for long-lived secrets that may otherwise be logged or retained.
- Avoid logging secrets and sensitive fields; redact at the type or formatter boundary.
- Enforce path containment after canonicalization where paths touch untrusted input.
- Use fixed executables and explicit args for subprocesses; avoid shell invocation.
- Prefer Rustls TLS stacks unless platform policy requires native TLS.
- Run
cargo deny check and/or cargo audit when configured.
- For unsafe code, require local safety comments, narrow unsafe blocks, tests, and Miri or
sanitizer evidence when practical.
Workflow
- Identify assets, actors, trust boundaries, and threat model.
- Inspect unsafe/FFI, parsing, auth, paths, subprocesses, logs, network, database, and
dependencies.
- Reproduce risk with safe local tests where practical.
- Implement minimal hardening and malicious-input regression tests.
- Run tests, deny/audit/scanners when configured, Clippy, and
just check.
- Separate code fixes from operational actions such as secret rotation.
Antipatterns
unwrap on untrusted input or protocol parsing.
- Raw string SQL/commands built from user input.
Debug output for config structs containing secrets.
- Unsafe blocks without documented invariants.
- Dependency feature defaults that pull in unwanted TLS/crypto/native code.
Completion
Report risks, mitigations, tests/scans, unsafe status, secrets avoided, and residual risk.
Source: nyquistwilder/personal-pi — distributed by TomeVault.
1---2name: rust-security3description: Secure Rust development and review workflow for secrets, unsafe code, FFI, path handling, command execution, deserialization, auth boundaries, TLS, dependency advisories, and supply-chain risk. Use when this capability is needed.4---56# Rust Security78## Rule910Use safe Rust by default and treat external input, secrets, unsafe code, FFI, filesystem11paths, subprocesses, network calls, auth, and dependencies as explicit security boundaries.1213## Hard Stops1415Stop before:1617- Introducing or modifying `unsafe`, FFI, custom allocators, or raw pointer code.18- Touching real secrets, production systems, customer data, incident evidence, or destructive19 operations.20- Weakening TLS, authentication, authorization, tenant isolation, audit logging, or data21 retention.22- Executing user-controlled commands, accepting unbounded deserialization, or writing outside23 intended directories.24- Suppressing `cargo deny`, `cargo audit`, scanner, or review findings without risk approval.2526## Defaults2728- Validate inputs at boundaries with explicit parsing or approved validation crates.29- Use `secrecy`/`zeroize` for long-lived secrets that may otherwise be logged or retained.30- Avoid logging secrets and sensitive fields; redact at the type or formatter boundary.31- Enforce path containment after canonicalization where paths touch untrusted input.32- Use fixed executables and explicit args for subprocesses; avoid shell invocation.33- Prefer Rustls TLS stacks unless platform policy requires native TLS.34- Run `cargo deny check` and/or `cargo audit` when configured.35- For unsafe code, require local safety comments, narrow unsafe blocks, tests, and Miri or36 sanitizer evidence when practical.3738## Workflow39401. Identify assets, actors, trust boundaries, and threat model.412. Inspect unsafe/FFI, parsing, auth, paths, subprocesses, logs, network, database, and42 dependencies.433. Reproduce risk with safe local tests where practical.444. Implement minimal hardening and malicious-input regression tests.455. Run tests, deny/audit/scanners when configured, Clippy, and `just check`.466. Separate code fixes from operational actions such as secret rotation.4748## Antipatterns4950- `unwrap` on untrusted input or protocol parsing.51- Raw string SQL/commands built from user input.52- `Debug` output for config structs containing secrets.53- Unsafe blocks without documented invariants.54- Dependency feature defaults that pull in unwanted TLS/crypto/native code.5556## Completion5758Report risks, mitigations, tests/scans, unsafe status, secrets avoided, and residual risk.5960---61> Source: [nyquistwilder/personal-pi](https://github.com/nyquistwilder/personal-pi) — distributed by [TomeVault](https://tomevault.io).62<!-- tomevault:4.0:skill_md:2026-06-16 -->