X-XSS-Protection and Legacy Headers
You'll learn why the X-XSS-Protection header exists, how it worked, and why it's now considered obsolete compared to modern Content Security Policy.
What Was X-XSS-Protection?
The X-XSS-Protection header was introduced by Internet Explorer 8 back in 2008 as a browser-level defense against reflected XSS attacks. It instructed browsers to detect dangerous scripts in URL parameters or form submissions and either block the page or sanitize the malicious content before rendering.
Think of it like an old security guard who tried to stop obvious threats at the door—helpful in its time, but not very sophisticated.
Common Values
X-XSS-Protection: 0— Disable the filter entirelyX-XSS-Protection: 1— Enable filter, sanitize detected attacksX-XSS-Protection: 1; mode=block— Enable filter, block entire page if attack detected
Why It Failed
Browser XSS filters had major limitations:
- False positives — Legitimate code was sometimes blocked, breaking functionality
- Incomplete protection — Only caught reflected XSS, ignored stored and DOM-based attacks
- Bypassable — Attackers crafted polyglot payloads that evaded detection
- Introduced new vulnerabilities — Ironically, the filter itself could sometimes be manipulated to create XSS conditions
Modern Approach: CSP Instead
Today, all major browsers have deprecated or removed XSS filters. Chrome, Firefox, and Edge no longer support X-XSS-Protection because Content Security Policy provides far more granular, reliable protection without the side effects.
Rather than trying to detect attacks, CSP prevents malicious code from executing at all by controlling what resources can load and where scripts can run.
Key Takeaway: X-XSS-Protection is a deprecated legacy header; modern applications should rely on strict Content Security Policy instead of browser XSS filters for robust XSS defense.