Content Security Policy

CSP

An HTTP header naming the sources a page may load scripts and other content from, as a defense against injection attacks.


A Content Security Policy is a declarative allowlist, delivered as a response header, naming the origins a page may load scripts, styles, images, fonts, and other resources from. Its main job is limiting the damage of a cross-site scripting vulnerability: even if an attacker injects a script tag, the browser blocks scripts that the policy does not allow.

A report-only mode and a report-uri or report-to directive let a policy be rolled out and monitored. The browser sends a report of what it would have blocked before the policy is switched to enforcement. This is how a policy gets tightened without breaking the page it protects on the first attempt.