Every script in your tag manager runs with the same power as your own code. It can read the DOM, read form fields, and send data anywhere. Most marketing teams treat that as a vendor problem. It is an engineering problem, and the fix is a Content Security Policy that you roll out in report-only mode first.
In 2024 the polyfill.io domain was sold and began serving malicious JavaScript to more than 100,000 sites that embedded it. Those sites had done nothing wrong at deploy time. A third party they trusted changed what it served. Your pixels, chat widgets, and A/B testing snippets carry the same exposure every single day.
Why Marketing Tags Are Your Largest Unaudited Attack Surface
A typical B2B site loads 20 to 40 third-party scripts, and many of them load further scripts you never reviewed. Tag managers make this worse by letting non-engineers publish code to production with no pull request and no review.
The payment angle makes this urgent. PCI DSS 4.0.1 requirements 6.4.3 and 11.6.1, mandatory since March 31, 2025, require an inventory of every script on payment pages, a justification for each, and detection of unauthorized changes. If you take card payments, "marketing owns the tags" is no longer an acceptable answer to an auditor.
The Tag Exposure
Sites that served polyfill.io code after the domain changed hands in 2024
Typical third-party scripts on a B2B marketing site
Date PCI DSS 6.4.3 and 11.6.1 became mandatory
Start With Report-Only, Not Enforcement
The mistake that kills CSP projects is turning on enforcement first. A strict policy will break your chat widget and your consent banner within the hour, and the project gets cancelled by lunch.
Instead, ship the policy as a report-only header. Browsers evaluate it, log every violation, and block nothing:
Content-Security-Policy-Report-Only: default-src 'self'; script-src 'self' 'nonce-{RANDOM}' 'strict-dynamic'; object-src 'none'; base-uri 'self'; report-to csp-endpoint
Reporting-Endpoints: csp-endpoint="https://reports.example.com/csp"
Three details matter. Generate a fresh nonce on every response, never a static one. Use 'strict-dynamic' so a nonce-approved loader such as your tag manager can load its children without you allowlisting every domain. And point the report endpoint at something you actually read, whether that is a log pipeline or a hosted collector.
Run report-only for two full weeks. You will collect a real inventory of every script, frame, and beacon destination your pages touch, including ones nobody remembers approving. That inventory alone is worth the work.
Triage the Reports Like a Backlog
Raw CSP reports are noisy. Browser extensions inject scripts and trigger violations that are not yours. Filter them out by dropping reports where the blocked URL scheme is chrome-extension or moz-extension, then group the rest by blocked domain.
Sort each domain into one of three buckets: keep, replace, or remove. Keep means a named owner and a business reason. Replace means the script can move to a first-party endpoint or a server-side tag. Remove means nobody can say why it is there. Expect the remove bucket to be larger than anyone wants to admit.
Which Control Covers Which Risk
| Control | Stops | Limitation |
|---|---|---|
| CSP with nonces | Injected inline scripts, unknown script origins | Needs per-response nonce generation |
| Subresource Integrity | A pinned file being swapped on the CDN | Useless for scripts that change by design, like tag managers |
| connect-src allowlist | Data exfiltration to unknown endpoints | Breaks when vendors add new beacon domains |
| Script inventory in CI | Untracked tags reaching production | Only covers what you check in |
Pin What Can Be Pinned, Monitor What Cannot
Subresource Integrity is the right tool for static files such as a self-hosted library version. Add the integrity attribute with a SHA-384 hash and the browser refuses a modified file. It does not work for vendor scripts that update continuously, and that includes Google Tag Manager, so do not expect it to cover your biggest risk.
For those, combine two controls. First, a tight connect-src and form-action policy limits where a compromised script can send data, which blunts exfiltration even when you cannot stop execution. Second, diff your script inventory on a schedule. A headless browser run in CI or on a daily cron can load your key pages, list every script URL and hash, and alert when a new domain appears.
What To Do This Week
- Add the report-only header on your highest-value pages first: checkout, pricing, and any page with a lead form.
- Stand up a report collector and set an alert for any new blocked domain.
- Assign a named owner to every domain in your inventory, with a one-line business reason.
- Remove everything without an owner after 30 days.
- Move to enforcement on one page type, then expand.
The goal is not a perfect policy. It is the end of invisible third-party code on pages that matter. Run report-only, read the reports, and make removal a normal part of how your team ships tags.
Tags
LETSGROW Dev Team
Marketing Technology Experts
Ready to Apply This Insight?
Schedule a strategy call to map these ideas to your architecture, data, and operating model.
Schedule Strategy Call