Privacy & Security

The Polyfill.io Attack: When Your CDN Turns Against You

Michael Bommarito

The Problem With Trusting a Script Tag

For years, polyfill.io was the kind of dependency people hardly thought about. It solved a real problem: older browsers missing modern JavaScript features. Drop in a script tag, move on with your life.

Then the ownership changed.

In February 2024, the polyfill.io domain and GitHub account were sold to Funnull, a Chinese company. By late June, researchers at Sansec were reporting that the service was being used to inject malicious JavaScript into more than 100,000 websites. Cloudflare independently confirmed the risk and described the domain as something that “can no longer be trusted.”

That is not a small bug. That is a supply chain attack with a long reach and a very short fuse.

And yes, the punchline is bleakly familiar: the thing you added to avoid browser compatibility problems can become the thing that compromises your users.

What Happened

Sansec reported on June 25, 2024 that the new owner of the Polyfill project was injecting malware into sites embedding cdn.polyfill.io. The payload was not some noisy, obvious smash-and-grab. It was more surgical than that.

According to Sansec, the malicious code:

  • targeted mobile users,
  • activated only under specific conditions,
  • avoided execution when it detected an admin user,
  • delayed execution when analytics were present, and
  • redirected users to betting sites through additional JavaScript loaded from typosquatted domains like www.googie-anaiytics.com.

That spelling mistake is doing a lot of work. It is supposed to look enough like Google Analytics to be overlooked in a quick review, which is exactly the kind of move you see when an attacker wants the code to blend in rather than stand out.

Cloudflare’s own analysis corroborated the redirection behavior and said it had observed the service being used to inject nefarious code on June 25, 2024. It also noted that the original concern was not theoretical. Cloudflare had already built a mirror of polyfill.io in February because the ownership change looked like a supply chain risk waiting for a receipt.

That receipt arrived.

Why This One Stings

There are plenty of security incidents that sound dramatic but are actually narrow. This is not one of them.

polyfill.io was embedded all over the web. Sansec said more than 100,000 sites used it, and Cloudflare pointed to estimates that it was present on nearly 4% of all websites. Among the cited users were names like JSTOR, Intuit, and the World Economic Forum. In other words, this was not an obscure library tucked away in a corner case. It was everywhere.

That matters for two reasons.

First, the blast radius is huge. If a CDN that your site loads from gets compromised, every visitor is now a potential victim. Your application can be perfectly patched, your backend can be clean, your infrastructure can be locked down, and you still lose because a third-party script tag became the attack path.

Second, this is a governance problem, not just a technical one. Teams love to talk about patching servers, rotating credentials, and hardening identity. All good things. But a modern web application also depends on a chain of vendors, libraries, tag managers, analytics scripts, browser helpers, and CDN endpoints. If nobody owns that chain, it will eventually own you.

That is why this incident belongs in the same conversation as SBOMs, third-party risk reviews, privacy reviews, and web application security assessments. Not because every org needs a panel discussion about JavaScript, but because asset inventory without dependency inventory is incomplete.

The Technical Lesson

The technical failure here is not subtle. A dependency that was once broadly trusted became dynamic, opaque, and centrally controlled by a new owner whose incentives were not aligned with the downstream users of the code.

That is the kind of thing source code escrow was meant to address in older software deals. Through time immemorial, attorneys negotiating technology transactions have recommended escrow because it was supposed to reduce counterparty risk. If the vendor disappeared, changed hands, or otherwise became untrustworthy, the customer had an off-ramp.

Web dependencies never got that same treatment at scale. We mostly accepted a world where a page can execute remote code from half a dozen places and nobody treats that as unusual.

Which is why supply chain risk in front-end code is so nasty. It is not just “can this library break?” It is “who controls it now, what can they change without notice, and can they make the change look boring?”

The answer, in this case, was apparently yes.

And if the code is generating behavior based on HTTP headers, device type, and time of day, then you are not dealing with a static utility library anymore. You are dealing with a runtime decision engine sitting in your user’s browser, controlled by somebody else. That is a very different beast.

What Teams Should Do Now

If your site still references polyfill.io, remove it. That is the easy part, and it should not require a committee.

If you need the functionality, replace it with a trusted alternative. Cloudflare and Fastly both moved quickly to provide safer mirrors, but the broader lesson is not “pick the other CDN.” The broader lesson is to treat externally hosted client-side code as a security dependency, not a convenience.

Here is the practical checklist we would expect to see in a serious web application security assessment:

  • inventory every third-party script loaded in production,
  • identify whether any script is dynamically generated or remotely controlled,
  • review whether the dependency is still needed at all,
  • check whether the vendor can modify behavior without a version pin,
  • verify whether subresource integrity is possible,
  • add monitoring for browser-side code changes,
  • and flag any dependency that can change the user experience or content delivery path without your approval.

That last one is important. A lot of teams focus on server compromise because it feels more familiar. But in this case the attack is happening in the browser, through code you already authorized to run. That is why supply chain analysis belongs inside privacy, security, and compliance work, not outside it.

If you are a board member, this is also a good example of why “cyber risk” cannot just mean ransomware and phishing. A single third-party script can redirect customers, damage trust, affect ad delivery, trigger fraud systems, or expose your brand to a cleanup exercise that makes everyone miserable.

And if you are a product team that leans heavily on analytics, tag managers, and browser-side helpers, maybe ask the uncomfortable question: do we actually know what code our users are running?

If the answer is “not really,” then you do not have a tooling problem. You have a governance problem.

The Real Takeaway

The polyfill.io incident is not a story about one bad CDN. It is a story about what happens when the web’s trust model meets ownership change, opaque dependencies, and a threat actor with patience.

The web was built on composition. That is its strength. It is also the part that lets attackers turn a helpful utility into a delivery mechanism.

Trust, in software, is not a moral category. It is an engineering control. And if you do not maintain it deliberately, somebody else will maintain it for you.

Not usually in your favor.

Related posts

Want to discuss this topic?

We'll give you a straight answer — not a sales pitch.