tools / HTTP reference / content-security-policy (csp) header
HTTP · W3C CSP3, RFC 7762 (header)

Content-Security-Policy header

CSP tells browsers which sources are allowed for scripts, styles, frames, fonts, and other resources. Defense against XSS and clickjacking. Misconfigured = legit resources blocked OR XSS still possible.

advanced W3C CSP3, RFC 7762 (header)

What the RFC says

A server may set a Content-Security-Policy header field to a CSP, which is a list of policy directives that define the security policy for a particular protected resource. (CSP3 §3.1) — W3C CSP3, RFC 7762 (header)

Example

Content-Security-Policy:
  default-src 'self';
  script-src 'self' https://cdn.example.com 'nonce-{random}';
  style-src 'self' https://fonts.googleapis.com;
  font-src 'self' https://fonts.gstatic.com;
  img-src 'self' data: https:;
  connect-src 'self' https://api.example.com;
  frame-ancestors 'none';
  upgrade-insecure-requests;

Real-world implementations

Common misuses (don't do this)

Use cases

Get the RFC reference for any HTTP response
httpwut takes a curl response and explains the status code + headers + the RFC sections you should actually read. Built for HTTP debugging that goes deeper than 'lol 500'.
Open httpwut  

Related HTTP topics

401 vs 403: which one to return · 401 vs 403: which one to return · 401 vs 403: which one to return · 401 vs 403: which one to return