Skip to content
rusthacks.dev
Security

Rust Security Checklist to Run Before Shipping a Service

A review checklist for a Rust service before it faces the internet: dependencies, unsafe, input limits, authentication, secrets, transport, containers and monitoring, each with a pass condition.

3 min read
Summarize in AI
Flat illustration for the post “Rust Security Checklist to Run Before Shipping a Service”, composed around security.

A checklist is useful when it is specific enough to fail. "Use strong crypto" cannot fail; "passwords hashed with Argon2id at 19 MiB or more" can. This one lists the controls for a Rust service that faces the internet, each with the condition that shows it is in place and a link to the post that explains it. It is the checklist form of security for Rust developers.

Rust 1.90.

Dependencies and build

  • [ ] Cargo.lock is committed, and CI builds with --locked. *Pass: build fails when the lock is stale.*
  • [ ] cargo audit or cargo deny check advisories runs on every pull request and daily. *Pass: CI job exists and is required.* See dependency risk.
  • [ ] deny.toml restricts licenses, sources and banned crates. *Pass: cargo deny check exits 0.* See cargo deny.
  • [ ] Toolchain is pinned in rust-toolchain.toml.
  • [ ] Release profile has overflow-checks = true, or all input arithmetic is checked. See integer overflow bugs.

Code

  • [ ] Every unsafe block has a // SAFETY: comment and the module is tested under Miri. *Pass: clippy::undocumented_unsafe_blocks is denied.* See safety comments.
  • [ ] unwrap, expect and indexing on input-derived values are reviewed. *Pass: clippy::unwrap_used warns in non-test code.*
  • [ ] SQL uses bind parameters only. *Pass: no format! building queries.* See SQL injection.
  • [ ] File paths from users go through a safe join. See path traversal.

Input

  • [ ] Body size, nesting depth, decompressed size, concurrency and time are all bounded. *Pass: each has a number in the code or config.* See parsers and limits.
  • [ ] Parsers of untrusted formats are fuzzed.

Authentication and secrets

Transport and headers

  • [ ] TLS terminates with a current configuration; HSTS is set. See security headers.
  • [ ] CORS lists exact origins. See CORS.
  • [ ] Cookies have Secure, HttpOnly and SameSite.

Runtime

  • [ ] The container runs as non-root with a read-only root file system. See non-root containers.
  • [ ] The image contains only the binary and what it needs. See a small Docker image.
  • [ ] Health endpoints do not leak internals, and shutdown is graceful.
  • [ ] Logs include request ids and exclude credentials, tokens and personal data. See structured logging.
  • [ ] Alerts exist for error rate, latency and authentication failures.

Process

  • [ ] There is a way to rotate every secret without a rebuild, and it has been tried.
  • [ ] Someone owns responding to advisories, with a target time.
  • [ ] A security contact and disclosure policy are published (security.txt).

Limits

A checklist verifies known controls. It misses design flaws, business logic abuse and anything specific to your product. Pair it with a threat model and, for sensitive systems, an external review. The French national cybersecurity agency ANSSI publishes a longer guide to secure Rust development.

Also inWeb
Taggedchecklist
Share

Keep reading

Get new posts by email

We send one email when a new post is published. No spam.

Unsubscribe in one click. No spam, ever.