Key takeaway
- Guide to HTTP security headers for CISOs and architects: CSP, HSTS, nosniff, CORS, CORP and COEP, what is deprecated, and how XSS is really stopped.
What are HTTP security headers and what do they protect against?
HTTP security headers are response headers a server sends so that the browser applies extra rules to a page: which scripts may run, whether the page may be framed, whether the connection must use HTTPS, and which other origins may read its resources. They narrow what the browser will do, which limits the damage when an application has a cross-site scripting (XSS), clickjacking or content-sniffing flaw. They sit beside secure coding, not in place of it. The OWASP XSS Prevention Cheat Sheet treats Content Security Policy (CSP) as defence in depth, not as the primary fix.
For a CISO or platform lead, the practical answer is a short baseline: a strict CSP, HSTS, nosniff and a framing rule, with CORS, CORP and COEP set deliberately where cross-origin access matters. Several headers older guides recommend, such as X-XSS-Protection, are now deprecated. This guide covers what each header does, what has changed, how to roll them out without breaking pages, and when they do not help. It builds on our work on adaptive security architecture and website security.
Which security headers belong in an enterprise baseline?
The table uses MDN and the OWASP HTTP Headers Cheat Sheet as sources. Status is as read on 12 November 2026.
| Header | What it does | When it fits | Current status |
|---|---|---|---|
| Content-Security-Policy | Restricts which sources may load scripts and other content; frame-ancestors controls framing | Every web application, rolled out in report-only mode first | Primary browser-side control against XSS impact; defence in depth, not a replacement for encoding |
| Strict-Transport-Security | Tells the browser to use HTTPS only for the host for a set time | Any site fully served over HTTPS | Current. Preload needs max-age of at least 31536000 and includeSubDomains |
| X-Content-Type-Options: nosniff | Blocks MIME sniffing; blocks scripts and styles served with the wrong type | Every response | Current. Needs correct Content-Type on all resources |
| X-Frame-Options | Allows DENY or SAMEORIGIN framing only | Fallback for legacy browsers beside CSP frame-ancestors | ALLOW-FROM is obsolete; frame-ancestors is the more flexible control |
| Referrer-Policy, Permissions-Policy | Limit referrer data and browser features | Sites handling sensitive URLs or embedding third parties | OWASP suggests strict-origin-when-cross-origin for Referrer-Policy |
| CORS headers | Let a server allow named origins to read its responses | APIs called from other origins | Current. Wildcard origin cannot be used with credentials |
| Cross-Origin-Resource-Policy | Resource owner blocks no-cors loads from other sites or origins | Sensitive resources and API responses | Current |
| Cross-Origin-Embedder-Policy | Document only loads cross-origin resources that opt in | Pages that need cross-origin isolation | Current. Values: unsafe-none, require-corp, credentialless |
| X-XSS-Protection | Legacy browser XSS filter | Not for new work | Deprecated and non-standard; MDN recommends CSP instead |
What has changed in HTTP security headers?
X-XSS-Protection is deprecated. MDN marks it deprecated and non-standard, warns that it can create XSS vulnerabilities in otherwise safe sites, and recommends CSP. The OWASP cheat sheet advises not to set it. If it is still sent,
X-XSS-Protection: 0avoids the filter-related problems MDN describes.Framing is now a CSP job.
X-Frame-Options: ALLOW-FROMis obsolete and modern browsers ignore the header when they see it. UseContent-Security-Policy: frame-ancestors 'none'unless the page must be embeddable, and keep DENY or SAMEORIGIN only as a legacy fallback.Strict CSP replaces allowlists. MDN describes nonce-based and hash-based strict policies as easier to maintain than host allowlists, which are hard to get right.
Reporting has moved. MDN recommends the Reporting API (
Reporting-Endpointswithreport-to) and marksreport-urideprecated, while suggesting both are declared until support is universal.
How do XSS attacks work and what stops them?
In cross-site scripting, an attacker gets a script to run in a victim's browser in the context of a trusted site. OWASP describes the cause as an application putting untrusted data into a page in a way that lets the browser treat it as code. There are three common forms.

What is stored XSS?
The application saves attacker input, for example a comment, and renders it raw to later visitors. Anyone who loads the page runs the script, which can read page data or redirect the user. The fix is output encoding for the context where the data lands, plus a maintained sanitiser such as DOMPurify where users may submit HTML.
What is reflected XSS?
The script arrives in a request parameter, such as a name in a URL, and the server echoes it in the response. The victim usually has to follow a crafted link. Server-side output encoding is the control; user vigilance is not.
What is DOM-based XSS?
Client-side JavaScript reads an attacker-controllable source, such as the URL, and writes it into the page through an unsafe sink. OWASP advises safe sinks such as textContent over innerHTML, avoiding eval(), and allowing only expected URL schemes (not javascript:). Trusted Types, where supported, help enforce this.
Why are headers not enough on their own?
OWASP states that input filtering, interceptors and web application firewalls do not replace context-aware encoding and safe DOM use, and that CSP should not be the primary defence. Treat headers as the layer that limits impact when a flaw slips through. For testing both layers, see our guide to SAST, DAST, IAST and SCA and the application security best practices guide.
How should you configure Content Security Policy?
A CSP is a set of semicolon-separated directives. MDN's strict examples use a nonce or hash and also set object-src 'none' and base-uri 'none'.
When does a nonce-based policy fit?
The server generates an unpredictable value for every response, puts it in the policy and in the nonce attribute of the intended script tags. The browser runs only scripts whose nonce matches. Because the value changes per response, the HTML cannot be served as static files. Insert nonces only into your own tags.
Content-Security-Policy:
script-src 'nonce-{RANDOM}';
object-src 'none';
base-uri 'none';When does a hash-based policy fit?
You hash each script with SHA-256, SHA-384 or SHA-512, Base64-encode it and list it with the matching prefix. External scripts also need an integrity attribute. This suits static pages and client-rendered single-page applications, but any script change means recomputing and redeploying the hash.
Content-Security-Policy:
script-src 'sha256-{HASHED_SCRIPT}';
object-src 'none';
base-uri 'none';
Two cautions from MDN. Browsers ignore 'unsafe-inline' when a directive contains nonce or hash expressions. 'strict-dynamic' eases third-party scripts but is less secure if trusted scripts build script elements from XSS-prone input.
How do you roll out CSP without breaking pages?
Send Content-Security-Policy-Report-Only first. It is not enforced but reports violations, and it cannot be delivered in a meta element. Our engineering teams have used this pattern on embedded applications, adding report-only headers first so that embed compatibility was kept while violations were reviewed. Move to enforcement once the reports are clean.
How do CORS, CORP and COEP differ?
| Header | Who sets it | Question it answers | Values or behaviour |
|---|---|---|---|
| CORS (Access-Control-Allow-Origin and related) | The server being called | Which other origins may read this response? | A named origin; no wildcard when credentials are used |
| Cross-Origin-Resource-Policy | The resource owner | Who may load this resource in no-cors mode? | same-site, same-origin, cross-origin |
| Cross-Origin-Embedder-Policy | The embedding document | Will this page load only resources that opted in? | unsafe-none (default), require-corp, credentialless |
A request is simple, and skips preflight, only if the method is GET, HEAD or POST, manually set headers are CORS-safelisted, and Content-Type is application/x-www-form-urlencoded, multipart/form-data or text/plain. Anything else triggers an OPTIONS preflight, whose result can be cached with Access-Control-Max-Age. Setting COEP with Cross-Origin-Opener-Policy: same-origin makes a document cross-origin isolated, which features such as SharedArrayBuffer need. Our API development best practices post covers where these controls sit in API design.
What should you know about HSTS before enabling it?
HSTS only takes effect after the browser has received the header once over HTTPS, so the first insecure request stays exposed unless the domain is preloaded. Preload requires max-age of at least 31536000, includeSubDomains and preload, and MDN notes it is hard to undo, so confirm every subdomain serves HTTPS first. Each subdomain should send its own header, and browsers offer no click-through on certificate errors for HSTS hosts.
How do you roll out headers across a large estate?
Inventory. List applications, owners and where headers are set (application, reverse proxy, CDN).
Set the safe defaults.
nosniff, a framing rule and HSTS where HTTPS is complete.Run CSP in report-only mode. Review reports, then enforce per application.
Set cross-origin policy deliberately. Named CORS origins, CORP for sensitive resources, COEP only where isolation is needed.
Make it a release check. Verify headers in the pipeline so a deployment cannot silently drop them.
The same control-and-evidence thinking applies to AI agents that call your web applications. ElixirData Context OS, according to its site, supplies enterprise AI agents with trustworthy context, checks what they are allowed to do before they act, and logs every decision for audit. AgentGRC offers governance, risk and compliance controls for autonomous agent actions. See also agentic AI security.
When do security headers not help?
They do not fix the underlying flaw. Unencoded output remains a vulnerability even behind a strong CSP.
A weak policy gives false comfort. A CSP that allows
'unsafe-inline'without nonces or hashes does little against injected inline script.Wrong Content-Type values plus
nosniffwill block legitimate scripts and styles.Headers protect the browser side only. They do not secure the server, the API logic or stored data.
What are the business impacts of XSS?
A successful XSS attack can expose session tokens or personal data, let an attacker act as a user, send users to phishing pages and damage trust in the brand. If personal data is exposed, privacy obligations may apply, so involve your data protection and legal teams in incident planning.
To map one browser-security decision your agents and applications depend on, and the context and policy behind it, book a Context Workshop. See what happens in the workshop.
Frequently asked questions
Should we still send X-XSS-Protection?
No. MDN marks it deprecated and non-standard and recommends CSP. If it is still sent, a value of 0 avoids the filter problems MDN describes.
Is X-Frame-Options still needed?
Use CSP frame-ancestors as the primary control. DENY or SAMEORIGIN can remain as a fallback for legacy browsers. ALLOW-FROM is obsolete.
Nonce or hash for CSP?
Nonces suit dynamically generated responses because the value changes per response. Hashes suit static or client-rendered pages but need recomputing whenever a script changes.
How do we test a CSP safely?
Send Content-Security-Policy-Report-Only first, review the violation reports, then enforce. Report-only cannot be set in a meta element.
Can we use Access-Control-Allow-Origin: * with cookies?
No. For credentialed requests the server must name an explicit origin and send Access-Control-Allow-Credentials: true, otherwise the browser blocks the response.
What does HSTS preload require?
A max-age of at least 31536000, includeSubDomains and preload, submitted through hstspreload.org, which MDN notes is not part of the HSTS specification.
Recommended Next Steps for Implementation
Engage with our specialists about implementing effective HTTP security headers. Discover how various industries utilize these headers and strategies to create robust defenses against XSS attacks. Leveraging security headers enhances web application safety, automating protection measures and optimizing response times, ultimately improving overall efficiency and security posture.
Follow XenonStack on LinkedIn: XenonStack on LinkedIn for new guides on agentic AI, data and platform engineering.
Ready to put AI agents to work? Explore ElixirClaw, the agentic OS platform to build, orchestrate and govern AI agents.
Explore the XenonStack platform family: ElixirData · ElixirClaw · ElixirHub · NexaStack · MetaSecure · Neural AI · AgentGRC · AgentSRE · AgentAnalyst · AgentInstruct · AgentRAI · AgentScrum · AgentSearch · AgentForce · AI Aviator · SAIF Aviator · CohortIQ · XenonStack AI · XenonStack UAE