TelicSentry

Hardening

Security headers: the six worth setting first, in order

HSTS, CSP, nosniff, frame protection, Referrer-Policy and Permissions-Policy: what each security header does, what to set, and what can break.

22 November 2026 · 6 minute read · All guides

A monitoring panel listing sites with days remaining and an alert being sent

The short version

Six response headers remove whole classes of attack. Four of them are safe to add this afternoon.

Why headers are the cheapest fix you have

A security header is one line in a server's response that tells the browser to behave more strictly. Adding one needs no code change and no redeploy of the application, only a line of web-server configuration, and each one closes off a category of attack rather than a single bug.

Four you can add today

X-Content-Type-Options: nosniff. Stops the browser guessing a file's type, so an uploaded text file cannot be run as a script. There is essentially no reason not to send it.

Clickjacking protection. X-Frame-Options: DENY, or the newer frame-ancestors directive, stops another site loading yours inside an invisible frame and tricking a user into clicking it. Use SAMEORIGIN only if you frame your own pages.

Referrer-Policy: strict-origin-when-cross-origin. Stops full page addresses, which sometimes carry tokens or record numbers, leaking to other sites when a user follows a link.

Permissions-Policy. Switches off browser features the site does not use, such as camera, microphone and location, so injected script cannot ask for them.

Two that need care

Strict-Transport-Security tells a browser to refuse plain HTTP for your host for a set period. It defeats downgrade attacks on hostile networks, and it is close to irreversible while that period lasts: a browser that has seen the header will not connect over HTTP until it expires. Start with a short max-age, confirm nothing on the domain still needs HTTP, then raise it to a year. Be especially careful with includeSubDomains.

Content-Security-Policy is the strongest defence against cross-site scripting and the easiest header to get wrong. It lists where scripts, styles and frames may load from, and a policy that is too tight breaks the site while one that allows unsafe-inline protects little. Deploy it in report-only mode first, read what it would have blocked, and tighten from there.

How to check what you send now

Open your site with the browser's developer tools, look at the response headers for the page itself, and compare them with the list above. Check a plain http:// address too and confirm it redirects.

Then check again after every infrastructure change. Headers set at a load balancer disappear quietly when traffic is moved to a new one, and nothing in the application will notice.

Common questions

Which security header should I add first?

X-Content-Type-Options: nosniff, then clickjacking protection and Referrer-Policy. All three are low risk and need no testing beyond confirming the site still loads.

Can HSTS break my website?

It can make any part of the domain that only works over HTTP unreachable for visitors who have already received the header. Start with a short max-age.

Is X-Frame-Options still needed if I use Content-Security-Policy?

The frame-ancestors directive supersedes it in modern browsers, but sending both is harmless and covers older ones.

Try it on your own site

Check your headers free