🕑 Estimated reading time: 4 minutes  |  Last updated: May 8, 2026

On 15 September 2025, malicious versions of popular npm packages began spreading a worm dubbed Shai-Hulud. Its install script harvested secrets such as npm tokens, GitHub tokens and cloud keys, published them to public repositories, and used stolen npm tokens to push infected versions of other packages, making it the first widely reported self-propagating attack in the npm ecosystem. A second wave followed later in 2025. Defences include pinning dependencies, using lockfiles, delaying adoption of brand-new versions, disabling install scripts where possible, short-lived tokens and secret scanning.

Lines of HTML codes

Modern JavaScript applications are built from hundreds, sometimes thousands, of open-source packages pulled from the npm registry. Developers install them in seconds with a single command. That convenience is also a risk: if one widely used package is poisoned, the malware can reach thousands of projects almost instantly. In September 2025, the npm ecosystem saw a nightmare version of that scenario, a worm that spread itself.

What Shai-Hulud Did

On 15 September 2025, security researchers spotted malicious versions of popular npm packages. Named after the giant sandworms in Dune, the malware, “Shai-Hulud,” ran when a developer or build system installed an infected package:

  1. A post-install script searched the machine for secrets, using a legitimate secret-scanning tool, and collected environment variables and cloud credentials.
  2. If it found GitHub tokens, it created public repositories named “Shai-Hulud” containing the stolen secrets, and in some cases made private repositories public.
  3. It added malicious GitHub Actions workflows to repositories to exfiltrate more secrets.
  4. Most alarmingly, if it found npm publishing tokens, it automatically published infected versions of other packages that the token could access, spreading itself further.

Security firms described it as the first successful self-propagating attack in the npm ecosystem. Hundreds of package versions were affected before npm and GitHub responded, and a further wave, often called Shai-Hulud 2.0, appeared later in 2025. Earlier that summer, attackers had also compromised other widely used packages and the Nx build system, showing a sustained campaign against developer tooling.

Why Developers Are Prime Targets

How to Protect Your Projects

Control what you install

Limit what packages can do

Protect your secrets

Protect maintainer accounts

Detect and respond

How the Ecosystem Is Responding

GitHub, which runs npm, announced plans after the attacks to tighten publishing security, including shorter-lived tokens, broader MFA requirements and wider use of trusted publishing. Regulations are pushing in the same direction: the EU Cyber Resilience Act will require commercial software makers to manage vulnerabilities in the open-source components they ship.

Review dependency updates before they reach production

Shai-Hulud proved that a supply chain attack can spread on its own. Every team that uses open source, which is virtually every team, should treat dependency installation as a security-sensitive operation: pin versions, slow down upgrades, isolate builds and keep secrets short-lived. Those habits turn a worm outbreak from a crisis into a manageable incident.

Frequently Asked Questions

Do I need to stop using npm?

No. Open source is essential; the goal is to consume it more safely.

How do I know if I was affected?

Check your lockfiles and build logs against published lists of compromised versions, and look for unexpected repositories, workflows or token activity.

Does this only affect JavaScript?

Similar attacks have targeted Python, Ruby and other package ecosystems; the defences are much the same.

Leave a Reply

Your email address will not be published. Required fields are marked *