Content Security Policy header is present
Why it matters
Without a Content Security Policy, browsers trust every script origin a page loads — including any injected by XSS. An attacker who finds a single injection point can exfiltrate session cookies, rewrite page content, or silently redirect users, because there is no browser-enforced allowlist to stop arbitrary script execution. OWASP A03 (Injection) and CWE-79 (Cross-Site Scripting) both identify missing CSP as a failure to implement available defenses. A Content-Security-Policy-Report-Only header monitors but enforces nothing — it does not satisfy this check. Even a minimal CSP with default-src 'self' eliminates an entire class of exfiltration attacks by blocking off-origin resource loads.
Severity rationale
High because the absence of an enforcing CSP leaves XSS attacks completely unrestricted — any injection vulnerability directly enables session hijacking, credential theft, or defacement.
Remediation
Add an enforcing Content-Security-Policy header to your HTTP responses. Start with a restrictive baseline and loosen only what your app needs:
Content-Security-Policy: default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'; img-src 'self' data:
In Next.js next.config.js, add to the headers() array:
{ key: 'Content-Security-Policy', value: "default-src 'self'; script-src 'self'" }
Test your policy with the CSP Evaluator at https://csp-evaluator.withgoogle.com/ before enforcing. Start in Report-Only mode if you have existing third-party scripts — collect violations, then promote to enforcing.
DetectionPro
The detection method for this pattern is part of AuditBuffet Pro.
The full method (what to look for, pass and fail conditions, and how results get reported) ships inside the Site Health Check audit. The pattern definition, severity rationale, and remediation remain openly licensed under CC-BY-4.0.
External references
- cwe · CWE-79 — Improper Neutralization of Input During Web Page Generation (XSS)
- owasp:2021 · A03 — Injection
Taxons
History
- 2026-04-18·v1.0.0·Initial import from site-health-check·automated
- 2026-04-20·v1.1.0·Add Phase 6.0 detect-curl snippet for deterministic CSP header probe·by cakleinman