Polyfill js - Another Supply Chain Attack

Polyfill js - Another Supply Chain Attack

Polyfill js is a JavaScript open-source library that allows old browsers to support features that are not natively supported (for example, it can allow a browser to support HTML5 canvas). "Polyfill" is actually a more general concept in programming.

On June 25th 2024, a supply chain attack has been detected by security researchers at "Sansec". Basically they noticed that the CDN (Content Delivery Network) domain "cdn.polyfill.io" was compromised and some malicious JavaScript was injected. More in details, in February the domain "polyfill.io" was acquired by a Chinese suspicious company named "Funnull" and after few weeks they started to inject the malicious code.

Since JavaScript code can access cookies, storage, network activities and sensitive data, it should be clear the nefarious impact of embedding this malicious code in your application.

Over 100 thousands of websites have been affected, including big corporates of all industries.

Fortunately, the DNS registrar of the domain (Namecheap) has immediately put the domain on hold and CloudFlare already implemented a complete safe rewrite of the affected library, so that their customers are not affected anymore.
However, it's still recommended to remove any reference to "polyfill.io" in your web applications.

The importance of the supply chain

Just few months ago we had the XZ library security incident and these kind of attacks to the open source world are becoming more popular and frequent.

This additional security incident shows how the supply chain is complex and how it's hard to maintain control over it, especially regarding the JavaScript ecosystem.

In order to avoid such security incidents, we could rely on a browser feature called "Subresource integrity" : using this feature, the browser can verify that the resource that has been downloaded from a CDN (or any other location) has not been tampered and we are actually loading what we expect to load.

An example of usage is shown below:

<script
  src="https://some-cdn.site/example-framework.js"
  integrity="sha384-oqVuAfXRKap7fdgcCY5uykM6+R9GqQ8K/uxy9rx7HNQlGYl1kPzQho1wx4JwY8wC"
  crossorigin="anonymous"></script>

So when the browser download the resource from the CDN, before loading the script on the current JavaScript context, it will first verify that the sha384 hash digest of the downloaded resource matches the integrity value specified as a attribute of the script tag. If not, the browser will not load the resource and it will return an error.

Also, it's important to emphasize how it's critical for the application security, being aware of which libraries and open source components are used by our application (directly or transitively). This can be done by leveraging security tools such as SCA (Software Composition Analysis) and integrate them in our Continuous Integration pipelines.

Related Posts

 Grazie CrowdStrike per averci ricordato a che cosa serve il Testing

Grazie CrowdStrike per averci ricordato a che cosa serve il Testing

Il caso di CrowdStrike dimostra quanto sia essenziale investire in attività di QA e testing. Questi processi non solo migliorano l'affidabilità e la sicurezza del software, ma proteggono anche le azie

Agile and Security

Agile and Security

How Agile practices can improve the shift security left approach

MongoDB RomeMUG: Meet Up #9

MongoDB RomeMUG: Meet Up #9

"Deploy an Application on MongoDB Atlas"

Automated TLS Certificate Management

Automated TLS Certificate Management

TLS Certificate

XZ Backdoor (CVE-2024-3094) - A hidden backdoor in open-source software

XZ Backdoor (CVE-2024-3094) - A hidden backdoor in open-source software

How a malicious actor was able to gain credibility and inject malicious payload in a popular unix-like compression library

Windows Server & VPN SSL - MFA with Azure AD

Windows Server & VPN SSL - MFA with Azure AD

MFA implementation with Entra ID

Tor Browser: un piccolo report sulle problematiche relative alla privacy

Tor Browser: un piccolo report sulle problematiche relative alla privacy

Una risposta agli attacchi relativi alla privacy

Carbon Black Integration for Securing Windows and Linux Systems

Carbon Black Integration for Securing Windows and Linux Systems

Carbon Black as a Service integration on a vSphere infrastructure for securing Windows and Linux systems