Shai-Hulud Worm Compromises NPM Packages in Escalating Supply Chain Attack
Table of Contents
A rapidly spreading malware dubbed Shai-Hulud is exploiting vulnerabilities in the Node Package Manager (NPM) ecosystem, compromising developer accounts and injecting malicious code into widely-used JavaScript packages. The worm leverages stolen NPM tokens to modify and republish popular packages, creating a cascading effect of infection.
How the Attack Works
According to Charlie Eriksen, a researcher at Aikido, the malware operates by first compromising a developer’s system, often through phishing attacks. Once inside, it searches for NPM tokens within the surroundings. If a token is found, Shai-Hulud modifies the 20 most popular packages accessible through that token, inserting its malicious code before publishing a new version. This self-propagating behavior distinguishes it from previous NPM compromises.
The attack builds upon a recent wave of phishing attempts targeting developers, designed to trick them into updating their multi-factor authentication (MFA) settings. These earlier attacks led to malware insertion into approximately two-dozen NPM packages, primarily focused on cryptocurrency theft. However, Shai-Hulud represents a meaningful escalation due to its worm-like propagation capabilities.
Recent Compromises and Impact
Prior to Shai-Hulud, the open-source code development toolkit “nx” was compromised in late August. attackers introduced code that scanned user devices for authentication tokens (GitHub, NPM), SSH keys, and API keys. Unlike Shai-Hulud, the nx compromise didn’t self-propagate but instead publicly exposed stolen credentials by creating a new repository in the victim’s GitHub account.
Shai-Hulud utilizes the open-source tool TruffleHog to identify exposed credentials and access tokens on compromised machines. It then attempts to create new GitHub Actions and publish stolen secrets. The worm’s initial compromise appears to have occurred on September 14th at 17:58 UTC.
CrowdStrike reported that at least 25 of its managed NPM packages were briefly compromised, but were quickly removed from the NPM registry.CrowdStrike confirmed that the Falcon sensor, its endpoint threat detection service, was not impacted and that keys in public registries have been rotated.
Cascading Infection and Current Status
Ashish bunch of StepSecurity explained the cascading nature of the attack: “This creates a cascading effect where an infected package leads to compromised maintainer credentials,wich in turn infects all other packages maintained by that user.”
While the spread of Shai-Hulud appears to have slowed in recent hours, Eriksen cautions that it remains a threat.”I still see package versions popping up once in a while,but no new packages have been compromised in the last ~6 hours,” he stated. “But that could change… I would think of this attack as a ‘living’ thing almost, like a virus.” The web address used for data exfiltration has been temporarily disabled due to rate limits.
Recommendations and Future Prevention
Nicholas Weaver, a researcher at the International Computer Science Institute, describes Shai-Hulud as “a supply chain attack that conducts a supply chain attack.” He advocates for immediate changes to NPM’s publication model, requiring explicit human consent and phish-proof two-factor authentication (2FA) for every publication request.
Allowing purely automated processes to update the published packages is now a proven recipe for disaster.
Weaver believes that implementing these measures would effectively throttle similar attacks before they can spread, emphasizing the need to move away from automated publication processes.
