Skip to content
Web Security

What is Content Security Policy?

An HTTP response header that whitelists exactly which origins may supply scripts, styles, and frames. A tight policy neuters injected payloads even after an XSS bug ships.

Example

A BYOB marketing site allows scripts from its own origin plus one analytics domain and blocks everything else. When a third-party widget injects an inline snippet, browsers refuse it and file a violation report instead of running unknown code.

What people get wrong

Deploying report-only mode forever and calling the job done. Reports without enforcement train nobody; graduate tested policies to blocking once the noise settles.

Sources

Browse all Web Security terms →