HTTP security headers: HSTS, CSP and the rest, the guide

A few lines in the server response close common browser-side attacks.

The main ones

  • Strict-Transport-Security (HSTS): forces HTTPS.
  • Content-Security-Policy (CSP): limits which scripts may run.
  • X-Frame-Options or frame-ancestors: stops the site being shown in a foreign frame.
  • X-Content-Type-Options: nosniff, Referrer-Policy, Permissions-Policy.

Check

Test security headers. Comparison with a well-known tool: AttackScout and securityheaders.

Add without breaking

Start HSTS with a short max-age, and run CSP as Content-Security-Policy-Report-Only before enforcing it.

Monitor

A theme or plugin update can drop a header. AttackScout rereads them every day on each monitored site. See pricing.

Get the free alerts