Headers Security
critical Severity
Free Check
Content Security Policy (CSP)
Restricts sources from which scripts, styles, and assets can load to prevent XSS and code injection.
Why It Matters
Cross-Site Scripting (XSS) allows attackers to steal user session cookies, log keystrokes, and execute unauthorized actions. A strict CSP provides essential defense-in-depth even if an input sanitization flaw exists.
How We Check This
We evaluate Content-Security-Policy headers for missing directives (default-src, script-src, object-src, frame-ancestors) and dangerous wildcards or 'unsafe-inline' tokens.
How to Fix & Implement
Copy-paste configuration blocks tailored for your web server or edge proxy.
nginx snippet
add_header Content-Security-Policy "default-src 'self'; script-src 'self' 'nonce-$request_id'; style-src 'self' 'unsafe-inline'; img-src 'self' data: https:; font-src 'self' data:; connect-src 'self' https:; frame-ancestors 'none'; base-uri 'self';" always;
Frequently Asked Questions
Why is unsafe-inline flagged in CSP?
Because it allows malicious scripts injected into DOM innerHTML or HTML attributes to run without restriction.