In February 2024 the polyfill.io domain was acquired by a Chinese CDN company. On 25 June, cdn.polyfill.io began serving malicious JavaScript to the 100,000-plus sites that embedded it.
Nothing on any of those sites changed. No file was edited, no server was breached, and no site owner did anything wrong on the day. A dependency they had trusted for years simply started answering differently, because it had changed hands.
The malicious code was conditional and evasive by design. It was generated per request from the HTTP headers, fired only on specific mobile devices, avoided visitors who looked like administrators, and delayed its own execution. Users who met the conditions were sent through a redirect chain — including a typosquatted domain impersonating Google Analytics — on to sports betting and adult sites.
Read that list again as a list of defences it defeats. A scanner does not present as a specific mobile device. An administrator checking the site is precisely who it hid from. A synthetic monitor does not wait around for a delayed payload. Fetching the file yourself and reading it tells you what it serves you, which was the point.
Every one of those evasions works against something that visits a site to check it. None of them works against telemetry from the real users it was targeting, because those users were the intended audience.
The standard advice for a third-party script is to pin it with Subresource Integrity, so the browser refuses to run it if the content does not match a known hash. It is good advice and it does not apply here.
Polyfill.io's entire purpose was to serve different code to different browsers — that is what a polyfill service does. The content was designed to vary per request, so there was no stable hash to pin. Anyone who has been told to "just use SRI" should understand why this class of dependency is exactly the one it cannot protect.
A Content Security Policy does not stop it either, and it is worth saying so plainly. The domain was already in every victim's allowlist. It had been a legitimate dependency for years. A policy that constrains where scripts come from permits it without hesitation, because the source never changed.
Cloudflare began automatically rewriting requests to the domain and serving a safe mirror the day after the story broke. Fastly stood up a mirror too. Google warned advertisers their landing pages might be affected. This was, by the standards of a web security story, extremely loud.
More than a week later, over 380,000 hosts were still embedding the malicious script.
That number is the actual finding. Not that an attack happened, but that hundreds of thousands of organisations could not act on front-page news because nobody could tell them whether they were affected. Answering "do we load this?" requires an inventory of what executes on your pages, and most teams do not have one.
Two things, and neither of them requires knowing about the attack in advance.
The first is simply the inventory. A list of every script executing across your estate, gathered from real browsers, turns the week of June 25th from a research project into a search box. Most of the 380,000 were not ignoring the news; they could not answer the question.
Browsers already tell us the answer. With CSP Integrity, every script a real browser executes is reported to us with a content-addressed fingerprint alongside its URL — so the same address serving different code is a different fingerprint, arriving from the session where it actually ran. A service built to vary its output has no single archivable version, but it cannot vary it without the fingerprints moving, which is why the question “what exactly was on the page at 14:00?” has an answer rather than a shrug.
The second is the destination. The redirect chain and the hosts it passed through were new, and a page that suddenly starts sending users somewhere it has never sent them before is exactly what Data Watch is watching for.
You don't need a mature Content Security Policy to start. Script Watch gives you the inventory of what executes on your pages, Data Watch gives you the destinations receiving data from them, and CSP Integrity adds the fingerprint of each script as it ran. One line of code or config to deploy.
Reach out to sales@report-uri.com if you want a demo or a trial with no commitment.
One header. No code. Your script inventory starts populating from the first visitor.
30-day free trial · One header · No code · Cancel anytime
Script Watch will monitor all JavaScript dependencies across your entire site and immediately notify you of any changes. A new JavaScript dependency could be the start of a Magecart attack.
Because Script Watch leverages the browser native Content Security Policy, there is no code or agent to deploy and running in the browser means we analyse your site in real-time as your users are browsing. We don't have the same limitations as external scanning services such as authentication or pay walls, geo-sensitive content or an attacker potentially serving safe content to the crawler.
Data Watch will monitor all of the locations that your webpages are sending data to. If your website starts sending data to a new location, it could be the start of a Magecart attack.
With Script Watch and Data Watch combined, you can monitor for clear indicators that your site has been compromised. Attackers will always want to inject their hostile JavaScript, and they'll always want to exfiltrate their stolen data.
We often find that creating a CSP is the first difficult step that organisations face. Having a complete list of all resource dependencies across your entire site like images, scripts or styles, from both 1st-party and 3rd-party locations, is tough to achieve.
The CSP Wizard was created to solve this problem, and in seven days or less, it can give you a complete list of all resources used across your entire site.
With the list of all resources you use on your site, and our easy-to-use tool, creating a viable Content Security Policy is easier than ever with just a few clicks.
All Content Security Policies will need to be tweaked at some point. New resources may be added to the site or old resources removed, and the policy needs to be updated to reflect those changes and kept up to date.
You can import your existing policy into the CSP Builder and use our fully featured tool to make any changes that you require right there in the UI. When you're done, hit Generate, and the CSP Builder will provide you with your new, updated policy.
Script Watch and Data Watch will allow you to rapidly detect and respond to a Magecart attack and combined, that capability puts you ahead of the field. If you want to take it a step further, Content Security Policy can mitigate a Magecart attack and stop it from even happening.
Deploying an effective Content Security Policy can be difficult, but our CSP Reporting allows you to gather feedback and safely test a policy before deployment. Once deployed, an effective Content Security Policy will block a Magecart attack and stop the hostile JavaScript from even running.
We subscribe to various feeds of Threat Intelligence data, along with managing our own internally generated feeds, to keep apprised of the latest threats that exist online.
Using this Threat Intelligence Data, we can better analyse the sources of JavaScript on your website and detect malicious activity sooner.