Rust Web Security Cheat Sheet

Headers, CSP, and secure cookies

Last Updated: November 21, 2025

Headers

Header Purpose
Strict-Transport-Security Force TLS
Content-Security-Policy Block scripts
X-Content-Type-Options Prevent sniffing

Commands

axum::middleware
Add headers
cookie::Cookie::build
Set httpOnly
rocket::fairing
Apply CSP

Guidance

Validate inputs, sanitize templates, and audit standards.

💡 Pro Tip: Use HTTPS, set CSP, and mark cookies httpOnly.
← Back to Security & Privacy | Browse all categories | View all cheat sheets