Security headers explained for site owners
Five short HTTP headers tell browsers how to protect your visitors. What HSTS, CSP, X-Frame-Options and friends do, and how to add them without breaking the site.
Security headers are instructions your server sends along with every page. Visitors never see them, but their browsers follow them. A handful of lines can stop whole categories of attack, and most WordPress sites send none of them.
The headers that matter
Strict-Transport-Security (HSTS), defined in RFC 6797, tells the browser to use HTTPS for your domain for a set period, even if someone types http:// or follows an old link. It closes the short window in which a visitor on a hostile network could be served a fake, unencrypted version of the site. A sensible value: max-age=31536000 (one year). Add includeSubDomains only when every subdomain works over HTTPS.
X-Frame-Options (or the newer frame-ancestors directive in CSP) stops other sites from loading your pages inside an invisible frame. That defeats clickjacking, where a visitor thinks they are clicking one thing and actually clicks a button on your site. A sensible value: SAMEORIGIN, so your own site can still use frames.
X-Content-Type-Options: nosniff tells browsers not to guess a file's type. Without it, a file uploaded as an image could be run as a script in some situations.
Referrer-Policy controls how much of the current address is passed to the next site a visitor goes to. strict-origin-when-cross-origin passes only your domain to other sites, which protects search terms and private addresses in URLs.
Permissions-Policy switches off browser features your site does not use, such as the camera, microphone and geolocation, so a compromised third-party script cannot ask for them.
Content Security Policy: powerful, handle with care
Content-Security-Policy (CSP) lists which sources may provide scripts, styles, images and frames. A strict CSP is one of the best defences against cross-site scripting, because injected scripts from unknown places simply do not run.
It is also the header most likely to break a WordPress site. Themes and plugins load scripts from many places, and inline scripts are everywhere. The safe way in:
- Start with
Content-Security-Policy-Report-Only, which reports violations without blocking anything. - Collect what the site actually loads for a week or two.
- Build the allowed list from that, then switch to enforcing.
- Recheck after adding any plugin or tracking tag.
How to check yours
Open your site, open the browser's developer tools, choose the Network tab, click the first request and look at the response headers. Free scanners give you a quick grade as well. A missing header is not a vulnerability in itself; it is a protection you are not using.
In Ironhelm
Security headers adds HSTS, frame protection, nosniff, a referrer policy and a permissions policy with safe defaults. Its Content Security Policy starts in report-only mode and collects what it would have blocked, so you can tighten it without breaking pages, and it can check which headers your site actually sends.
Sources
- IETF, RFC 6797: HTTP Strict Transport Security (HSTS)
- MDN Web Docs, Content Security Policy (CSP)
- MDN Web Docs, X-Frame-Options
- MDN Web Docs, Referrer-Policy
- OWASP, Secure Headers Project
Ironhelm Suite is one WordPress plugin for security, speed, SEO and analytics. See plans or tour the features.