Content Security Policy (CSP) only becomes useful for monitoring once violation reports reach somewhere you can read them. This guide covers how to set up reporting endpoints for CSP violation monitoring: the difference between the old and new reporting mechanisms, what a report actually contains, and how to filter out the noise so the reports that matter don’t get buried. It’s written for developers and security engineers who have deployed a policy, or are about to, and want to see what it blocks in production.
Without a reporting endpoint, a CSP fails silently. The browser blocks a script, logs a line in the console of a visitor you will never talk to, and nobody on your team finds out.
How CSP Reporting Endpoints Work Today
Browsers can deliver CSP reports in two ways. The legacy report-uri directive sends one POST request per violation with the content type application/csp-report. The body is a JSON object wrapped in a “csp-report” key. It is formally deprecated, but every major browser still honors it.
The newer approach uses the Reporting API. You declare a named endpoint with the Reporting-Endpoints response header, for example Reporting-Endpoints: csp=”https://example.com/csp-reports”. You then point to that name with report-to csp inside the policy. Chromium-based browsers have supported this form since version 96. Reports arrive batched as a JSON array with the content type application/reports+json, and each entry has a type of “csp-violation”.
There is also an older Report-To header that uses a JSON group syntax. Some guides still recommend it. It is superseded, so don’t build anything new on it.
Browser support is still uneven, so the practical setup is to send both. A policy ending in report-uri https://example.com/csp-reports; report-to csp covers every browser. Browsers that understand report-to ignore report-uri when both are present, so you won’t receive duplicates from the same client.
What a Violation Report Actually Tells You
A Reporting API report body contains documentURL, blockedURL, effectiveDirective, disposition (“enforce” or “report”), statusCode, and, when available, sourceFile, lineNumber, and columnNumber. If you add ‘report-sample’ to script-src or style-src, the browser also includes the first 40 characters of the inline script or style that was blocked.
The sample matters more than most teams expect. A blockedURL of “inline” tells you almost nothing. Forty characters of the offending code, however, usually show straight away whether you are looking at a forgotten analytics snippet or an injected skimmer loader.
Setting Up Report-Only Monitoring Step by Step
An experienced application security engineer never starts with an enforcing policy on a live site. The usual sequence looks like this:
1. Deploy the policy in a Content-Security-Policy-Report-Only header so nothing breaks, and point both reporting mechanisms at a dedicated endpoint.
2. Collect reports for at least 7-14 days so that weekly jobs, marketing campaigns, and rarely used pages all show up.
3. Group reports by effectiveDirective and blockedURL host, then decide for each group whether to allow it or remove it.
4. Switch to an enforcing header but keep reporting enabled, because the endpoint now becomes your detection signal.
5. Change the policy only together with code changes, and review report volume for 48 hours after every release.
Building the policy itself is a separate topic, covered in our guide on implementing Content Security Policy correctly. This article focuses on what happens to the reports once the policy is live.
The endpoint must be served over HTTPS. If it is on a different origin from the site, it must also answer a CORS preflight, because application/reports+json is not a “simple” content type. Teams often host collectors on a separate subdomain and then wonder why Chrome reports never arrive while Firefox’s report-uri posts come in fine. A missing OPTIONS handler is the usual culprit.
A Realistic Scenario: The Report That Mattered
Picture a mid-sized online store with about 150,000 daily pageviews. Its enforcing CSP has a report endpoint that receives roughly 20,000 reports a day, almost all of them from browser extensions. Nobody reads them anymore.
On a Tuesday, a compromised tag manager container starts injecting a script from an unfamiliar domain, but only on the checkout path. The policy blocks it for most visitors. The 300 new reports a day with a novel blockedURL on /checkout/ are simply lost among the 20,000 extension reports. Three weeks later, the payment processor asks questions.
The data was there the whole time, but nothing was alerting on it. This pattern is common in formjacking campaigns that target checkout pages. It is also why PCI DSS 4.0 requirements 6.4.3 and 11.6.1 have pushed payment-page script monitoring into audit scope since March 31, 2025.
Common Mistakes With CSP Violation Monitoring
Storing everything and alerting on nothing. A raw dump of reports in a database is not monitoring. Alerting should fire when a new blockedURL host appears, not when total volume crosses a fixed number. Volume spikes usually reflect traffic. New hosts reflect change.
Not filtering extension noise. Reports where the sourceFile or blockedURL starts with chrome-extension://, moz-extension://, or safari-web-extension:// almost never come from your code. Drop them at ingestion, and log the count only if you need it for capacity planning.
Leaving the endpoint unprotected. A reporting endpoint is a public, unauthenticated POST target. Attackers and broken bots can flood it with fabricated reports to hide real signals or fill your disk. Cap the payload size at around 64 KB, rate-limit per client IP, and apply the same thinking as for any rate-limited public API. Treat every field as untrusted input. Rendering blockedURL unescaped in an internal dashboard is a stored XSS waiting to happen.
Myth: Report-Only Mode Is Just a Testing Phase
Many teams treat Report-Only as training wheels that come off once the policy enforces. In practice, running two headers in parallel is one of the most useful long-term setups. Keep the enforcing policy you trust, and add a stricter Report-Only policy, such as one with strict-dynamic and nonces, that you are working toward.
The browser evaluates both independently. You get real production data on the stricter policy without risking breakage. This matters most on large legacy apps, where moving from allowlists to nonces can take 6-12 months.
There are exceptions. On sites with strict data-minimization rules, such as healthcare portals and some public-sector services in the EU, documentURL can contain query strings with personal data, which makes reports personal data under GDPR. Strip query strings at ingestion, or set a short retention period of 30 days or less.
FAQ
Do I need a third-party service to collect CSP reports?
No. A small HTTPS handler that accepts both content types, validates the JSON, and writes to your logging pipeline is enough. Hosted collectors like report-uri.com or Sentry’s CSP ingestion save time on parsing, deduplication, and dashboards, but they are optional.
Why do Chrome reports arrive late or in bursts?
The Reporting API queues reports and delivers them in batches, often with a delay of up to a minute. If the user closes the tab before delivery, some reports may never arrive. Use report-uri alongside report-to if you need closer to real-time delivery.
Can CSP reports detect an active compromise?
They can flag injected scripts, unexpected connect-src destinations, and data exfiltration attempts that the policy blocks. They cannot see anything the policy allows. That is why allowlisting an entire CDN or tag manager domain weakens both protection and detection.
Turning Reports Into a Detection Signal
A CSP reporting endpoint works only when it is configured correctly and someone acts on what it collects. Send both report-uri and report-to, answer CORS preflights, and filter extension noise at ingestion. Alert on new hosts rather than on volume, and keep a stricter Report-Only policy running alongside the enforcing one. Once the noise is filtered out, a report from your checkout page about a domain you’ve never seen should be treated as an incident, not a log line.
