Polyfill.io supply chain attack hits 100,000+ websites — all you need to know (2024)

In a significant supply chain attack, over 100,000 websites using Polyfill[.]io, a popular JavaScript CDN service, were compromised.

Earlier this year, a Chinese company called Funnull took over the ownership of the polyfill[.]io domain. What followed was the CDN delivering malicious JavaScript code which was automatically deployed on websites that embedded scripts from cdn.polyfill[.]io. The code would redirect mobile visitors of a website to scam sites.

As a result of the fall out from this attack, Google has informed advertisers about possible impacts on their landing pages that might be contaminated with malicious scripts, whereas safe mirrors of Polyfill have been setup by Fastly and Cloudflare.

We break down what this incident means for npm developers and packages relying on the Polyfill CDN.

Understanding the Polyfill.io Compromise

In February 2024, Andrew Betts, the original developer of the polyfill service warned users against using polyfill[.]io as a precaution—months before there was any indication, knowledge of, foul play involved.

"If your website uses http://polyfill.io, remove it IMMEDIATELY," wrote Betts. "I created the polyfill service project but I have never owned the domain name and I have had no influence over its sale."

"No website today requires any of the polyfills."

Sansec researchers discovered this week that ever since the domain changed hands, it has been "injectingmalwareon mobile devices via any site that embeds cdn.polyfill[.]io." and raised the alarm bells for everyone.

Although technology leaders like Cloudflare, Fastly, and Google have all stepped in to thwart the threat, it's not yet over. Google started alerting advertisers that, as a result of this attack, their landing pages contain the malicious code that could send visitors away from the intended site without the website owner knowing about it. Cloudflare and Fastly setup safer mirrors of the Polyfill service.

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. For example, it can be used to plant backdoors that could allow the threat actor(s) to remotely access an infected device—similar to what we saw with the compromise of IRS-authorised tax filing service eFile.com that was caught delivering malicious JavaScript.

Cryptocurrency theft, mining, and credit card skimming are key characteristics of successful Magecart-style attacks that often involve delivering malicious JavaScript via otherwise legitimate websites or CDNs that have been quietly compromised.

npm libraries that still use unsafe Polyfill.io CDN

As Mozilla explains it, "A polyfill is a piece of code (usually JavaScript on the Web) used to provide modern functionality on older browsers that do not natively support it."

Several npm packages designed to offer the polyfill functionality continue to embed code from the 'cdn.polyfill[.]io' service. For example, looking at the 'create-polyfill-service-url' package, we can see it uses the service as the default provider for polyfill:

Polyfill.io supply chain attack hits 100,000+ websites — all you need to know (1)

Similar behavior is exhibited by other libraries, like 'dynamic-polyfill' that fetch code from the CDN:

Polyfill.io supply chain attack hits 100,000+ websites — all you need to know (2)

Although the polyfill[.]io domain is, at the time of writing, redirecting to Cloudflare's mirror, we can not conclude that the threat from this domain is over yet, given that the DNS entries could be manipulated in the future to resume the attack.

Out of caution, the Sonatype Security Research team has and continues to categorize several npm packages under sonatype-2024-2304 as 'Potentially Unwanted Application(s)' or PUAs.

Users of Sonatype Lifecycle and Sonatype Repository Firewall will notice that open source packages that rely on the risky polyfill[.]io domain will gradually start flagging a security alert.

We understand it may not be practical to identify and flag every single library from every registry that uses or has in the past used the 'cdn.polyfill[.]io service. Our teams are actively reviewing the ongoing incident and will discretionarily modify our package blocklists while bearing in mind that some applications could have a legitimate need for these packages and that their software builds should continue to run smoothly.

Polyfill.io supply chain attack hits 100,000+ websites — all you need to know (3)

Mitigation and Response

In response to the Polyfill.io compromise, security experts recommend several measures to mitigate the risks associated with JavaScript supply chain attacks:

  1. Regular Audits and Monitoring: Conduct regular security audits and monitor third-party services for unusual activity. Early detection can help prevent widespread damage.
  2. Content Security Policy (CSP): Implementing a robust CSP can help restrict the sources from which scripts can be loaded, reducing the risk of malicious code execution.
  3. Subresource Integrity (SRI): Use SRI to ensure that third-party scripts have not been tampered with. This security feature allows browsers to verify that a fetched resource matches the expected hash.
  4. Dependency Management: Maintain strict control over dependencies (a feature of Sonatype Nexus Repository) and avoid unnecessary third-party scripts. Regularly update and review dependencies to ensure they are secure.

Future of Supply Chain Security

The Polyfill.io attack is a stark reminder of the evolving threat landscape in web development and is a wake up call. As the use of third-party services continues to grow, so does the need for robust supply chain security practices. It highlights the urgent need for improved supply chain security measures and greater vigilance in monitoring third-party services Developers and organizations must prioritize security at every stage of the development process to mitigate risks associated with third-party dependencies.

Investing in advanced threat detection systems, educating developers on secure coding practices, and fostering a culture of security awareness are crucial steps in enhancing supply chain security. Additionally, collaboration between security researchers, developers, and service providers is essential to identify and address vulnerabilities promptly.

Polyfill.io supply chain attack hits 100,000+ websites — all you need to know (4)

Written by Ax Sharma

Ax is a Staff Security Researcher & Malware Analyst at Sonatype with a penchant for open source software. His works and expert analyses have frequently been featured by leading media outlets including the BBC. Ax's expertise lies in security vulnerability research, reverse engineering, and cybercrime investigations. He has a passion for educating a wide range of audiences through writing and vlogs.

Explore All Posts by Ax Sharma

Tags

vulnerabilities Nexus Firewall npm Javascript supply chain

Polyfill.io supply chain attack hits 100,000+ websites — all you need to know (2024)

FAQs

What is polyfill.io used for? ›

Polyfill.io is a service that helps automatically deliver polyfills that a browser requires for displaying a particular website. The service gained popularity both for its efficiency (only the polyfills you need are loaded) and for its regular updates to the technologies and standards used.

What is a polyfill in JavaScript? ›

A polyfill in JavaScript is a script that adds modern features to older browsers that do not natively support them. To use it, include the polyfill script in your HTML or install it via a package manager, ensuring compatibility with older environments.

What does polyfill do? ›

Polyfills allow web developers to use an API regardless of whether or not it is supported by a browser, and usually with minimal overhead. Typically they first check if a browser supports an API, and use it if available, otherwise using their own implementation.

What is an example of a polyfill? ›

Let's take an example of polyfill implementation for the Math. trunc() method. The function Math. trunc(n) "cuts off" the decimal portion of an integer.

What does polyfill feel like? ›

If you were to Goldilocks-it and jump back and forth between the two, you might notice that the Poly Fill's texture is slightly spongier than the classic loft of the Feather Down, but again it's very subtle.

What is a polyfill in HTML? ›

Polyfill, or even Polyfilla, is any code component that makes cutting-edge HTML, CSS or JavaScript functions available in older browsers that inherently lack support. In most cases, a polyfill is written in JavaScript.

When you want to include a polyfill you need? ›

If you want to include a polyfill, you need to: - add a fallback 'resolve. fallback: { "stream": require. resolve("stream-browserify") }' - install 'stream-browserify' If you don't want to include a polyfill, you can use an empty module like this: resolve.

What does a polyfill mod do? ›

Polyfill has become the go-to for removing unwanted acoustics from your keyboard. Hollowness, tinniness or high pitched frequencies can all be reduced or eliminated with the use of this fantastic filler. Just place some in the bottom of your case in the desired locations, seal it up and you are good to go.

What is polyfill stuffing used for? ›

Polyester fiberfill is a synthetic fiber used for stuffing pillows and other soft objects such as stuffed animals. It is also used in audio speakers for its acoustic properties. It is commonly sold under the trademark name Poly-Fil, or un-trademarked as polyfill.

Which browser is compatible with polyfill? ›

A polyfill is a piece of code, usually written in JavaScript, that emulates the functionality of a modern feature in older browsers. It fills the gap between the browser's native capabilities and the desired functionality, enabling developers to use new language features or web platform APIs in outdated environments.

Top Articles
Latest Posts
Article information

Author: Gregorio Kreiger

Last Updated:

Views: 5299

Rating: 4.7 / 5 (77 voted)

Reviews: 84% of readers found this page helpful

Author information

Name: Gregorio Kreiger

Birthday: 1994-12-18

Address: 89212 Tracey Ramp, Sunside, MT 08453-0951

Phone: +9014805370218

Job: Customer Designer

Hobby: Mountain biking, Orienteering, Hiking, Sewing, Backpacking, Mushroom hunting, Backpacking

Introduction: My name is Gregorio Kreiger, I am a tender, brainy, enthusiastic, combative, agreeable, gentle, gentle person who loves writing and wants to share my knowledge and understanding with you.