HTTP security header
Content-Security-Policy
The Content-Security-Policy (CSP) header lets a site declare approved sources for scripts, styles, images, and other content. A strict CSP is a powerful defense-in-depth measure against cross-site scripting: even if an attacker injects markup, the browser refuses to execute disallowed scripts. CSP mitigates impact but does not replace correct output encoding.
Example
Content-Security-Policy: default-src 'self'; script-src 'self'; object-src 'none'; base-uri 'none'Configuration guidance
- Prefer a strict, nonce- or hash-based policy over allowlisting hosts.
- Avoid 'unsafe-inline' and 'unsafe-eval', which defeat much of CSP's value.
- Set object-src 'none' and base-uri 'none' to close common bypasses.
- Roll out with Content-Security-Policy-Report-Only first to catch breakage.
Helps mitigate
Related headers
Impactr checks security-header configuration as part of testing your web apps and APIs the way an attacker would - and proves what a missing header actually exposes.
Test my app