Supply chain

Third-party scripts you did not approve

Almost nobody knows everything running on their own site. A tag manager loads three tags, one of them loads a partner's loader, and that pulls a fourth from somewhere nobody has heard of. All of it happens after your build, without a deploy.

A reporting policy answers from the browser, the only place the whole chain is visible. It shows you new hosts, and it misses most changes inside a vendor's code. Code arriving at run time is why client-side security is a layer of its own.

What the problem is

The usual risk is not malice. The thing you approved is not the thing that is running. You reviewed a vendor's tag in 2023. Since then it has been rewritten twice and acquired once, and it now loads a CDN bundle that loads a consent tool that loads a session recorder. Every link in that chain runs with the same privileges as your own code, and none of it is in your repository.

The chain is hard to audit by hand. Devtools shows what loaded on your machine, on that page, at that moment, with your ad blocker on. Scripts that load for a country, a signed-in session or a checkout step do not show up, and the ones that fire for one visitor in a thousand never will.

A report-only script-src listing the hosts you believe you use turns that into an inbox. Every host not on the list reports itself, from real visitors on real pages.

What the report looks like

This is the second hop. Your policy allows the vendor's widget, the widget fetches something else, and that is not on the list.

A vendor's bundle loading a host that is not on the allowlist.
{
  "csp-report": {
    "document-uri": "https://shop.example.com/checkout/payment",
    "referrer": "",
    "violated-directive": "script-src-elem",
    "effective-directive": "script-src-elem",
    "original-policy": "default-src 'self'; script-src 'self' https://widget.vendor.example; report-uri https://k3x9mp2nq7ab.ingest.us.headerhawk.com/r",
    "disposition": "report",
    "blocked-uri": "https://cdn.partner-analytics.example/loader.js",
    "source-file": "https://widget.vendor.example/embed.js",
    "line-number": 1,
    "column-number": 18422,
    "status-code": 200,
    "script-sample": ""
  }
}

How it appears in HeaderHawk

script-src-elem blocking cdn.partner-analytics.example

  • source-file names the script that made the request, the vendor's bundle and not your page. It turns 'something is loading an unknown host' into 'this tag is loading an unknown host'.
  • Line 1, column 18422 is normal. The vendor ships minified code, so every request is on line one, and the column still finds the call in a beautified copy.
  • blocked-uri is the new host. The vendor's own script sent no report, because it is on the allowlist. You only see the hop past the edge of what you approved.
  • One issue per directive and host, so a vendor that adds four new endpoints is four rows with counts, not four thousand reports. First seen is roughly when the vendor shipped the change.
  • The page count shows scope. A host on every page is a globally loaded tag; one confined to the checkout is a feature, or a problem.

Field by field: the script-src reference.

What HeaderHawk does with it

The first week of a report-only policy on a site with any marketing history is a long list. Reports collapse to one row per directive and blocked host, with a report count, the number of pages it appeared on, and first- and last-seen times. Working through it is triage: recognise a host and add it to the policy, or ask someone who should.

Reports whose blocked URI is chrome-extension:// or a similar scheme, or whose user agent matches a known crawler, are marked as noise. On a public site that is a large share of the traffic. It stays visible, because occasionally it is what you are looking for, but it never triggers an alert.

Once the list is quiet, a new host means something changed on a page you did not deploy. A 15-minute window reported by two or more browser families, or with twenty or more reports from one, goes straight to Slack, email or a webhook, and quieter ones go into a daily or weekly digest. An ongoing issue sends one notification, then goes into the digest.

On the Team plan and above, the Scripts view lists the SHA-256 hashes of the scripts browsers ran, by origin and by script URL. A second hash against a familiar URL shows a vendor shipped an update. Where the bytes match a file in a published npm package version, the view names the library and version, and your own bundles read as unrecognised. On the Professional plan and above, a named version is also checked against published advisories, which reaches vendor scripts no lockfile lists; a flag is about the version, not how your page uses it. The inventory is a sample from Chrome and Edge only, and its new and changed script alerts cover payment pages only, on the Professional plan and above.

Where CSP alone is not enough

  • A change inside a script you already allow reports nothing, and this is the limit that matters most here. Your allowlist names hosts, and a vendor pushing new code to the same host has not violated it. The Ticketmaster breach had exactly that shape.
  • CSP describes origin, not behaviour. It cannot tell you that an allowed analytics script started reading your form fields, as long as it sends them somewhere you already permit. Narrowing the policy on sensitive pages is the lever you have.
  • Alerts about new and changed scripts cover payment pages only, on the Professional plan and above. There, a new script alerts, and so does a new version of one you authorized with pinned hashes, once browsers on two different networks have reported it or the page's daily scan fetches it. A vendor you authorized for any content updates without alerting anyone, by your choice. Elsewhere, a changed script shows as a second hash against a familiar URL when you look, and alerts nobody.
  • The hash inventory is a sample and starts on the Team plan. It covers Chrome and Edge only and fetched subresources only, never cached or inline scripts, and repeat sightings are sampled. A first sighting skips the sample rate as a priority, not a guarantee. A site over its monthly quota or its daily hash ceiling can have a new hash held until the next sighting.
  • Report-only mode prevents nothing. It shows what an enforcing policy would refuse, before you enforce it. When you switch, the block is your own header.
  • A tag manager that needs 'unsafe-inline', or an allowlist wide enough to keep marketing unblocked, gives up most of the signal. That trade-off is worth making on purpose, before you discover it.
  • On the Free and Team plans nothing fetches your pages, so a policy that stopped being served looks like a quiet week. The daily scans that catch it are on the Professional plan and above, and cover the pages you mark, not the whole site.

Where to go next

  • The script-src reference covers the allowlist itself, including why your reports name script-src-elem when your policy does not.
  • Magecart and card skimming is what this becomes when the page in question takes payment.
  • PCI DSS 4.0 covers the script inventory and change-detection requirements, and which parts of them nothing here addresses.
  • Two write-ups of this exact shape: the Ticketmaster breach, a vendor's chat widget modified at the vendor, and the polyfill.io attack, a CDN changing behind a stable URL.

Find out what is on your pages

List the hosts you think you use, put them in a report-only script-src, and read what comes back.