Browser Security

Website Security Headers Explained

A practical guide to the browser protections that reduce clickjacking, content sniffing, referrer leakage, unsafe embedding, and script abuse.

By Fixnx Security Team
Security headers review in a Fixnx website scan

Security headers are instructions sent by your website to the browser. They do not fix every vulnerability, but they reduce important classes of browser-side risk and make exploitation harder when other mistakes exist.

For website owners, headers are attractive because many can be improved at the application, CDN, hosting, or reverse proxy layer. The challenge is choosing policies that improve security without breaking analytics, payments, embeds, fonts, or legitimate third-party scripts.

Why security headers matter

Browsers are powerful application platforms. They execute JavaScript, store cookies, load third-party scripts, submit forms, display embedded content, and move users between pages. Security headers define guardrails for that behavior.

A missing header is not always a confirmed vulnerability by itself. It is often a hardening gap. The risk increases when missing headers combine with sensitive sessions, user-generated content, payment flows, admin panels, or weak application code.

  • They reduce the blast radius of cross-site scripting and content injection.
  • They help enforce HTTPS and reduce mixed-content exposure.
  • They limit framing and clickjacking risk.
  • They reduce accidental leakage through referrers and browser features.
  • They provide a more consistent baseline across pages and subdomains.

Strict-Transport-Security

Strict-Transport-Security, usually called HSTS, tells browsers to use HTTPS for future requests to the site. It helps prevent downgrade behavior after a browser has seen the header.

HSTS should be enabled only when HTTPS is working reliably across the domain and any included subdomains. A rushed rollout with includeSubDomains can create availability problems if some subdomains are not ready for HTTPS.

  • Start with HTTPS working everywhere before enabling long HSTS durations.
  • Use includeSubDomains only when every relevant subdomain supports HTTPS.
  • Consider preload only after careful review because removal can take time.
  • Keep redirects from HTTP to HTTPS simple and reliable.

Content-Security-Policy

Content-Security-Policy, or CSP, controls where scripts, styles, images, frames, and other resources can load from. It is one of the most useful browser protections, but also one of the easiest to break when applied without testing.

A good CSP should reflect how the website actually works. If the site depends on analytics, payment widgets, maps, chat tools, or marketing tags, those services need to be handled intentionally rather than added through broad wildcards.

  1. Inventory scripts and third-party services used by the website.
  2. Start with a report-only policy when possible.
  3. Remove unsafe inline scripts instead of immediately allowing everything.
  4. Tighten script-src, object-src, base-uri, frame-ancestors, and form-action first.
  5. Monitor violations and adjust with evidence.

CSP is not a substitute for output encoding

CSP can reduce impact, but the primary XSS fix is still safe output handling and avoiding unsafe DOM patterns.

Framing and clickjacking protection

Clickjacking occurs when an attacker frames your site and tricks a user into interacting with it unknowingly. This matters most for logged-in areas, settings pages, checkout flows, and actions that change data.

Modern sites should usually prefer the frame-ancestors directive in CSP. X-Frame-Options is still commonly checked and can provide a useful compatibility layer.

  • Use frame-ancestors in CSP to control who can frame your pages.
  • Use X-Frame-Options: DENY or SAMEORIGIN where it fits the site.
  • Be careful with pages that must be embedded by trusted partners.
  • Do not frame sensitive account actions unless there is a clear business need.

MIME sniffing, referrers, and browser permissions

Several headers reduce quieter but still important risks. X-Content-Type-Options helps stop browsers from guessing content types. Referrer-Policy limits how much URL information is sent to other sites. Permissions-Policy restricts access to browser features such as camera, microphone, geolocation, and payment capabilities.

These headers are usually easier to roll out than CSP, but they still deserve testing. Referrer rules can affect analytics, and permissions policies can affect legitimate product features.

  • Use X-Content-Type-Options: nosniff on most modern sites.
  • Use a Referrer-Policy that balances privacy and business analytics needs.
  • Disable browser permissions that the site does not use.
  • Review headers across important pages, not only the homepage.

A practical rollout plan

Do not copy a strict header template into production without understanding the site. Start with the safest headers, test important workflows, then tighten CSP and framing rules with evidence.

After deployment, rescan the website and check browser console errors, payment flows, login, forms, embedded content, and analytics.

  1. Confirm HTTPS and redirects are stable.
  2. Add nosniff, Referrer-Policy, and an initial Permissions-Policy.
  3. Add HSTS with a cautious max-age, then increase when stable.
  4. Add frame-ancestors or X-Frame-Options according to embedding needs.
  5. Build and test a CSP that matches real website behavior.

Recommended next steps

FAQ

Are missing security headers vulnerabilities?

Sometimes they are hardening gaps rather than confirmed vulnerabilities. Severity depends on the website, sessions, sensitive flows, and whether the missing header increases the impact of another issue.

Which security header should I add first?

For many sites, start with HTTPS correctness, X-Content-Type-Options, Referrer-Policy, and basic framing protection. HSTS and CSP should be rolled out carefully with testing.

Can a Content-Security-Policy break my website?

Yes. CSP controls resource loading, so a strict policy can block legitimate scripts, styles, payments, analytics, or embeds. Test first and consider report-only mode.

Check your website security headers

Fixnx reviews browser security headers and explains what each finding means in the context of the public website.