Security news that informs and inspires
A crowded street

Researchers Warn of Widespread Polyfill Supply Chain Attack

A popular JavaScript library used by more than 100,000 websites has been injecting malicious code into pages delivered to mobile users in some circumstances and researchers and CDN providers are warning site owners to remove the library immediately.

The incident began earlier this week when researchers noticed that in some cases, the library was injecting dynamic code that would redirect users to a third-party site. Researchers estimate more than 100,000 sites are affected by this at the moment. is a library used to dynamically deliver some functionality to older browsers that don’t support specific features. Sites that use the library load it dynamically based on information in the HTTP headers presented by the user’s browser. It has been in use for many years, but the author of the library said in February that he had never owned the domain, which was purchased by a Chinese company in February.

“The polyfill.js is a popular open source library to support older browsers. 100K+ sites embed it using the domain. Notable users are JSTOR, Intuit and World Economic Forum. However, in February this year, a Chinese company bought the domain and the Github account. Since then, this domain was caught injecting malware on mobile devices via any site that embeds Any complaints were quickly removed (archive here) from the Github repository,” researchers at e-commerce security company Sansec said in an analysis of the incident.

“The polyfill code is dynamically generated based on the HTTP headers, so multiple attack vectors are likely. Sansec decoded one particular malware (see below) which redirects mobile users to a sports betting site using a fake Google analytics domain ( The code has specific protection against reverse engineering, and only activates on specific mobile devices at specific hours. It also does not activate when it detects an admin user. It also delays execution when a web analytics service is found, presumably to not end up in the stats.”

In response to the incident, Cloudflare has created its own safe mirror of and has taken the additional step of replacing any reference in its customers’ sites to the CDN with a redirect to that safe mirror. Fastly developed its own fork of in February and also released drop-in replacements for the original library. Namecheap, the registrar for the domain, has suspended it and GitHub has flagged the polyfill repository, as well.

Researchers recommend any site owners whose sites pull in the library look for it in their code and remove any links to it.

"Given how widespread this is, we don't expect to understand the real impact of this supply chain attack for many weeks. Attacks like these, however, can be quite devastating," Ax Sharma of Sonatype said.