Inline event handler
Not run<button onclick="window.__handlerRan = true">Reported by script-src, still loads
Same policy, nothing blocked
This page sends the same policy as Content-Security-Policy-Report-Only. The markup below still attempts forbidden things; the browser allows them and files a violation report with this app's own endpoint using report-uri.
Content-Security-Policy-Report-Onlydefault-src 'self'; script-src 'self' 'nonce-YDI9VzAYXXcRgRBgPewC2g==' 'strict-dynamic' 'report-sample'; style-src 'self' 'unsafe-inline'; img-src 'self' data: blob:; connect-src 'self'; font-src 'self'; frame-src 'self'; object-src 'none'; base-uri 'none'; form-action 'self'; frame-ancestors 'none'; report-uri /api/csp-report
/api/csp-reportworks on HTTP and HTTPSFour elements are in the markup right now. The browser loaded them anyway and sent a violation report for each one.
picsum.photos is not in img-src.example.org is not in frame-src.<script>
window.__staticInlineScriptRan = true;
</script>script-srcnonce, no unsafe-inline, no execution.<script
src="https://code.jquery.com/jquery-3.7.1.min.js">
</script>script-srcstrict-dynamic trusts nonce-created scripts, not parser-inserted ones.Each button asks the browser to do something the policy disallows. Watch the feed on the right while the request fails.
<button onclick="window.__handlerRan = true">Reported by script-src, still loads
example.org/theme.cssReported by style-src, still loads
picsum.photos/seed/csp-run/320/200Reported by img-src, still loads
example.org/?from=csp-runReported by frame-src, still loads
api.github.com/zenReported by connect-src, still loads
nonce="YDI9VzAY…"Carries this response's nonce; expected to run
/api/csp-report (GET)Same origin; expected to pass
style="background:#096b50"Permitted by style-src's 'unsafe-inline'
The same violations are printed in the browser console. The feed reads them from the server, which is what makes the round trip visible.