Skip to the content
AI and Cybersecurity Learning and Practice Center Test automation Open the Learning Center

IncidentSupply chain

Shai-Hulud: self-replicating worm spreads through npm

CriticalCrowdStrike (packages affected)

A self-spreading worm infected more than 500 npm packages. Installing one stole the developer's secrets, then used their npm access to infect every other package they maintained.

Replay the attack step by step in the Learning Center

How it happened

  1. An infected version ran a script automatically through npm's postinstall hook.
  2. It dumped environment variables and ran a secret scanner to find GitHub, npm and cloud credentials.
  3. It posted the secrets to a public GitHub repository in the victim's account and added a malicious workflow.
  4. With a stolen npm token it injected itself into up to 20 of the maintainer's packages and published new versions.

Impact

Developer and CI/CD credentials were harvested and private code exposed across many organizations.

The fix

GitHub removed the packages and announced npm hardening: mandatory 2FA, short-lived tokens and trusted publishing.

Lessons

  • Disable install scripts in CI where possible and pin dependencies with lockfiles.
  • Replace long-lived tokens on developer machines with short-lived, scoped credentials.
  • Watch for unexpected public repositories and workflows, and rotate quickly after exposure.

Sources