SITEDOCTOR
Website Security · HTTP Headers

Website security headers explained: the 6 headers that actually matter

SITEDOCTOR Blog · 2026-10-26 · ~7 min read

Security headers are the highest ROI fix in web security: each one is a single line of configuration, costs nothing, and blocks an entire class of attack. Yet most sites ship with none of them — not because developers don't care, but because the header names are cryptic and nobody explains what each one actually blocks. This guide does. For every header: what attack it stops, the recommended value, and the misconfiguration that makes it useless.

The quick-reference table

HeaderBlocksRecommended value
Strict-Transport-SecuritySSL stripping, downgrade attacksmax-age=63072000; includeSubDomains; preload
Content-Security-PolicyXSS, data injectiondefault-src 'self' (then tighten)
X-Frame-OptionsClickjackingDENY or SAMEORIGIN
X-Content-Type-OptionsMIME-sniffing attacksnosniff
Referrer-PolicyURL/data leakage to third partiesstrict-origin-when-cross-origin
Permissions-PolicyAbuse of camera, mic, geolocation APIscamera=(), microphone=(), geolocation=()

1Strict-Transport-Security (HSTS) — force HTTPS forever

HSTS tells the browser: never talk to this site over plain HTTP again. Without it, an attacker on a coffee-shop network can intercept the first HTTP request and strip the redirect to HTTPS (SSL stripping). With it, the browser upgrades every request internally before anything leaves the machine.

Strict-Transport-Security: max-age=63072000; includeSubDomains; preload
Common failure: setting max-age to a tiny value like 300, or sending the header only on some pages. It must be on every HTTPS response, and two years (63072000 seconds) is the standard. Only add preload if you're ready to commit — removal from browser preload lists takes months.

2Content-Security-Policy (CSP) — the XSS kill switch

CSP is the most powerful and most feared header. It whitelists where scripts, styles, images and frames may load from, so even if an attacker injects a <script> tag into your page, the browser refuses to execute it. It is the difference between an XSS bug being a nuisance and a full account takeover.

Content-Security-Policy: default-src 'self'; script-src 'self'; object-src 'none'; base-uri 'self'
Safe rollout: deploy first as Content-Security-Policy-Report-Only. The browser reports what would break without breaking it. Fix the violations, then enforce.

3X-Frame-Options — stop clickjacking

Clickjacking puts your site in an invisible iframe on a malicious page, so users think they're clicking "Claim prize" but actually click your "Delete account" button. X-Frame-Options: SAMEORIGIN tells browsers that only your own pages may frame your site. Modern sites should also set frame-ancestors 'self' inside the CSP, which is the successor directive — but keep the old header for legacy browsers.

4X-Content-Type-Options — one word: nosniff

Browsers try to be helpful: if a file labeled "image" looks like JavaScript, some will execute it anyway. That "helpfulness" turns any file-upload feature into an XSS vector. X-Content-Type-Options: nosniff disables it. There is no valid reason to omit this header — it breaks nothing.

5Referrer-Policy — stop leaking your URLs

When a user clicks a link from your site to a third party, the browser sends the full source URL in the Referer header. If your URLs contain tokens, reset links or private IDs (/reset?token=abc123), you just handed them to a stranger. Referrer-Policy: strict-origin-when-cross-origin sends only your domain name to other sites, and nothing at all on downgrades to HTTP.

6Permissions-Policy — disable APIs you don't use

Does your marketing site need access to the visitor's camera, microphone and precise geolocation? No — and neither does any ad script or embedded widget on it. Permissions-Policy: camera=(), microphone=(), geolocation=() removes those capabilities from the page entirely, shrinking the surface any compromised third-party script can abuse.

Check your own headers in 10 seconds

You don't need a tool to see the truth — ask the server directly:

curl -sI https://yourdomain.com | grep -iE "strict-transport|content-security|x-frame|x-content|referrer-policy|permissions-policy"

No output at all? You have zero of the six — which is where most sites start. Run the same command against several pages, not just the homepage: it's common for the landing page to be hardened while the app behind /login or a CDN-cached route sends nothing.

The 5-minute fix checklist

SITEDOCTOR checks all six security headers — plus SSL validity, redirect chains, meta tags and broken links — in one scan. Free instant scan for humans, no signup; AI agents get 25 free credits via the MCP API.

Get a free scan →