THE TAKEAWAYS

What to take away

  • Start without enforcement: use Report-Only to collect real violations and build the allowlist.
  • Reports only arrive with report-to and a prepared endpoint, so set up the receiver first.
  • Base script control on nonces and decide up front not to fall back on unsafe-inline.
  • After enforcing, test every next version with Report-Only before applying it.

FROM PRIMARY SOURCES

Why CSP breaks pages

CSP is a set of instructions from a site to the browser restricting what the page may load and run.

It blocks not only injected attacker scripts but also any of your own tags that are not allowed, such as analytics, chat widgets, payment components and embeds.

According to MDN, once default-src or script-src is present, inline JavaScript does not run unless extra measures are taken.

So CSP is best treated as observing what actually loads and narrowing permissions, not as writing a perfect value once.

Sources: [1]

FROM PRIMARY SOURCES

Report-Only counts without blocking

MDN explains that CSP can be deployed in report-only mode: the policy is not enforced, but violations are sent to the reporting endpoint.

The Report-Only header supports all CSP directives except sandbox, so the observed policy can match the one you will enforce.

A report-only policy cannot be delivered in a meta element; it must be sent as a response header from the server, CDN or application.

If both headers are present in one response, both policies are honored: one is enforced, the other only reports.

Sources: [1][2]

FROM PRIMARY SOURCES

Prepare the reporting endpoint first

Reports are only sent when the report-to directive is specified; otherwise the header has no effect.

report-to names an endpoint defined in the Reporting-Endpoints header; MDN also shows declaring the older report-uri for compatibility.

Reports include page addresses, so decide storage permissions and retention, and keep the receiver from loading the main service.

Trigger a deliberate violation on a test page and confirm a record arrives before the observation period starts.

Sources: [2][1]

EDITORIAL PRACTICE

What to collect while observing

Observe long enough for all important pages to be used, including monthly billing pages and seasonal embeds.

Group reports by directive and blocked source, then sort them into intended, unused and suspicious.

Do not widen permissions just to silence reports; MDN says developers should avoid unsafe-inline because it defeats much of CSP's purpose.

Record who requested each allowed source and for which page, so the policy can be explained later.

Sources: [1]

FROM PRIMARY SOURCES

Allow scripts with nonces

MDN recommends nonces for restricting script and style loading: the server inserts the same random value into the policy and into each script tag.

The nonce must be different for every HTTP response and unpredictable, which requires templating rather than static HTML.

Hash-based policies suit static pages, but hashes must be recalculated whenever a script changes.

strict-dynamic passes trust to scripts loaded by allowed scripts, which helps with third-party tags, but MDN notes it makes the CSP less secure.

Sources: [1]

FROM PRIMARY SOURCES

Stage the other directives too

MDN advises setting frame-ancestors to none unless the site needs to be embeddable, as protection against clickjacking.

upgrade-insecure-requests rewrites leftover http resource loads to https, but it does not replace HSTS.

Observe these with Report-Only too, because partners may embed your pages in ways you do not know about.

Record the purpose of each directive and when it was enforced.

Sources: [1]

EDITORIAL PRACTICE

Switching to enforcement and later changes

When new violations have mostly stopped, send the same policy as Content-Security-Policy at a quiet time and check key pages immediately.

Write down how to roll back, but use reports to fix the cause rather than simply removing the header each time.

For every later change, send the next version as Report-Only alongside the enforced policy and apply it once no violations appear.

When outsourcing, make Report-Only results and allowlist updates part of the deliverables.

Sources: [1][2]

EDITORIAL PRACTICE

A checklist before you start

Decide scope and the layer that adds the header, the reporting setup and its verification, and the observation period with conditions for enforcement.

Decide the allowlist policy (nonces or hashes, no unsafe-inline, criteria for strict-dynamic), the record of sources and reasons, and the change procedure.

With these in place, CSP becomes a monthly improvement routine rather than a one-off project.

Sources: [1][2]

WITH OPERUN.

Delegate everyday AI management.

Used well, CSP greatly reduces attack impact, but every gap in the allowlist becomes a broken page. Count without blocking first, confirm reports arrive, narrow permissions around nonces, and keep testing each next version with Report-Only after enforcement. Turned into procedures and records, this keeps quality steady across staff changes and outsourced teams.

Discuss your product and AI work

Primary sources

Sources checked on 18 November 2026. The workflows and checklists are editorial proposals.

  1. [1]
  2. [2]

Share this insight