Analyzing CSP Violation Reports
You'll learn how to decode CSP violation reports so you can quickly identify which resources are breaking your policy and fix them.
What Are Violation Reports?
When you've set up report-uri or report-to directives, browsers send JSON reports whenever something violates your Content Security Policy. Think of these reports as security incident logs—each one tells you exactly what happened when a resource tried to load but was blocked (or would have been blocked in report-only mode).
Report Structure
A typical CSP violation report contains several key fields:
document-uri: The page where the violation occurredviolated-directive: Which CSP rule was broken (e.g.,script-src)blocked-uri: The resource that tried to loadsource-file: Where the violating code originatedline-numberandcolumn-number: Exact location in the source filedisposition: Whether it was "enforce" or "report" mode
Reading the Tea Leaves
When analyzing reports, focus on patterns:
{
"violated-directive": "script-src 'self'",
"blocked-uri": "https://evil-ads.example.com/inject.js",
"document-uri": "https://yoursite.com/checkout"
}
This tells you: an external script from evil-ads.example.com tried to run on your checkout page but was blocked because your policy only allows scripts from 'self'.
Common Scenarios
- Browser extensions: Look for
chrome-extension://ormoz-extension://URIs—often false positives - Inline scripts without nonces: Shows
inlineas the blocked resource - Third-party widgets: CDN URLs you may have forgotten to whitelist
Key Takeaway: CSP violation reports are structured JSON logs that pinpoint the exact directive, resource, and location of policy violations—analyze the violated-directive and blocked-uri fields first to identify problematic resources quickly.