CSPRules
Reference

Directives and source values

Commonly used directives, their fallback order, and the scope of each source expression. Definitions follow CSP Level 3.1 Browser support per directive is listed by MDN.2

Directives

DirectiveControlsFalls back toTypical value
default-srcFallback for the fetch directives belownone'self'
script-srcJavaScript files, inline scripts, evaldefault-srcNonces or hashes. No 'unsafe-*'6
script-src-elem<script> elements onlyscript-srcUsually unset
connect-srcfetch, XHR, WebSocket, sendBeacon, EventSourcedefault-srcAPIs the page calls
img-srcImages, faviconsdefault-src'self' data: and image CDNs
style-srcStylesheets and inline stylesdefault-src'self'
frame-srcIframes your page embedschild-src, then default-srcPayment and media providers
object-src<object> and <embed> pluginsdefault-src'none'
base-uriThe <base> elementno fallback'self' or 'none'
form-actionWhere forms may submitno fallback'self'
frame-ancestorsWho may embed your page (clickjacking)no fallback'self' or 'none'
report-toReporting endpoint name, defined in Reporting-Endpoints4n/aSet
upgrade-insecure-requestsRewrites http:// requests to https://n/aSet

Source values

ValueAllowsRisk
'self'The document's originLOW
'none'NothingLOW
'nonce-…' / 'sha256-…'Elements carrying the nonce, or scripts matching the hashLOW
https://cdn.vendor.comAny resource the host serves, including JSONP endpoints and old library versions5VENDOR-DEPENDENT
*.vendor.comEvery subdomain, including unreviewed onesMEDIUM
'strict-dynamic'Any script a trusted script inserts. Host entries are ignored.1MEDIUM
'unsafe-eval'eval(), new Function(), string timersHIGH
'unsafe-inline'Any inline script or event handler. Ignored when a nonce or hash is present.3HIGH
https: / *Any hostHIGH
data: in script-srcScripts built from data URLsHIGH

Risk ratings follow the OWASP CSP Cheat Sheet and Google's strict CSP guidance.7,6

References

  1. [1]
    Content Security Policy Level 3. W3C, Web Application Security Working Group. Working Draft. The normative definition of directives, source matching and fallback.
  2. [2]
    Content-Security-Policy header reference. MDN Web Docs. Per-directive browser compatibility tables.
  3. [3]
    CSP: script-src. MDN Web Docs.
  4. [4]
  5. [5]
    CSP Is Dead, Long Live CSP! On the Insecurity of Whitelists and the Future of Content Security Policy. Weichselbaum, Spagnuolo, Lekies, Janc. ACM CCS, 2016. Analysis of 26,011 unique policies from 1,680,867 hosts.
  6. [6]
  7. [7]
    Content Security Policy Cheat Sheet. OWASP Cheat Sheet Series.