Command Reference
1. Audit Live HTTP Security Headers with curl
Fetch only the response headers of a site to inspect its security posture.
curl -sI https://example.com | grep -iE "strict-transport|content-security|x-frame|x-content-type|referrer-policy|permissions-policy"
2. Strict-Transport-Security (HSTS Preload Ready)
Force HTTPS connections for 2 years including subdomains.
Strict-Transport-Security: max-age=63072000; includeSubDomains; preload
3. Strict Content-Security-Policy (CSP Baseline)
Block inline XSS scripts, object plugins, and unauthorized framing.
Content-Security-Policy: default-src 'self'; script-src 'self'; object-src 'none'; base-uri 'self'; frame-ancestors 'none'; upgrade-insecure-requests
4. Clickjacking Defense (X-Frame-Options)
Prevent attackers from embedding your login or settings page inside an invisible iframe.
X-Frame-Options: DENY
5. MIME-Sniffing Protection
Stop browsers from executing uploaded text/image files as JavaScript or HTML.
X-Content-Type-Options: nosniff
6. Privacy-Preserving Referrer-Policy
Send only the origin domain on cross-origin requests so sensitive URL paths are not leaked.
Referrer-Policy: strict-origin-when-cross-origin
7. Permissions-Policy (Disable Unused Browser APIs)
Explicitly disable camera, microphone, geolocation, and payment APIs unless needed.
Permissions-Policy: camera=(), microphone=(), geolocation=(), payment=()
8. Secure Session Cookie Flags
Prevent JavaScript XSS theft (HttpOnly), cleartext transmission (Secure), and CSRF (SameSite).
Set-Cookie: __Host-session=TOKEN; Secure; HttpOnly; SameSite=Lax; Path=/
Frequently Asked Questions
Why does the __Host- cookie prefix improve security?
A cookie named with the __Host- prefix is enforced by browsers to have the Secure flag, Path=/, and no Domain attribute, preventing compromised subdomains from overwriting or tossing session cookies.
Do I need both X-Frame-Options and CSP frame-ancestors?
CSP frame-ancestors is the modern standard and supports multiple allowed origins, while X-Frame-Options: DENY is kept alongside it for defense-in-depth compatibility.