Advanced Security Headers Guide
Beyond the core security headers like CSP and HSTS, modern browsers support a second tier of headers that defend against side-channel attacks, control cross-origin interactions, and prevent your server from leaking infrastructure details. This guide covers all of them.
Cross-Origin Policies#
Two web pages are "cross-origin" when they differ in protocol, domain, or port. For example, https://your-site.com and https://other-site.com are cross-origin because the domains differ. Cross-origin policy headers control how your page loads resources from, and interacts with, other origins.
These three headers work together to create cross-origin isolation, a browser security state that prevents side-channel data leakage and unlocks powerful APIs like SharedArrayBuffer (a tool for sharing memory between JavaScript threads).
Controls how cross-origin resources can be embedded in your website.
Purpose
Prevents cross-origin data leakage and enables SharedArrayBuffer usage.
Example
Cross-Origin-Embedder-Policy: require-corpValues
Benefits
- Enables SharedArrayBuffer for high-performance apps
- Prevents cross-origin data leakage
- Improves isolation between origins
- Required for advanced web features
Considerations
- May break existing cross-origin integrations
- Requires careful implementation planning
- Can affect third-party scripts and resources
Controls how your website can be opened in new windows or tabs.
Purpose
Prevents cross-origin window manipulation and popup attacks.
Example
Cross-Origin-Opener-Policy: same-originValues
Benefits
- Prevents cross-origin window manipulation
- Protects against popup-based attacks
- Improves browser security isolation
- Works with COEP for enhanced security
Considerations
- May break legitimate popup functionality
- Can affect third-party integrations
- Requires testing with existing features
Controls which origins can load your website's resources.
Purpose
Prevents cross-origin resource loading and data exfiltration.
Example
Cross-Origin-Resource-Policy: same-originValues
Benefits
- Prevents cross-origin resource loading
- Protects against data exfiltration
- Improves resource isolation
- Simple to implement
Considerations
- May break legitimate cross-origin resource sharing
- Can affect CDN and third-party resources
- Requires careful configuration
Supporting and Lifecycle Headers#
Privacy and Legacy Protection
These headers address niche concerns like legacy browser plugin security and DNS prefetch privacy. They are low priority individually, but collectively they tighten your security posture with minimal risk of breaking anything.
Controls cross-domain policy file access for legacy plugins like Flash and Silverlight.
X-Permitted-Cross-Domain-Policies: nonePrevents Internet Explorer from automatically opening downloaded files without user confirmation.
X-Download-Options: noopenControls whether browsers perform DNS lookups for links on the page before the user clicks them, which can leak browsing intent.
X-DNS-Prefetch-Control: offBrowser Lifecycle and Upgrades
These headers control how the browser handles process isolation, data cleanup, and protocol upgrades. Origin-Agent-Cluster improves process separation, Clear-Site-Data enables clean logouts, and Upgrade-Insecure-Requests prevents mixed content (when an HTTPS page loads resources over HTTP).
Requests that the browser assign this page to its own origin-keyed agent cluster, improving isolation from other pages on the same site.
Origin-Agent-Cluster: ?1Instructs the browser to clear stored data for your website, useful for secure logout flows and cache invalidation.
Clear-Site-Data: "cache", "cookies", "storage"Tells the browser to automatically upgrade any HTTP resource requests on the page to HTTPS before fetching them.
Upgrade-Insecure-Requests: 1Information Disclosure Prevention#
Information disclosure headers reveal details about your server software, framework, and infrastructure. Attackers use this information to search for known vulnerabilities (CVEs, publicly disclosed security flaws) specific to the exact version you are running. Removing these headers forces attackers to probe blindly, significantly increasing the effort needed for a successful attack.
Server and Framework Banners
These headers directly reveal the software your stack runs on. Removing them prevents attackers from targeting known CVEs for your specific server version, framework, or language runtime.
Server
Reveals the web server software and version.
Server: Apache/2.4.41 (Ubuntu)X-Powered-By
Reveals the application runtime or framework.
X-Powered-By: ExpressX-AspNet-Version
Reveals the ASP.NET framework version.
X-AspNet-Version: 4.0.30319X-AspNet-MVC-Version
Reveals the ASP.NET MVC framework version.
X-AspNet-MVC-Version: 5.2X-PHP-Version
Reveals the PHP version running on the server.
X-PHP-Version: 8.1.0X-PHP-Originating-Script
Reveals the PHP script that generated the response.
X-PHP-Originating-Script: /var/www/html/index.phpAdministrative and Contact Information
Some servers emit contact addresses and admin panel identifiers that hand attackers a ready-made target list for social engineering and brute-force login attempts.
Panel
Reveals the hosting control panel in use.
Panel: cPanelX-Panel
Reveals the hosting control panel in use.
X-Panel: cPanelX-Server-Admin
Reveals server administrator contact information.
X-Server-Admin: admin@example.comRuntime and Application Details
These headers expose application internals, platform identifiers, CMS names, and backend infrastructure details. None of them provide any user-facing benefit.
X-Runtime
Reveals application response time.
X-Runtime: 0.123456X-Version
Reveals the application version.
X-Version: 1.2.3Platform
Reveals the platform or technology stack.
Platform: Node.jsX-Platform
Reveals the platform or technology stack.
X-Platform: Node.jsX-Framework
Reveals the web framework being used.
X-Framework: Django/3.2X-CMS
Reveals the content management system.
X-CMS: WordPress/5.8X-Generator
Reveals the CMS or static site generator.
X-Generator: WordPress/5.8X-Drupal-Cache
Confirms the site runs Drupal and reveals caching details.
X-Drupal-Cache: HITX-Application-Server
Reveals the application server type and version.
X-Application-Server: Tomcat/9.0.45X-Backend-Server
Reveals backend server or load balancer information.
X-Backend-Server: nginx/1.18.0X-Server-Software
Reveals detailed server software information.
X-Server-Software: Apache/2.4.41X-Server-Name
Reveals server hostname or identification.
X-Server-Name: web01.example.comCaching Infrastructure
Caching headers can fingerprint your CDN or reverse proxy layer and reveal your caching architecture. Remove them in production environments.
X-Cache-Status
Reveals caching system status.
X-Cache-Status: HITX-Cache-Engine
Reveals the caching engine being used.
X-Cache-Engine: VarnishX-Cache-Info
Reveals detailed caching information.
X-Cache-Info: HIT from cacheX-Cache-Version
Reveals the caching system version.
X-Cache-Version: 6.0Why These Headers Matter#
Advanced security headers protect against sophisticated attack techniques that basic headers alone cannot prevent. Without these protections, your site is exposed to data leakage, side-channel attacks, and infrastructure reconnaissance.
Cross-Origin Isolation
After the Spectre vulnerability was discovered in 2018, browsers restricted access to high-precision timers and SharedArrayBuffer because they could be used for side-channel attacks (where an attacker reads data from other processes by measuring timing differences). Cross-origin isolation headers (COEP, COOP, CORP) restore access to these features by ensuring your page cannot accidentally load or interact with resources from other origins.
- Prevents Spectre-style side-channel data extraction
- Enables high-performance features like SharedArrayBuffer
- Creates strong security boundaries between your site and others
Information Disclosure
When your server reveals its software version, framework, or platform through HTTP headers, attackers can search for known vulnerabilities (CVEs) specific to that version. Removing information disclosure headers forces attackers to probe blindly, significantly increasing the effort required for a successful attack.
- Prevents targeted attacks using known software vulnerabilities
- Reduces your attack surface by hiding infrastructure details
- Required by security compliance frameworks like PCI DSS and CIS Benchmarks
Implementation Guide#
Below are complete configurations for setting advanced security headers and removing information disclosure headers on common web servers.
Apache
# Add to .htaccess or httpd.conf Header always set Cross-Origin-Embedder-Policy "require-corp" Header always set Cross-Origin-Opener-Policy "same-origin" Header always set Cross-Origin-Resource-Policy "same-origin" Header always set X-Permitted-Cross-Domain-Policies "none" Header always set X-Download-Options "noopen" Header always set X-DNS-Prefetch-Control "off" Header always set Origin-Agent-Cluster "?1" Header always set Upgrade-Insecure-Requests "1" # Remove information disclosure headers ServerTokens Prod ServerSignature Off Header unset X-Powered-By Header unset X-AspNet-Version Header unset X-AspNet-MVC-Version Header unset X-Runtime Header unset X-Version
Nginx
# Add to nginx.conf or site configuration add_header Cross-Origin-Embedder-Policy "require-corp" always; add_header Cross-Origin-Opener-Policy "same-origin" always; add_header Cross-Origin-Resource-Policy "same-origin" always; add_header X-Permitted-Cross-Domain-Policies "none" always; add_header X-Download-Options "noopen" always; add_header X-DNS-Prefetch-Control "off" always; add_header Origin-Agent-Cluster "?1" always; add_header Upgrade-Insecure-Requests "1" always; # Hide server information server_tokens off;
Node.js / Express
const express = require('express');
const app = express();
// Remove the default X-Powered-By header
app.disable('x-powered-by');
// Add advanced security headers
app.use((req, res, next) => {
res.setHeader('Cross-Origin-Embedder-Policy', 'require-corp');
res.setHeader('Cross-Origin-Opener-Policy', 'same-origin');
res.setHeader('Cross-Origin-Resource-Policy', 'same-origin');
res.setHeader('X-Permitted-Cross-Domain-Policies', 'none');
res.setHeader('X-Download-Options', 'noopen');
res.setHeader('X-DNS-Prefetch-Control', 'off');
res.setHeader('Origin-Agent-Cluster', '?1');
res.setHeader('Upgrade-Insecure-Requests', '1');
// Remove any remaining disclosure headers
res.removeHeader('X-Runtime');
res.removeHeader('X-Version');
next();
});Testing and Verification#
After deploying these headers, verify they are being sent correctly and that cross-origin isolation is active. Use multiple methods to ensure nothing was missed.
Browser Developer Tools
Open DevTools (F12), go to the Network tab, and click on your main document request. The Response Headers section lists every header your server sends. Check that all the advanced headers are present and that no information disclosure headers remain.
For cross-origin isolation, open the Console tab and run self.crossOriginIsolated. If it returns true, isolation is active.
Command Line
# Check all cross-origin headers curl -sI https://your-site.com | grep -i "cross-origin" # Check for remaining disclosure headers curl -sI https://your-site.com | grep -iE "server|x-powered|x-aspnet|x-php|x-generator"
Automated Scanning
Use SiteSecurityScore to scan your website for all of these headers at once. The scanner checks for missing headers, incorrect values, and information disclosure headers, then provides specific recommendations for your configuration.
Best Practices#
Implementation Order
- 1Start with basic security headers (CSP, HSTS, X-Frame-Options)
- 2Remove information disclosure headers
- 3Implement cross-origin policies (test thoroughly first)
- 4Add remaining supporting and lifecycle headers
Testing Strategy
- Test in a staging environment before deploying to production
- Verify headers with browser DevTools and curl
- Check that third-party scripts and embeds still load correctly
- Monitor for broken functionality after deploying cross-origin policies
Continue reading
Ready to Secure Your Website?
Test your website's security headers and get detailed recommendations for improvement.