When a package install runs the attacker's code
Most developers think of a dependency as code that runs when their app runs. An npm package can also run code the moment it is installed, through lifecycle scripts such as preinstall and postinstall. A self-replicating worm abuses exactly that: its install script harvests whatever credentials are on the machine, developer npm and GitHub tokens, cloud keys, CI secrets, and then uses those credentials to publish a poisoned version of every other package the victim is allowed to publish. Each new victim becomes a new publisher. That is what makes it a worm rather than a one-off compromise.
A dependency does not have to wait for your app to run. It can run the attacker's code the moment you install it.
The waves
[Confirmed] The campaign has run in waves for more than a year. Dates and counts below are from each wave's primary source.
- GlobalSupply chain
Shai-Hulud: the first self-replicating npm worm
CISA warned that a self-propagating worm had compromised "over 500 packages" to steal GitHub tokens and cloud keys and republish itself.
Why it matters [Our assessment]
a developer laptop and a CI runner are credential stores. After any exposure, rotate developer and CI credentials and enforce phishing-resistant MFA on npm and GitHub, as CISA advised.
SourceCISA, Widespread Supply Chain Compromise Impacting npm Ecosystem, 23 September 2025.
- GlobalSupply chain
Sha1-Hulud, "the second coming"
A larger resurgence hit around 24 November 2025. Tenable counted "at least 800 compromised packages"; parallel analysis reported thousands of malicious repositories created with stolen tokens.
Why it matters [Our assessment]
the same control gaps as the first wave, at larger scale. Developers and CI accounts that reused the first wave's unrotated tokens were the ones re-hit.
SourceTenable, FAQ about Sha1-Hulud 2.0, the second coming of the npm supply-chain campaign, 24 November 2025.
- GlobalSupply chain
TanStack: valid provenance, poisoned packages (CVE-2026-45321)
Malicious versions of TanStack npm packages were published: "84 malicious versions across 42 @tanstack/* packages", tied by Tenable to the "Mini Shai-Hulud" wave.
Why it matters [Our assessment]
a valid provenance attestation did not mean safe code. The attacker abused the project's legitimate OIDC publishing pipeline, so provenance verified the pipeline, not the content.
SourceTanStack, GitHub Security Advisory GHSA-g7cv-rxg3-hmpx, 11 May 2026.
- GlobalSupply chain
The worm's source is open-sourced under MIT
Researchers reported the worm's source code published to GitHub under an MIT license, which lets anyone fork and rerun it.
Why it matters [Our assessment]
once the code is public, "which group did this" stops being answerable. Defend against the technique, not a named actor.
SourceZscaler, Shai-Hulud campaign evolution: Miasma, Hades and AI scanner evasion, 12 June 2026.
- GlobalSupply chain
Miasma: preinstall persistence through a Red Hat npm scope
Microsoft documented a credential-stealing wave it calls Miasma, which abused the
@redhat-cloud-servicesscope: "32 maliciously modified packages across more than 90 versions", with a dropper run from an npm preinstall hook.Why it matters [Our assessment]
preinstall and postinstall hooks run before your code ever does. Installing with scripts disabled would have stopped the dropper.
SourceMicrosoft, Preinstall to persistence: inside the Red Hat npm Miasma credential-stealing campaign, 2 June 2026.
[Reported] Vendors have tracked further branches, including a "Hades" wave in May 2026 and a PyPI variant that tried to evade AI code scanners (Zscaler, 12 June 2026), and a "Mini Shai-Hulud" strand active since late April 2026 across npm and PyPI (Tenable, 21 May 2026). The branches matter less than the shared mechanism.
TanStack: provenance is not the same as trust
[Confirmed] CVE-2026-45321 is the entry from this campaign in CISA's KEV catalog, added on 27 May 2026 and flagged for known ransomware use. It is worth dwelling on because it breaks a comforting assumption. TanStack publishes through a legitimate OIDC "trusted publishing" pipeline, and the malicious versions carried valid provenance. The attacker did not forge provenance; they abused the pipeline that produces it, through a pull_request_target "pwn request" and Actions cache poisoning. Provenance attested that the packages came from TanStack's real pipeline. It said nothing about whether the content was safe. That is the same CI weakness we cover in auditing your own GitHub Actions.
Controls that cut install-time risk
Mitigation
For developer machines and CI
Block install scripts by default. Install with
npm install --ignore-scripts, or setignore-scripts=truein.npmrc, and allow scripts only for the specific packages that genuinely need them. This alone stops the preinstall and postinstall droppers every wave above relied on.Pin and quarantine versions. Commit a lockfile, and do not auto-adopt brand-new releases. A short cooldown before a new version is allowed into builds means a malicious version is often pulled before you ever install it.
Publish through OIDC trusted publishing, not long-lived npm tokens, so there is no standing token on a laptop or runner to steal (npm docs). Keep provenance on, but treat it as "this came from the expected pipeline", not "this is safe".
Lock down CI. Least-privilege tokens, restricted outbound network access from runners, and ephemeral runners, so a malicious install script cannot reach the internet or your cloud freely.
Harden the accounts. Phishing-resistant MFA on npm and GitHub, as CISA advised; GitHub itself moved to shorten token lifetimes and disable token-based publishing by default after the first wave (GitHub blog, 22 September 2025).
If a dependency you use was hit
Response
01Scope it
Identify which projects and CI pipelines installed an affected package version, and in what window, from your lockfiles and build logs.
02Rotate what the install could see
Developer npm and GitHub tokens, cloud keys, and any CI secret reachable from the build. Rotate, do not just revoke sessions.
03Re-pin to a known-good version
Move to a release published before the compromise window, and turn on
--ignore-scriptsif it was not already.04Hunt for use of the stolen tokens
Review GitHub, npm and cloud audit logs for publishing or access from unexpected places after the exposure.
What we don't know
- The true number of downstream victims. Counts are per-wave and per-vendor, and the open-sourcing of the worm means later copies are hard to attribute or total.
- Whether a given organization's exposure led to real token theft. The rotation-and-hunt steps above answer that for your own estate.
If you want help reviewing how your pipelines handle dependencies, our secure code review and cloud penetration testing teams do this work. Every control above you can apply yourself.
Sources
9 sourcescisa.gov+7+5ShowHide
- 01cisa.gov
CISA, Widespread Supply Chain Compromise Impacting npm Ecosystem, 23 September 2025.
- 02github.blog
GitHub, Our plan for a more secure npm supply chain, 22 September 2025.
- 03tenable.com
Tenable, FAQ about Sha1-Hulud 2.0, 24 November 2025, and Mini Shai-Hulud FAQ, 21 May 2026.
- 04github.com
TanStack, GitHub Security Advisory GHSA-g7cv-rxg3-hmpx (CVE-2026-45321), 11 May 2026.
- 05cisa.gov
CISA, Known Exploited Vulnerabilities catalog, catalog version 2026.10.21, checked 22 October 2026.
- 06zscaler.com
Zscaler, Shai-Hulud campaign evolution: Miasma, Hades and AI scanner evasion, 12 June 2026.
- 07microsoft.com
Microsoft, Preinstall to persistence: inside the Red Hat npm Miasma credential-stealing campaign, 2 June 2026, and Postinstall payload inside the Mastra npm supply-chain compromise, 17 June 2026.
- 08docs.npmjs.com
npm docs, Trusted publishers and npm install (
--ignore-scripts). - 09attack.mitre.org




