Huge NPM Supply Chain Hack: What Happened?

Published:
September 18, 2025

The September 2025 attack on the Node Package Manager (NPM) ecosystem is already considered a watershed moment in cybersecurity history. Although the incident was contained quickly, its widespread impact exposed critical vulnerabilities across the software development ecosystem.

This report provides a technical breakdown of the attack vector, the malicious payload, and the broader implications for open-source software. It also discusses how the lessons learned will shape future security practices.

Huge NPM supply chain hack: What happened?

What Happened? – NPM Hack Highlights

On September 8, 2025, a huge supply chain attack took place in the JavaScript ecosystem. Threat actors initiated a targeted phishing attack against a trusted package maintainer, successfully gaining control of his NPM account.

Using unauthorized access, the attackers published malicious updates to at least 18 popular JavaScript packages, including debug, chalk, and ansi-styles. These packages, which collectively account for over two billion downloads each week, silently spread malicious code to downstream applications. The malicious payload was a sophisticated, browser-based crypto-stealer designed to hijack transactions and redirect funds to attacker-controlled wallets.

The compromised packages were live for approximately two hours before being detected by the community and removed by NPM. While the reported financial theft was minimal, the potential for catastrophe and the operational disruption caused by the cyber incident were profound.

Understanding the NPM Supply Chain Attack

The attack on the NPM supply chain was not a random event but a calculated exploitation of the current software development paradigm. A complete understanding of the incident requires an examination of each attack component.

What is NPM?

NPM, an acronym for Node Package Manager, is the basis of the modern JavaScript and Node.js ecosystem. It fulfills two primary functions, acting as:

The dual nature of NPM allows developers to effortlessly share, install, and manage reusable code libraries, from small utility functions to complex user interface (UI) components. By enabling developers to build applications through composing thousands of modular dependencies, NPM significantly increases development speed and efficiency.

An illustration showing a hacked computer in an office.

Why Is NPM a High-Value Target?

The value of NPM as a target stems from its ubiquity and foundational role in the digital world. By injecting malicious code into widely used packages, the attackers ensured their malware would proliferate silently into countless applications that depend on these libraries.

The attack exploited modern software's reliance on interconnected dependencies. The average software project today contains hundreds of dependencies, many of which are transitive, meaning they are installed indirectly by other packages. Transitive dependencies create a large and often unpredictable attack surface, amplifying the scope of the attack.

The attackers strategically targeted foundational utility libraries, such as debug and chalk. A compromise at such a low level of the dependency tree cascaded upward, affecting thousands of downstream applications. This approach is part of a broader trend in which cybercriminals are shifting their focus from targeting individuals to attacking foundational projects.

What Are Supply Chain Attacks?

A software supply chain attack is a type of cyber attack in which a threat actor compromises a trusted, upstream component, such as an open-source library. The component is then used as an attack vector to distribute malicious code to all its users.

The core principle of a supply chain attack is leveraging trust. Instead of attempting to breach every target individually, an attacker goes upstream and corrupts a single, trusted source. The malicious code is then automatically distributed to every user downstream.

A common analogy used to describe this is a car factory: instead of cutting the brakes on every car individually, the attacker compromises the factory that manufactures the brake pads. If successful, this operation ensures every car produced in the factory has the faulty pads.

Notable historical examples of this strategy include:

  • The SolarWinds attack.
  • The XZ Utils backdoor incident.
  • The NotPetya attack.

All of these attacks demonstrated the devastating impact of compromising a single trusted source.

How Attackers Exploited the NPM Ecosystem

The attack vector was not a technical exploit of the NPM registry itself. Instead, it was a social engineering campaign targeting a human administrator, a well-regarded maintainer known as qix (Josh Junon).

The attackers employed a highly sophisticated phishing lure. They registered a convincing, typosquatted domain, npmjs.help, to impersonate official NPM support. Phishing emails were sent to multiple NPM maintainers, warning them of an urgent need to update their 2FA credentials.

This tactic created a sense of urgency and exploited the natural human tendency to act quickly when under pressure. The maintainer entered his credentials and a live OTP token into the fraudulent portal, granting the attackers full account access.

This single account takeover unlocked a massive distribution channel. It allowed the malicious updates to be published and propagated across the entire ecosystem.

NPM Hack Timeline

The attack speed and the subsequent community-led response provide a timeline that highlights the importance of supply chain security. Refer to the table below for the list of key events:

Date/Time (UTC)Event
September 4, 2025Attackers register the malicious phishing domain, npmjs.help.
September 8, 2025
13:16
The first malicious versions of compromised packages are published to the NPM registry.
September 8, 2025
~15:15-15:20
The open-source community detects suspicious code and raises alerts on GitHub and social media platforms.
September 8, 2025
15:15
The compromised maintainer, Josh Junon, publicly acknowledges the breach and alerts NPM.
September 8, 2025
17:17
NPM confirms the breach and initiates the removal process for the compromised packages.
September 8, 2025
19:59
NPM reports that all initially affected packages have been removed from the registry.
September 9-11, 2025Security researchers and the community continue to identify additional compromised packages, while maintainers publish fixes.

Affected Packages and Scope of the Breach

The scope of the breach was vast, not only due to the number of packages affected but also because of their critical role as foundational dependencies. The initial wave of the attack compromised at least 18 widely used packages, a number that grew to 27 as further investigation uncovered additional affected libraries.

The table below contains a selection of affected packages and their weekly download numbers:

Package NameWeekly Downloads (millions)
ansi-styles371.41
debug357.6
chalk299.99
supports-color 287.1
strip-ansi261.17
ansi-regex 243.64
wrap-ansi197.99
color-convert193.5
color-name191.71

The malicious payload itself was a sophisticated, obfuscated JavaScript script designed to operate exclusively within browser environments. Its primary function was to act as a wallet-drainer by intercepting and manipulating cryptocurrency transactions.

The malware achieved its objective through several key mechanisms:

  • API hooking. The malicious code integrated itself directly into the browser environment, hooking into critical APIs such as fetch, XMLHttpRequest, and wallet-specific interfaces like window.ethereum. This strategy allowed it to monitor network traffic and wallet interactions in real-time without the user's knowledge.
  • Stealthy address replacement. Upon detecting a cryptocurrency transaction, the malware would replace the legitimate destination address with one of its own. It evaded detection by employing a Levenshtein distance algorithm to identify and utilize visually similar addresses, thereby making the change less noticeable to the user. The address swap occurred before the user signed the transaction, ensuring that even if the user interface appeared correct, the signed transaction would route funds to the attacker.
  • Multi-chain targeting. The payload was engineered to target multiple major blockchains, including Ethereum, Bitcoin, Solana, Tron, Litecoin, and Bitcoin Cash.

The Shai-Hulud Worm Attack

Following the September 8th incident, a new and more sophisticated campaign has emerged. Unlike previous incidents that relied on one-time credential theft and malware injection, the new attack uses a self-propagating worm dubbed Shai-Hulud. The worm not only steals credentials but also automatically infects other packages maintained by the compromised developer.

The Shai-Hulud attack was first recorded on September 14, with the publishing of the first malicious package, a compromised version of rxnt-authentication. Early reports also identified the compromise of packages like ngx-bootstrap and @ctrl/tinycolor and dozens of others. In four days, the number of affected packages rose to over 500.

The attack chain consists of the following stages:

  1. The attacker sends a targeted phishing email, similar to the one used in the September 8th attack.
  2. These emails, often disguised as security alerts from NPM, trick maintainers into revealing their credentials.
  3. Once a developer's NPM account is compromised, the attackers don't need to infect other packages manually. Instead, the malicious payload (a script named bundle.js) kicks off an automated multi-stage attack.

The Shai-Hulud worm's primary functions are:

  • Credential harvesting. The malware executes a post-installation script that scans the infected developer's machine for sensitive data. It targets NPM tokens, GitHub personal access tokens, and cloud service credentials (AWS, GCP, and Azure keys). To do this, it leverages legitimate, open-source tools like TruffleHog to scour the file system for secrets and query cloud metadata endpoints for ephemeral credentials.
  • Data exfiltration. Stolen credentials and other system information are immediately exfiltrated. The worm automatically creates a new public GitHub repository named Shai-Hulud under the victim's account and dumps the harvested data there, making it publicly accessible to the attackers. It also injects a malicious GitHub Actions workflow into the victim's repositories to persistently exfiltrate secrets via webhooks.
  • Self-propagation. Using the stolen NPM token, the worm queries the NPM registry to find all other packages maintained by the compromised developer. It then automatically creates and publishes new, malicious versions of these packages, injecting its own bundle.js script into them. This action turns every newly infected package into a new vector for the worm to spread, creating a cascading effect that rapidly compromises the ecosystem. As a result, the number of affected packages grew from dozens to over 500 in a matter of days.

The Shai-Hulud campaign significantly escalates the scale and speed of the attack, and highlights the evolution of supply chain attacks from one-off compromises to self-sustaining threats.

Impact on the Developer and Crypto Communities

The NPM supply chain attack had a dual impact, causing both financial losses and a psychological and operational disruption. It served as a reminder that the open-source ecosystem, while powerful and flexible, is now a prime target for sophisticated cybercriminals and nation-state actors.

Initial reports from security researchers indicated that the direct financial losses from the attack were minimal, with stolen funds amounting to approximately $500 to $1,000. However, viewing the attack as a minor incident is wrong as it ignores its actual impact: a form of technical and operational denial-of-service on the entire industry.

The incident forced development teams to spend hours on emergency audits, purging poisoned caches, and rotating credentials. The waste of time and resources for remediation, regardless of the direct financial payoff, showcases a new type of attack where the objective is to cause widespread operational chaos.

The attack also had a psychological impact, creating a wave of fear, uncertainty, and doubt throughout the community. It highlighted a vulnerability of placing trust in a small number of under-resourced maintainers.

How to Protect Your Projects From Supply Chain Attacks?

The NPM incident proves that relying on community-led detection is not a sustainable security strategy. A proactive, multi-layered defense is crucial for mitigating security risks.

The following is a list of actions developers and maintainers must perform to ensure sustainable protection:

  • Enforce Two-Factor Authentication (2FA). Developers should enable 2FA on all publishing accounts, especially those with write-mode permissions. While a phishing attack was able to bypass a one-time token, stronger, phish-proof methods like hardware security keys are critical for high-value accounts.
  • Use and enforce lockfiles. The package-lock.json file is essential for ensuring deterministic installations and verifying package integrity via checksums and source URLs. Developers should use the npm ci command in their CI/CD pipelines to enforce strict adherence to the lockfile and prevent unintended package updates.
  • Minimize attack surface. Regularly audit and remove all unused dependencies from projects. Additionally, consider using the --ignore-scripts flag during installation to prevent malicious code from executing during the build process.
  • Vet new packages. Before installing a new package, perform due diligence. Check the maintainer's history and credibility, and hold off on immediately upgrading to new versions, allowing the packages time to circulate and be reviewed by the community.
An illustration showing a well-protected computer.

Organizations and security teams must support the developers' efforts with the following actions of their own:

  • Audit dependencies. Use a Software Composition Analysis (SCA) tool to continuously audit dependency manifests (package-lock.json, yarn.lock) against known compromised versions.
  • Block and purge. Immediately blocklist all compromised package versions and purge caches on developer machines, CI/CD servers, and artifact registries to prevent the reintroduction of malicious code.
  • Continuous monitoring. Implement continuous monitoring and runtime-aware detection. The monitoring should include scanning built assets for injected obfuscated code and hunting for suspicious runtime behavior, such as unexpected outbound connections or API anomalies.
  • Rotate credentials. Immediately rotate all credentials, including passwords, API keys, and tokens, if there is any possibility of exposure to a compromised environment.

Our Website security guide teaches you all you must know to keep a website safe from cyber threats.

Broader Implications for Open Source Security

The NPM incident is more than a single security event. It is a critical indicator for the future of open-source security, highlighting trends and vulnerabilities that will define the coming years. The attack exposed the vulnerability of the trust model by successfully compromising its most trusted element: a human maintainer.

Another aspect that amplifies the problem is the rise of Generative AI (GenAI) and Large Language Models (LLMs). Malicious actors can use LLMs to accelerate attacks by automating the creation of hundreds of fake developer identities with plausible backstories and legitimate-looking contribution histories.

Since it is virtually impossible for a human to distinguish between a legitimate contributor and an AI-driven imposter, attackers can build trust over time before embedding malicious code. The effort to prevent this will lead to a critical race between offensive AI, used for infiltration, and defensive AI, used for behavioral detection and anomaly flagging.

Lessons from the 2025 NPM Attack

The NPM supply chain attack of September 8, 2025, was a critical stress test of the open-source ecosystem. It demonstrated that the software supply chain is now a primary target for sophisticated cybercriminals.

The attack, much like the XZ Utils incident, also underscores the urgent need for greater investment from both the private and public sectors into open-source projects. Companies that rely on open-source code must recognize that it is a shared public good that requires shared responsibility, such as:

  • Providing funding.
  • Dedicating developer time.
  • Offering security expertise to critical, but often under-resourced, open-source projects.

The incident also highlights the need for improved governance within open-source projects, including more rigorous code review processes and a shared responsibility for updates.

Cybersecurity Begins at the Foundation

The NPM attack underscores a simple yet profound truth: in the interconnected digital world, cybersecurity begins long before an application reaches a user's device. It begins at the foundation, in the open-source libraries that form the bedrock of modern technology. Securing that foundation is no longer optional, but a necessity for the entire digital economy.