HTTP Security Headers
Also Known As
HTTP security headers
response security headers
TL;DR
A set of HTTP response headers that instruct browsers to enforce security policies, reducing XSS, clickjacking, and data leakage risks.
Explanation
Key security headers and their purpose: Content-Security-Policy (restricts resource loading, mitigates XSS), X-Frame-Options (prevents clickjacking — superseded by CSP frame-ancestors), X-Content-Type-Options: nosniff (prevents MIME-type sniffing), Referrer-Policy (controls referrer leakage), Permissions-Policy (restricts browser feature access), Strict-Transport-Security (enforces HTTPS), and Cross-Origin-Opener-Policy/Cross-Origin-Embedder-Policy (isolation for SharedArrayBuffer). Use securityheaders.com to audit. In PHP, emit all headers before output.
Common Misconception
✗ Setting security headers fully secures a site. Headers are a defence-in-depth layer — a misconfigured CSP, missing SameSite, or absent HSTS still leaves specific attack vectors open. They complement but do not replace proper application-level security.
Why It Matters
Security headers are a low-effort, high-impact defence layer — each header closes a distinct browser-exploitable attack vector with a single line of configuration.
Common Mistakes
- Not setting Content-Security-Policy — leaves XSS execution unrestricted even after injection.
- Omitting X-Content-Type-Options: nosniff — browsers may interpret uploaded files as executable.
- Setting X-Frame-Options instead of CSP frame-ancestors — the latter supersedes it in modern browsers.
- Using a permissive CSP like unsafe-inline or unsafe-eval which negates most of its protection.
Code Examples
✗ Vulnerable
// No security headers set — default browser behaviour
✓ Fixed
header('X-Content-Type-Options: nosniff');
header('X-Frame-Options: DENY');
header('Referrer-Policy: strict-origin-when-cross-origin');
header('Permissions-Policy: geolocation=(), microphone=()');
References
Tags
🤝 Adopt this term
£79/year · your link shown here
Added
15 Mar 2026
Edited
22 Mar 2026
Views
35
🤖 AI Guestbook educational data only
|
|
Last 30 days
Agents 0
No pings yet today
No pings yesterday
Amazonbot 8
Perplexity 7
Unknown AI 3
Ahrefs 2
SEMrush 2
Google 1
ChatGPT 1
Also referenced
How they use it
crawler 24
Related categories
⚡
DEV INTEL
Tools & Severity
🟡 Medium
⚙ Fix effort: Low
⚡ Quick Fix
Add these 5 headers to every PHP response: Strict-Transport-Security, X-Content-Type-Options: nosniff, X-Frame-Options: DENY, Referrer-Policy: strict-origin, Permissions-Policy
📦 Applies To
PHP 5.0+
web
🔍 Detection Hints
Missing security headers detected by securityheaders.com scan; MIME sniffing enabled no X-Content-Type-Options
Auto-detectable:
✓ Yes
securityheaders.com
owasp-zap
lighthouse
⚠ Related Problems
🤖 AI Agent
Confidence: High
False Positives: Low
✓ Auto-fixable
Fix: Low
Context: File
CWE-693
CWE-1021
CWE-116