Use this when adding browser security headers.
Security Headers
Security headers instruct browsers to apply protections: Content-Security-Policy, Strict-Transport-Security, X-Content-Type-Options: nosniff, Referrer-Policy, Permissions-Policy and frame-ancestors or X-Frame-Options.
1. Security headers harden browsers.
2. CSP, HSTS, nosniff, Referrer-Policy, Permissions-Policy, frame-ancestors (or X-Frame-Options).
3. Set at proxy or app.
4. Test after changes.
5. Don't rely on deprecated X-XSS-Protection.
response → headers → browser enforcement
Context & applicabilityCommon mistakes · platform/version boundaries
Operational reference
Fast context before you go deeper.
curl -sI https://example.comVerification & Troubleshooting
Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.
Use the operational verification above to establish the expected state.
Capture the concrete output, symptom, packet, log or counter before changing anything.
Step 1 Checking headers Verify boundary
curl -sI https://example.com
Expected: Strict-Transport-Security, Content-Security-Policy, X-Content-Type-Options: nosniff, Referrer-Policy, Permissions-Policy, and frame-ancestors in CSP (or X-Frame-Options). Use securityheaders.com or Mozilla Observatory for a graded report.
Step 2 Common mistakes Narrow the fault
- Headers set on some responses only.
Evidence · 1 on this Topic
Expected observations and documentation recipes are reference material. Record actual output, device identity, scope and time before claiming a verified result.
- Key headers: CSP, HSTS, X-Content-Type-Options, Referrer-Policy, frame-ancestors.
- Test before enforcing.
- Scan regularly.
curl -sI https://<site>— headers present- securityheaders.com-style check — grading
- Headers: CSP, HSTS, X-Content-Type-Options, Referrer-Policy, Permissions-Policy, frame-ancestors — set
ReferenceWhy it matters1 section · depth on demand
Recommended headers
| Header | Example value |
|---|---|
| Strict-Transport-Security | max-age=31536000; includeSubDomains |
| Content-Security-Policy | default-src 'self'; frame-ancestors 'none' |
| X-Content-Type-Options | nosniff |
| Referrer-Policy | strict-origin-when-cross-origin |
| Permissions-Policy | camera=(), microphone=(), geolocation=() |
X-Frame-Options is replaced by CSP frame-ancestors but is still useful for old browsers. Check with curl -I https://site or securityheaders.com.
ReferenceImportant terms & boundaries2 sections · depth on demand
Nginx example
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
add_header X-Content-Type-Options "nosniff" always;
add_header Referrer-Policy "strict-origin-when-cross-origin" always;
add_header Permissions-Policy "camera=(), microphone=(), geolocation=()" always;
add_header Content-Security-Policy "default-src 'self'; frame-ancestors 'none'" always;
Documented example, not captured output. add_header in a nested block replaces headers set at a higher level.
In depth
Security headers are HTTP response headers that instruct browsers to enable protections. They are cheap to add and mitigate several common attack classes.
| Header | Purpose | Example value |
|---|---|---|
| Strict-Transport-Security | HTTPS only | max-age=31536000; includeSubDomains |
| Content-Security-Policy | Restrict scripts and resources; frame-ancestors | default-src 'self'; frame-ancestors 'none' |
| X-Content-Type-Options | No MIME sniffing | nosniff |
| Referrer-Policy | Limit referrer leakage | strict-origin-when-cross-origin |
| Permissions-Policy | Disable browser features | camera=(), microphone=(), geolocation=() |
| Cross-Origin-Opener-Policy | Isolate browsing context | same-origin |
Set headers centrally on the reverse proxy or framework, and test with browser developer tools or online header scanners. X-XSS-Protection is obsolete — rely on CSP instead.
Additional reference context Scope · expected state · examples · history · terminology Open only when you need the supporting context
Verification history & basis
When and against what this Topic was checked. Later text edits do not count as a new check.
Authoritative/upstream documentation reviewed for bounded claims in Web Security → Security Headers. Documentation verification only; this is not observed lab or production Evidence.
Basis: https://owasp.org/www-project-application-security-verification-standard/ · confidence 94%