Configuring Content Security Policy (Part 4): Roll Out CSP Safely with Report-Only
Deploy CSP without breaking production. Learn Content-Security-Policy-Report-Only, Reporting-Endpoints, report-to, legacy report-uri, violation triage, sampling and staged enforcement.

The easiest way to make a team hate Content Security Policy is to deploy an aggressive enforcing header directly to production and discover that checkout, analytics or sign-in no longer works.
The second easiest way is to leave CSP in report-only mode forever because the reports are noisy and nobody knows what to do with them.
A good rollout sits between those extremes.
You use report-only mode to learn what the browser would block, turn that raw data into an intentional policy, enforce it gradually, and continue watching for regressions afterwards.
This is less glamorous than copying a “perfect CSP header” from a security blog. It is also how you deploy CSP on a real application without creating a self-inflicted outage.
The two CSP headers do different jobs
An enforcing policy is sent with:
Content-Security-Policy: ...
The browser blocks behaviour that violates it.
A monitoring policy is sent with:
Content-Security-Policy-Report-Only: ...
The browser does not block the violating resource or behaviour, but it can report what would have happened under enforcement.
That gives you a safe experiment.
For example:
Content-Security-Policy-Report-Only:
default-src 'none';
script-src 'self';
style-src 'self';
img-src 'self';
connect-src 'self'
If your production application also calls https://api.example.com, the request continues working, but you receive a violation showing that your proposed connect-src would have blocked it.
Report-only does not make a weak policy useful
A common mistake is to generate an enormous stream of reports from a policy nobody intends to enforce.
For example:
Content-Security-Policy-Report-Only: default-src 'none'
on a complex production application may report almost every resource on every page.
That is technically informative but operationally useless.
Start from the policy you actually want to deploy.
If the target is a strict nonce-based script policy, test that model in report-only mode rather than testing an unrelated deny-everything policy and hoping the results somehow turn into a strict CSP later.
Modern reporting uses Reporting-Endpoints and report-to
The current standards-based pattern is:
Reporting-Endpoints: csp="https://reports.example.com/csp"
and then:
Content-Security-Policy-Report-Only:
default-src 'self';
report-to csp
The endpoint name csp connects the policy to the URL declared in Reporting-Endpoints.
Browsers can then send CSP violation reports through the Reporting API.
As of 2026, report-to has much better modern-browser support than it did a few years ago, but compatibility across older browsers still matters for some audiences.
Why you may still see report-uri
Older CSP implementations use:
report-uri https://reports.example.com/csp
report-uri is deprecated in CSP Level 3 in favour of report-to, but MDN and the CSP specification still recommend declaring both when you need broader compatibility.
For example:
Reporting-Endpoints: csp="https://reports.example.com/csp"
Content-Security-Policy-Report-Only:
default-src 'self';
script-src 'self';
report-uri https://reports.example.com/csp;
report-to csp
Browsers that support report-to use it and ignore report-uri for that policy; older clients may fall back to the legacy mechanism.
Do not copy the old Report-To response header into new implementations unless you specifically need compatibility with clients that still rely on it. Reporting-Endpoints is the current replacement.
Report-only must be an HTTP response header
You cannot do this:
<meta http-equiv="Content-Security-Policy-Report-Only" ...>
Report-only CSP is not supported through a meta element.
It must be delivered as an HTTP response header.
That means CSP rollout often involves your application server, reverse proxy, CDN or hosting platform rather than only frontend HTML.
You can run enforcement and report-only at the same time
This is one of the most useful CSP deployment techniques.
Suppose production currently enforces a conservative policy:
Content-Security-Policy:
default-src 'self';
script-src 'self' https://legacy-cdn.example.com
You want to move toward strict CSP:
Content-Security-Policy-Report-Only:
script-src 'nonce-{NONCE}' 'strict-dynamic';
object-src 'none';
base-uri 'none';
report-to csp
Both can be present.
The first policy continues protecting the application today.
The second tests tomorrow’s stricter policy and generates telemetry.
That is far safer than weakening the current policy while experimenting.
What a violation report tells you
Modern Reporting API CSP reports can contain fields such as:
- the page URL;
- blocked resource URL or type;
- effective directive;
- source file;
- line/column information;
- original policy;
- disposition (
enforceorreport); - HTTP status;
- optional script/style sample information.
A legacy report-uri payload uses a somewhat different JSON structure, often under a csp-report object.
Your ingestion service should therefore be prepared for the reporting mechanism you actually support.
Do not build parsing logic around one browser’s exact sample payload and assume every report will be identical forever.
The most useful field is often effective-directive
Suppose you receive:
effective-directive: connect-src
blocked URL: https://api.partner.example/v2/orders
That immediately tells you what class of browser behaviour needs investigation.
Compare that with staring at a 900-character CSP and wondering which rule applies.
Useful triage categories include:
script-src-elem -> script element blocked
script-src-attr -> inline event handler blocked
style-src-elem -> stylesheet/style element blocked
connect-src -> fetch/XHR/WebSocket/beacon blocked
img-src -> image/favicons blocked
font-src -> font blocked
frame-src -> embedded frame blocked
worker-src -> worker/service worker blocked
form-action -> form submission target blocked
frame-ancestors -> page embedding attempt blocked
Group reports by effective directive before looking at individual URLs.
Add 'report-sample' carefully
For script/style directives, CSP supports the 'report-sample' source expression.
For example:
script-src 'nonce-{NONCE}' 'strict-dynamic' 'report-sample'
When an inline script/style/handler is blocked, the report may include a short sample of the offending content.
That can make debugging far easier:
blocked inline script
sample: "document.querySelector('#buy').onclick..."
instead of:
blocked inline script
sample: [nothing]
But remember that reports leave the browser and arrive at your reporting endpoint.
Treat samples as potentially sensitive telemetry. Do not casually retain them forever or forward them into every analytics system.
CSP reports are untrusted input
Your reporting endpoint is public.
Anyone can send requests to it.
Do not trust report fields simply because the payload looks browser-generated.
Treat them like any other internet-facing input:
- validate payload size;
- limit request body size;
- rate-limit sensibly;
- sanitise before rendering in an admin UI;
- avoid executing or interpolating report content unsafely;
- authenticate access to dashboards;
- consider abuse/DoS scenarios.
It would be painfully ironic to create an XSS vulnerability in the dashboard used to investigate CSP violations.
Do not page somebody for every violation
CSP report volume can be huge.
Violations may come from:
- real application code;
- browser extensions injecting scripts;
- password managers;
- corporate security software;
- antivirus products;
- stale service workers;
- old cached application versions;
- user scripts;
- malware on a client’s machine;
- scanners;
- genuine attacks.
A CSP report is not automatically a security incident.
It is an observation.
Your reporting system should aggregate, classify and trend rather than treating each POST as an emergency.
Build useful aggregation keys
Instead of storing 500,000 near-identical reports and reading them one by one, group on fields such as:
effective directive
blocked origin / URL pattern
document route
source file
policy version
browser family
release version
For example:
connect-src | api.partner.example | /checkout | 12,481 reports
is actionable.
Twelve thousand individual JSON files are not.
Version your CSP rollout
When you change the proposed policy, you need to know which reports relate to which version.
You can track this outside the policy using deployment metadata, response headers, endpoint query parameters, report infrastructure or application release IDs.
For example:
App release: 2026.08.31.4
CSP draft: strict-v3
If violations spike immediately after strict-v3, you can correlate the change.
Without versioning, your report store becomes a mixture of old and new policy behaviour.
Separate application violations from extension noise
Browser extensions are notorious for producing CSP noise because they inject content into pages.
Clues include:
- unusual
chrome-extension://URLs; moz-extension://URLs;- script sources that never appear in your application code;
- violations affecting only a tiny browser subset;
- report patterns tied to known extensions.
Do not weaken production CSP to make a browser extension happy.
The extension operates in its own trust model and may generate noise that your application cannot or should not accommodate.
Watch for route-specific dependencies
Testing only / is not enough.
Your homepage may need:
self + analytics
while checkout needs:
payment iframe
fraud-detection script
address API
payment API
and the dashboard needs:
WebSocket
chart assets
blob worker
Aggregate by document route.
If a violation appears only on /billing/setup, reproduce that flow rather than adding the source globally to every page’s policy immediately.
Route-specific policies are possible, although operational complexity should be weighed carefully.
Validate the public response during rollout
Report-only telemetry tells you what browsers see at runtime. SiteTidy can complement that by checking whether the expected CSP and other security headers are actually present on the public response after CDN and proxy processing.
A staged rollout that works
A practical production deployment can use several stages.
Stage 1: local enforcement
Use an enforcing CSP locally while actively developing the policy.
Breaking your local page is useful because failures are obvious and immediate.
Fix:
- inline handlers;
- missing nonces;
- unexpected external resources;
- blocked API/WebSocket origins;
- framework incompatibilities.
Stage 2: staging enforcement
Deploy the real enforcing policy to a production-like staging environment.
Exercise full workflows:
- login;
- logout;
- password reset;
- checkout;
- file uploads;
- admin pages;
- dashboards;
- payment/authentication widgets;
- browser workers;
- error pages.
CSP bugs often hide in infrequently visited routes.
Stage 3: production report-only
Send the proposed policy with:
Content-Security-Policy-Report-Only
Collect real-world violations without blocking users.
Run long enough to observe meaningful traffic cycles.
For some applications, a few hours is enough. For low-frequency workflows, you may need days.
Stage 4: limited enforcement
If your delivery architecture allows it, enforce for:
- internal staff;
- a canary environment;
- a small percentage of traffic;
- selected routes first.
Observe business and technical metrics.
Stage 5: full enforcement
Once the policy is stable, deploy:
Content-Security-Policy: ...
Keep reporting enabled so newly introduced violations do not become invisible.
Do not wait for literally zero reports
You may never reach zero.
The goal is zero unexplained application violations, not zero internet noise.
Before enforcement, you should be able to classify recurring patterns into categories such as:
valid application dependency -> policy/code adjusted
obsolete application behaviour -> code removed
browser extension noise -> ignored/filter
scanner/malware noise -> monitor/filter
attack-like activity -> security investigation
unknown -> investigate before enforcement
Unknown high-volume violations on critical routes are a reason to delay enforcement.
One strange extension report from a single browser is not.
Don’t automatically allow every blocked origin
This is the single worst way to tune CSP.
A report says:
blocked: https://random-cdn.example.com/script.js
Before adding the origin, ask:
- Which feature tried to load it?
- Is that feature intentional?
- Which first-party or third-party script initiated it?
- Is this source stable/documented by the vendor?
- Can strict nonce/hash trust avoid needing the host allowlist?
- Could the functionality be removed?
CSP reports are evidence about behaviour, not auto-generated firewall tickets.
Use business metrics during enforcement
Technical telemetry can look clean while a business flow is broken.
During CSP rollout, watch things such as:
- login success rate;
- checkout completion;
- payment authorisation;
- account signup;
- form submission;
- JavaScript error rate;
- API error rate;
- page-view tracking if analytics matters.
If checkout completion falls 20% after enforcement, a quiet CSP report dashboard is not proof that the rollout succeeded.
Report endpoint reliability matters, but it is not in the critical path
CSP reporting is asynchronous telemetry.
Your site should not depend on the reporting endpoint being healthy to render the page.
If the endpoint is unavailable, reports may be lost or retried according to browser/reporting behaviour, but application traffic should continue.
Design the reporting service for ingestion, not for user-facing latency.
Protect privacy in report storage
Violation reports can contain URLs, referrers, source locations and samples.
Depending on your routing and query-string design, those fields could contain sensitive values.
Before storing reports:
- remove unnecessary query strings;
- redact tokens/IDs where appropriate;
- avoid logging full sensitive URLs;
- define retention;
- limit who can access raw reports.
Security telemetry is still data governance.
Client-side securitypolicyviolation events
Browsers also expose a securitypolicyviolation event.
You can observe violations in the page:
document.addEventListener('securitypolicyviolation', (event) => {
console.log(event.effectiveDirective);
console.log(event.blockedURI);
});
This can be useful for local debugging, automated tests or targeted client telemetry.
Do not rely on client JavaScript as your only reporting path for script-blocking problems — the very JavaScript you expect to run may be what CSP blocked.
Server-side Reporting API ingestion is the more robust foundation for production monitoring.
Test CSP in automated browser journeys
Add CSP-sensitive flows to your E2E suite.
For example, your Playwright/Cypress tests can fail on unexpected browser console CSP violations during critical journeys.
Conceptually:
run checkout journey
│
├── assert payment frame loads
├── assert API calls succeed
├── collect console messages
└── fail on unexpected CSP violations
This prevents a future dependency change from reintroducing CSP breakage silently.
Include error pages and redirects
Production errors often bypass the normal application rendering pipeline.
A reverse proxy may generate a 502 page without your CSP.
An authentication callback may be served by a different component.
A CDN error response may have a completely different header set.
During rollout, inspect:
- 200 pages;
- redirects;
- 404s;
- 500s;
- maintenance pages;
- auth callbacks;
- edge-generated errors.
Security-header consistency is easier to fix before an incident.
Promote the policy like application code
Version it, test it, observe it, canary it and have a rollback path. CSP is executable browser policy. Treating a header change as “just config” is how security changes become production incidents.
Browse SiteTidy's security toolsA practical report pipeline
For a busy site, think of CSP reporting as a small telemetry pipeline:
Browser
│
▼
Reporting endpoint
│
├── validate / size limit
├── redact sensitive fields
├── normalise legacy + modern formats
└── enqueue
│
▼
Aggregator
│
├── group by directive/origin/route
├── suppress known extension noise
├── attach app/CSP version
└── calculate trends
│
▼
Dashboard / alerts
You do not need this architecture for a site receiving 100 page views per day.
At larger scale, it prevents CSP reporting itself becoming the operational problem.
Enforcement rollback plan
Before switching enforcement on, decide how to switch it off or back to the previous version.
Possible controls:
- configuration flag;
- CDN header rule version;
- application config rollback;
- deployment rollback;
- feature flag around strict policy.
Do not rely on editing production files manually under pressure.
A security control that can break JavaScript, forms and network calls deserves a controlled rollback path.
A final pre-enforcement checklist
Before full rollout, you should be able to answer yes to these:
[ ] Critical user journeys tested under enforcement
[ ] Production report-only data reviewed
[ ] Recurring violations classified
[ ] Nonce/hash strategy verified
[ ] Third-party script behaviour understood
[ ] API/WebSocket/frame/form origins confirmed
[ ] Browser-extension noise separated
[ ] Business metrics ready for rollout observation
[ ] Reporting endpoint handles untrusted input safely
[ ] CSP version can be rolled back quickly
[ ] Public response verified after proxy/CDN
If several are unknown, keep learning in report-only mode.
Final thought
Report-only is not a weaker version of CSP.
It is the deployment instrument that lets you build a strong version safely.
Use it to answer one question before the browser starts blocking users:
“What would this policy break, and is that behaviour something we actually want to allow?”
Once every important violation has an answer, enforcement stops being a gamble.
In Part 5, we will deal with the messiest real-world CSP problem: third-party JavaScript — analytics, tag managers, payment widgets, chat, consent platforms and all the scripts that load more scripts behind your back.
