On June 25 the researchers at Sansec reported that cdn.polyfill.io, a free service that for about a decade had served compatibility code to older browsers, was injecting malicious JavaScript into the more than 100,000 websites that embedded it. Selected mobile visitors were being redirected to scam and sports-betting sites. The domain and its GitHub account had been sold in February to a company called Funnull. The project's original creator warned at the time that sites should stop using it. Most did not, because nobody remembered the line was there.
Google, it turned out, had already been disapproving ads whose landing pages carried the script. Within two days of the report Cloudflare had begun automatically rewriting polyfill.io references to its own mirror for free-plan sites on its network, with a one-click option for paid plans, and the registrar had put the domain on hold. The immediate fire is out. The condition that produced it is not.
What a script tag actually is
A script tag pointing at a third-party domain is an instruction to run whatever that domain serves, with the full privileges of your page. It can read the form your customer is typing into, rewrite the checkout, and send data wherever it likes.
That decision is not made once, when a developer adds the line. It is re-made on every page load, by whoever controls the domain at that moment. A domain sale therefore changes your supplier without a contract, a notice or a change ticket. No one at any of those 100,000 sites approved Funnull as a vendor. They became its customers anyway.
When we wrote about the logging library in 2021, the problem was code sitting on your own disk that you had not chosen. This is a step further: code you have never stored at all, fetched live, from someone else's server, every time.
Why the obvious control did not fit
The standard defense for third-party scripts is Subresource Integrity: you put a hash of the expected file in the tag, and the browser refuses to run anything that does not match. For a static library on a CDN, that is close to ideal.
Polyfill.io could not use it. The service's whole purpose was to send different code to different browsers, tailored to each user agent, so there was no single file to hash. Its design made the strongest available control unusable, and that trade was accepted years ago, by default, by everyone who pasted in the snippet.
The malicious code was also built not to be seen. Sansec found it activated only on certain mobile devices at certain hours, stayed quiet when it detected an admin user, and held off when web analytics were present. The person most likely to notice a problem with a website, its owner, testing it from a desktop while logged in, was the person least likely to see this one. Cloudflare has said its own monitoring first saw matching malicious JavaScript on June 8, more than two weeks before the public report.
Finding yours
Removing one domain is easy. Knowing every domain your pages load scripts from is the actual work.
- Search the code and templates for polyfill.io and for every other external script source. Include CMS themes, plugins and old microsites, not only the main application.
- Look inside the tag manager. Marketing tools can add scripts to production pages without a deploy, and that is often where the forgotten ones live.
- Crawl the live site. What is in the repository is not always what is served. Record every external script domain the pages actually load.
- Check the neighbors. Google's notice to advertisers also named Bootcss, Bootcdn and Staticfile as sources of unwanted redirects. Look for those too.
When we ran this across our client base this week, a handful of clients had a polyfill.io reference somewhere. Almost all of them were in marketing microsites and CMS themes nobody had touched in years.
The fix, in order
Remove polyfill.io. The original creator's point stands: modern browsers do not need it. If something genuinely does, switch to the mirrors Cloudflare and Fastly operate, or host the polyfills yourself.
Self-host what you reasonably can. Pin the version, serve it from your own domain, and put integrity hashes on any static third-party file you keep.
Deploy a Content Security Policy with an explicit list of allowed script sources. Start in report-only mode to learn what your pages really load, then enforce. The reports alone are worth having: they tell you when a page starts pulling code from somewhere new.
Treat the tag manager as a production deployment. Limit who can publish, require review, and keep a change log. It is shipping code to every visitor; it should be governed like it.
Give every external script domain an owner. A person, a business reason and a review date. Domains expire and change hands. Someone should be watching the ones your revenue depends on.
If you take card payments
PCI DSS version 4.0, revised as 4.0.1 earlier this month, adds two requirements aimed squarely at this problem: 6.4.3, which calls for an inventory of every script on payment pages with a justification and a way to confirm each one is authorized and intact, and 11.6.1, which calls for detecting unauthorized changes to those pages. Both are best practice today and become mandatory on March 31, 2025.
Polyfill.io is the case study for why they exist. Start the inventory now. In our experience it takes longer than anyone expects, mostly because of scripts that load other scripts.
The wider point
Third-party risk programs track companies you have contracts with. The most dynamic supplier on your website may be one you have never paid, never met, and could not name. It ships to your customers every few seconds.
A domain you do not control is a supplier you do not control.
Sources
- Polyfill supply chain attack hits 100K+ sites — Sansec, June 2024
- Polyfill.io JavaScript supply chain attack impacts over 100K sites — BleepingComputer, June 2024
- Automatically replacing polyfill.io links with Cloudflare's mirror for a safer Internet — Cloudflare, June 2024
- Just Published: PCI DSS v4.0.1 — PCI Security Standards Council, June 2024






