Browser security workshop

CSP Report Only

Start with a page that still works while the browser records a policy violation. This workshop runs seven fixtures in three browser engines, then turns those observations into a CSP rollout checklist.

Executed workshop
21 cases: 7 fixtures in Chromium, Firefox and WebKit
Report-only result
The inline probe executes in all 3 tested engines and emits a report-disposition DOM event
Existing enforcement
A separate enforced policy still blocks the probe; report-only cannot relax it
Evidence boundary
Loopback HTTP and DOM events; reporting-endpoint delivery is not measured
A safety engineer records a theater rehearsal on a clipboard beside an amber warning lamp while another engineer holds a separate navy safety gate closed.
Conceptual illustration: observe a rehearsal while a separate boundary remains enforced.

The page works. That does not mean the policy passes.

CSP report only evaluates a candidate Content Security Policy without using that candidate to block a violating action. The enforced Content-Security-Policy header has a different job: its restrictions remain binding. A working page with a report-only warning can therefore be the expected result, not evidence that the browser ignored CSP.

Use report-only to learn which legitimate application behavior conflicts with a proposed policy. Keep the active enforced policy while testing a stricter candidate. The W3C CSP specification defines those dispositions separately. The MDN report-only reference describes the response header used for the candidate.

This is a browser workshop, not an account of a production incident. Its intentionally small page contains one inline probe. The runner observes whether that probe executes and what violation event appears. No customer data, application credentials or third-party scripts enter the fixture.

Read execution and violation disposition together

Seven fixtures ran in Chromium 151.0.7922.34, Firefox 153.0 and WebKit 26.5 through Playwright 1.62.1. The 21 assertion-backed cases produced byte-identical JSON on two runs. Each fixture starts in a fresh browser context and loads an owned 127.0.0.1 HTTP page.

For each of seven fixtures, three browser engines either execute or block one inline script. Report-only and loose enforcement with strict reporting execute in all three. Strict enforcement and the intersection of two enforced policies block in all three.
Actual inline-probe observations from the saved JSON. Counts are tested cases, not market share, security scores or performance. View full-size figure.
One inline probe across three tested engines per fixture
FixtureProbe executedProbe blockedDOM disposition
No policy30None
Strict report-only header30report
Strict enforced header03enforce
Loose enforced + strict report-only30report
Strict enforced + loose report-only03enforce
Two enforced headers03enforce
Report-only meta element30None

The report-only fixture emits a violation while the inline code runs. In the opposite direction, a loose report-only policy does not rescue code blocked by an enforced policy. The meta fixture executes the probe without a violation event because that delivery mechanism does not install a report-only policy.

These are DOM SecurityPolicyViolationEvent observations. The runner configures no reporting destination, so the chart says nothing about a report POST reaching a collector, a Reporting API queue flushing or an HTTPS endpoint being available. A console message, a DOM event and a received server report are separate observations.

Install the candidate in the document response

Schematic document response: active enforcement and a separately reported candidate
Content-Security-Policy: script-src 'self'; object-src 'none'; base-uri 'self'
Content-Security-Policy-Report-Only: script-src 'nonce-REPLACE_PER_RESPONSE'; object-src 'none'; base-uri 'self'; report-to csp-candidate
Reporting-Endpoints: csp-candidate="https://reports.example/csp"

This is a schematic response-header example, not a ready-made policy for an unknown application. Replace the endpoint with an owned HTTPS destination and generate the nonce correctly. The enforced script-src permits same-origin external scripts. The candidate asks what would happen under a nonce-based rule. Existing applications may need additional directives and an entirely different baseline.

Send the header on the final HTML document response. Adding it to a request or to an unrelated JavaScript asset does not install the document policy. Inspect the response after redirects and CDN processing. A successful origin configuration is insufficient if the edge strips, replaces or duplicates the field.

Content-Security-Policy-Report-Only is unsupported in a meta element. The workshop demonstrates that limit directly. An enforced CSP can use a meta element with restrictions, but that does not make meta interchangeable with response headers. In particular, the OWASP delivery guidance explains the limits around framing protections and reporting.

Two policies do not take turns winning

A final HTML response feeds an active enforced policy that can block actions and a candidate report-only policy that generates observations. Collector delivery is a separately configured path outside this fixture.
Conceptual rollout flow. The experiment exercises browser execution and DOM observations. The collector path requires separate verification. View full-size figure.

Treat an enforced policy and a report-only policy as independent evaluations. The candidate can record a violation even when active enforcement permits the action. When active enforcement rejects the action, a more permissive report-only candidate cannot authorize it. The two paired fixtures make that distinction visible.

Multiple enforced policies restrict the document together. In the two-header fixture, one header permits inline code and the other requires a nonce. The inline probe has no nonce and remains blocked in all three engines. Adding a permissive header is therefore a poor repair for an unexpected restriction introduced by another response layer.

Inspect every CSP field on the wire rather than only the configuration file you edited. Preserve which policy produced a finding during triage. A stale edge header and a new application header can both be valid syntax while expressing the wrong combined contract.

Identify the rule that actually applies

Fetch directives form specific fallback chains. For a script element, script-src-elem can take precedence, with script-src and then default-src supplying fallbacks where applicable. Inline event handlers have their own script-src-attr concern. The effectiveDirective in a violation can identify script-src-elem even when the delivered policy spells only script-src, as the saved observations show.

Map each required resource to its owner: connect-src for fetch or WebSocket destinations, img-src for images, font-src for fonts and frame-src for embedded documents. Styles need their own style directives. Do not add an analytics host to script-src when the rejected operation is a connection governed by connect-src.

Some controls need explicit treatment. Frame-ancestors limits who can embed the document, while frame-src concerns frames it loads. Base-uri and form-action do not inherit a default-src restriction. Object-src belongs in the review even when the application is not intentionally using plugins. The report-only header also ignores sandbox. A monitoring candidate is not a sandbox deployment.

The nonce in a lab is not a production nonce strategy

The fixture names one fixed nonce source solely to reject an inline script that has no matching nonce attribute. It does not generate or validate a production nonce. For a real nonce-based policy, generate an unpredictable value for each response and put the matching value only on scripts that the application deliberately authorizes.

Coordinate document generation and caching. Reusing a static nonce across responses, letting an attacker inject a matching attribute or serving a cached document with a mismatched header defeats the intended contract in different ways. A static deployment may instead use hashes for fixed inline code. Changing the bytes then requires updating the corresponding hash.

Strict-dynamic changes how trusted scripts can authorize further script loading in supporting browsers. Unsafe-inline and unsafe-eval are separate allowances with different consequences. Neither should be added automatically to silence a finding. Inline event handlers and runtime string evaluation can require application changes. This single-script lab does not certify those paths.

Configure delivery as a separate acceptance condition

The current Reporting API setup maps an endpoint name through the Reporting-Endpoints response header and references that name with the CSP report-to directive. The name is not a destination URL. MDN Reporting-Endpoints requires quoted endpoint URLs and notes that non-secure endpoints are ignored.

Report-uri is the older CSP-specific delivery directive. It is deprecated, but the current MDN report-only example declares it alongside report-to for browser coverage. Do not confuse the older Report-To response header with the report-to CSP directive or assume they are the same configuration object.

Choose compatibility from the browser versions your application actually supports. Reporting API delivery can be queued and batched. A page navigation or an immediately empty endpoint log does not establish that nothing happened. Test a deliberate violation against the actual HTTPS collector and inspect its received content type and body. Those delivery tests are outside our HTTP-only fixture.

Keep the two report envelopes distinct

Legacy report-uri requests commonly use application/csp-report with an object under the csp-report key. Fields include document-uri, blocked-uri, effective-directive and original-policy. Reporting API requests use application/reports+json and an array of reports, with a csp-violation type and a body containing names such as documentURL, blockedURL and effectiveDirective.

Abbreviated legacy envelope, illustrated rather than captured by the fixture
{
  "csp-report": {
    "effective-directive": "script-src-elem",
    "blocked-uri": "inline",
    "disposition": "report"
  }
}

This abbreviated JSON illustrates a legacy envelope. It is not a captured POST from this workshop. A collector must parse the envelope it actually accepts, then normalize useful fields without losing the original distinction. Do not feed an array into a parser that assumes one legacy object.

Disposition distinguishes observation from enforcement. Original policy, effective directive and the relevant document or route help assign the finding. Reporting API age describes report age rather than an authoritative incident timestamp. User agents and submitted payloads cannot prove who sent a report.

The collector receives untrusted input

Anyone who can reach a public reporting endpoint can try to submit fabricated data. A CSP report is telemetry, not an authenticated vulnerability finding or a command to modify an allowlist. The MDN report-uri reference explicitly treats violation reports as attacker-controlled input.

Apply bounded request size and rate limits before expensive processing. Validate accepted content types and envelope shapes, cap batch entries and field lengths, then encode stored values when presenting them in an analyst interface. Keep raw HTML or script samples out of rendering paths. Define what happens to malformed, oversized or unsupported submissions without reflecting them back into a page.

Separate ingestion availability from application availability. A failing collector should produce an operational signal, not make a customer transaction depend on synchronous report processing. The workshop provides no production collector implementation, rate-limit threshold or authentication design. Those controls need deployment-specific acceptance tests.

A report can contain more than a host name

Document and source URLs can carry private paths or query values. A report-sample allowance can include a sample of violating code for relevant script or style violations. Browser stripping rules reduce some cross-origin detail, but they do not make every field harmless. The legacy report reference describes why a blocked URL may be reduced to its origin.

Choose the minimum fields needed to assign a problem. Normalize routes, remove unnecessary query strings and avoid keeping code samples by default. Document retention and access controls for the resulting telemetry. The audit-log minimization guide covers the related question of which diagnostic detail deserves to be retained.

Do not publish a full report in an issue tracker before reviewing it. A synthetic fixture can safely demonstrate a payload shape. An actual report may disclose application state or user information that the visible error message never showed.

Turn findings into owned changes

Group observations by policy version, document route, effective directive and the relevant blocked-resource category. Add a release identifier from trusted ingestion context where possible. Keep counts as observations from a stated sample, not as a vulnerability severity score or a denominator-free percentage of users affected.

Check whether a report comes from a supported application journey, a browser extension or a stale document. Extension-related findings and duplicate submissions can add noise, but a familiar-looking source is not permission to discard every similar event. Reproduce a representative case and identify which delivered policy produced it.

For each legitimate dependency, decide whether to remove the dependency, refactor the code or grant a narrowly justified source. A submitted blocked URL must never become an automatic allowlist entry. Record the decision and its owner so the next release does not repeat the investigation.

Promote a tested policy, not an empty dashboard

Create an explicit journey inventory before starting observation: signed-in navigation, authentication callbacks, uploads and downloads, payment or support integrations where present, plus optional features that do not run on every visit. Test the actual response headers for each document type and supported browser group.

  1. Keep the current enforced policy and deploy a versioned candidate in report-only on a bounded cohort. Verify that the final response contains the intended pair.
  2. Trigger a deliberate known violation and verify both browser observation and collector receipt using the chosen delivery mechanism. Treat either missing side as an instrumentation problem.
  3. Exercise the agreed journeys, assign legitimate violations and verify remediations without broadening sources merely to reduce counts. Include cold, cached and redirected document paths.
  4. Promote the exact reviewed candidate to enforcement on a canary cohort. Monitor functional failures and retain a documented rollback to the previous reviewed policy before widening exposure.

There is no universal number of report-only days that proves readiness. Traffic mix, optional workflows and browser coverage determine what the observation period includes. Zero reports can mean a compatible policy, an unused path, a missing header or a broken collector. The release decision needs functional evidence and a working reporting path.

Trace a missing report from response to receiver

First inspect the final document response in the affected browser. Confirm the candidate header, reporting directive and endpoint-name mapping. Compare cached and fresh responses when an edge or deployment layer can retain an older version. The Vary header guide explains a separate cache-selection contract. CSP headers still need direct inspection.

Next produce a violation that the candidate is supposed to observe and inspect its DOM event or console evidence. Check effectiveDirective and disposition rather than assuming that any CSP message came from the new candidate. An absent DOM observation and an absent network receipt require different investigations.

Finally inspect endpoint reachability, HTTPS, accepted media type, batch parsing and delivery timing. A collector can receive a request and discard its body as the wrong format. CSP is also separate from CORS: changing response access rules is not a general fix for a document policy violation.

Run the workshop without contacting a reporting service

Download experiment.mjs and the saved results. Use an isolated directory with Playwright 1.62.1 and its installed Chromium, Firefox and WebKit browsers. The public runner uses Node HTTP, starts one ephemeral loopback server and closes its browsers and server when finished.

Isolated setup and execution for the downloadable browser fixture
npm init -y
npm install --save-exact playwright@1.62.1
npx playwright install chromium firefox webkit
node experiment.mjs > actual.json

Run those installation commands in a disposable workshop directory, not an existing application repository. Our executed runner used Node 24.20.0 and the already installed Playwright package, so it added no application dependency. Exact browser versions are saved in results.json. A different installed revision is a new observation, not a contradiction to hide.

The automation installs its event observer before page scripts. That observer runs outside the document policy solely to measure the page. The inline probe itself remains subject to CSP. The runner never injects a matching nonce into the probe. It sends no customer data and defines no collector URL, so there is no evidence here about real-world report delivery.

Keep application-security assurance in the release scope

A successful policy workshop does not establish that an application has no injection flaws. Output encoding, safe DOM APIs, sanitization where required and application-specific security tests remain necessary. CSP adds a browser boundary. Report-only by itself supplies observation rather than prevention.

If a release also needs an independent assessment, Pharos Production describes web application security testing and remediation retests covering web/API testing, a SAST/DAST CI baseline and gray-box review with reproduction and remediation follow-up. That service scope is useful for planning assurance beyond header checks. The page does not supply this workshop or certify its policy for a particular application.

Keep the resulting evidence separate: browser execution cases support the policy mechanism, journey tests support application compatibility and scoped security findings support remediation decisions. None of those artifacts makes an unread report collector trustworthy.

What the fixture leaves for your application

Nginx, Apache, Cloudflare and framework middleware can own response headers, but their configuration recipes are outside this page. React, Next.js, Helmet, Spring Security, Django and WordPress need version-specific integration work. Check where the final document is generated before choosing the layer that installs its policy.

Trusted Types, COOP, COEP, Permissions Policy and Integrity Policy have their own contracts. This workshop neither implements them nor measures a production XSS exploit, an extension ecosystem, cross-origin report transport or performance. Its narrow result is reproducible execution and DOM-event behavior for the saved browser revisions.

Before promotion, attach the exact policy version, final-header captures, journey results, one confirmed collector receipt and the rollback target to the release record. That gives the next engineer something concrete to verify when a browser update or new dependency changes the behavior.

Sources

Documentation checked .

  1. W3C Content Security Policy Level 3
  2. MDN report-only header
  3. MDN Content Security Policy guide
  4. MDN report-to directive
  5. MDN legacy report-uri payload
  6. MDN Reporting-Endpoints header
  7. SecurityPolicyViolationEvent fields
  8. OWASP Content Security Policy Cheat Sheet

Continue the conversation

Comments (0)

    Leave a comment

    Your name and comment stay in this page and are cleared after the spam check.

    10–2,000 characters. Keep the discussion relevant to this article.

    Spam protection verification
    Spam protection loads when you begin the form.

    JavaScript is required to use this form and its spam protection.