Abstract shield formed from stacked HTTP header lines protecting a browser window

Security headers are HTTP response headers that tell the browser how to treat your site: which scripts may run, whether the page can be framed, how much of the URL to leak to third parties. Eight headers cover what almost every website needs, and they are configured once at the web server or CDN. Set correctly, they neutralise whole classes of attack — cross-site scripting, clickjacking, MIME sniffing and HTTPS downgrade — without touching your application code.

Why this matters for your website

Most attacks against small business sites are opportunistic. A scanner finds a missing header, an injected script executes, and a checkout page starts leaking card data or session cookies.

Headers are defence in depth. They do not fix a vulnerable plugin, but they limit what an attacker can do with one. They are also the cheapest hardening available to you: a few lines of configuration, no performance cost, no licence.

The authoritative references are the OWASP Secure Headers Project and MDN's HTTP headers documentation. Both are free and kept current.

The security headers list, one by one

Each snippet below shows nginx first, then Apache. Add them to your server block or .htaccess, or set them at your CDN if it terminates TLS.

Strict-Transport-Security (HSTS)

Blocks an attacker on the same network from downgrading a visitor's first request to plain HTTP and intercepting the session. Recommended value: max-age=31536000; includeSubDomains, defined in RFC 6797.

add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
Header always set Strict-Transport-Security "max-age=31536000; includeSubDomains"

Common mistake: adding includeSubDomains or preload while a subdomain still runs on HTTP. Browsers will then refuse to load it, and preload entries are slow to reverse.

Content-Security-Policy (CSP)

Stops a script injected through a comment field, a compromised plugin or a third-party tag from executing or exfiltrating data. It is the most powerful header and the most work to deploy.

add_header Content-Security-Policy "default-src 'self'; script-src 'self'; object-src 'none'; base-uri 'self'; frame-ancestors 'self'" always;
Header always set Content-Security-Policy "default-src 'self'; script-src 'self'; object-src 'none'; base-uri 'self'; frame-ancestors 'self'"

Start with Content-Security-Policy-Report-Only so violations are reported but nothing breaks, then tighten. Common mistake: keeping 'unsafe-inline' in script-src, which removes most of the protection. Use nonces or hashes instead.

Diagram showing how Content-Security-Policy blocks an injected script from executing and exfiltrating data
With a strict script-src, the injected script never executes and no data leaves the page.

X-Frame-Options and frame-ancestors

Prevents clickjacking, where your login or checkout page is loaded invisibly inside an attacker's page so clicks land on your buttons. Recommended value: SAMEORIGIN.

add_header X-Frame-Options "SAMEORIGIN" always;
Header always set X-Frame-Options "SAMEORIGIN"

CSP's frame-ancestors supersedes this header and supports multiple allowed origins. Keep both for older browsers. Common mistake: using ALLOW-FROM, which no current browser supports.

X-Content-Type-Options

Stops the browser from guessing a file's type and executing an uploaded image or text file as JavaScript. One value only: nosniff.

add_header X-Content-Type-Options "nosniff" always;
Header always set X-Content-Type-Options "nosniff"

Common mistake: serving real assets with a wrong Content-Type (for example JavaScript as text/plain), which nosniff then correctly refuses to load. Fix the MIME types, not the header.

Referrer-Policy

Prevents full URLs — including password-reset tokens and internal search terms — from being sent to third-party sites and ad networks. Recommended value: strict-origin-when-cross-origin.

add_header Referrer-Policy "strict-origin-when-cross-origin" always;
Header always set Referrer-Policy "strict-origin-when-cross-origin"

Common mistake: jumping straight to no-referrer, which breaks analytics attribution and some affiliate and payment flows.

Permissions-Policy

Denies access to camera, microphone and geolocation for your page and anything embedded in it, so a compromised third-party widget cannot prompt your visitors for hardware access.

add_header Permissions-Policy "geolocation=(), camera=(), microphone=()" always;
Header always set Permissions-Policy "geolocation=(), camera=(), microphone=()"

Common mistake: using the old Feature-Policy syntax (camera 'none'). The current syntax is an allowlist in parentheses; an empty list means deny.

Cross-Origin-Opener-Policy and Cross-Origin-Resource-Policy

COOP cuts the link between your page and any window that opened it, so a malicious site cannot manipulate or probe your tab. CORP stops other origins from loading your resources into their pages, reducing cross-origin leak techniques.

add_header Cross-Origin-Opener-Policy "same-origin" always;
add_header Cross-Origin-Resource-Policy "same-origin" always;
Header always set Cross-Origin-Opener-Policy "same-origin"
Header always set Cross-Origin-Resource-Policy "same-origin"

Common mistake: same-origin COOP breaks OAuth and payment popups that talk back through window.opener. Use same-origin-allow-popups on those pages. If you serve images or embeds to partner sites, CORP must be cross-origin for those paths.

X-XSS-Protection (drop this one)

This header controlled the legacy XSS filter in Internet Explorer and old Chrome. The filter was removed from Chrome and Edge and never existed in Firefox, and it could itself be abused to block legitimate scripts.

Remove the header, or send X-XSS-Protection: 0 if a compliance checklist still expects a value. Real cross-site scripting defence is output encoding plus a strict CSP.

Summary: values and risk if missing

  • Strict-Transport-Security — max-age=31536000; includeSubDomains — HTTPS downgrade and session interception on hostile networks.
  • Content-Security-Policy — default-src 'self'; script-src 'self'; object-src 'none'; base-uri 'self' — injected scripts run freely; card and credential skimming.
  • X-Frame-Options — SAMEORIGIN — clickjacking of admin and checkout actions.
  • X-Content-Type-Options — nosniff — uploaded files executed as scripts.
  • Referrer-Policy — strict-origin-when-cross-origin — tokens and private URLs leaked to third parties.
  • Permissions-Policy — geolocation=(), camera=(), microphone=() — embedded content requesting device access.
  • Cross-Origin-Opener-Policy / Resource-Policy — same-origin — cross-window tampering and cross-origin data leaks.
  • X-XSS-Protection — remove, or 0 — no protection; legacy filter behaviour only.
Layered stack diagram showing where security headers sit between CDN, web server and browser
Set headers once at the edge or web server so every page and asset inherits them.

How to check your own site

Headers are easy to verify because they are public. Run curl -I https://example.com and read the response, or use a grader.

Scantinel (scantinel.ai) is an automated website security assessment platform that runs OSINT, network, and OWASP Top 10 web vulnerability tests against ownership-verified assets and delivers actionable, business-owner-legible reports. You can check your security headers free with no account: the tool grades each of the headers above and shows the value it found.

The Essential scan runs the same header check in context — alongside cookie flags (Secure, HttpOnly, SameSite), a TLS audit covering protocols, ciphers and expiry, DNS and SPF/DKIM/DMARC posture, and a CMS version and known-vulnerable plugin check. That combination matters because a perfect CSP does little if session cookies are readable by JavaScript. See what each scan depth covers. For wider context, read our website security guide and how to check your website security.

Open-source alternatives for the same job include OWASP ZAP and nuclei. A header scan is a configuration review, not a penetration test.

Key takeaways

  • Six headers do most of the work: HSTS, CSP, X-Frame-Options, nosniff, Referrer-Policy and Permissions-Policy.
  • Deploy CSP in Report-Only mode first, then enforce; never ship 'unsafe-inline' in script-src and call it done.
  • Set headers in one place — web server or CDN — so every page and asset inherits them.
  • Drop X-XSS-Protection and stop treating it as a control.
  • Re-test after any CDN, theme or plugin change; headers are silently easy to lose.

Frequently asked questions

What security headers should my website have?

At minimum: Strict-Transport-Security, Content-Security-Policy, X-Frame-Options, X-Content-Type-Options, Referrer-Policy and Permissions-Policy. Add Cross-Origin-Opener-Policy and Cross-Origin-Resource-Policy if you handle accounts or payments. Use the recommended values in the summary list above as your starting point.

Are security headers a ranking factor?

No search engine has confirmed security headers as a ranking signal; HTTPS itself is the only related factor Google has publicly described. The indirect benefit is real, though: headers help prevent the defacement, injected spam links and malware warnings that do damage rankings.

Can security headers break my website?

Yes, and CSP is the usual culprit because it blocks third-party scripts, fonts and inline code you forgot about. Deploy CSP in Report-Only mode, review the violation reports for a week, then enforce. HSTS with includeSubDomains and a strict COOP value are the other two to test carefully.

Where do I add security headers on WordPress?

Prefer the web server: an nginx server block, an Apache .htaccess, or your CDN's response-header rules. If you have no server access, a security plugin can add them through PHP, but headers are then missing on static files served directly. Whichever route you take, verify the result on a real URL rather than trusting the settings screen.

Published November 2025 by the Scantinel Security Research Team. Header behaviour changes with browser releases — confirm current guidance against primary sources such as OWASP, MDN, NVD and WPScan.