Security operations

Shai-Hulud npm Supply Chain Attack: How the Worm Spread and How to Stop It

Shai-Hulud turned one compromised npm package into hundreds, using stolen maintainer tokens. Here is how the worm worked and what stops the next wave.

Cysoro Security TeamPublished · 7 min read
npmSECURITY OPERATIONSShai-Huludnpm wormOne package. Hundreds infected.
Quick answer

Shai-Hulud is a self-propagating supply chain worm that hit the npm registry from September 2025. A poisoned package's install script stole npm, GitHub and cloud credentials from the installing machine, then used the victim's own publish rights to release infected versions of every package they maintained, spreading without further attacker input.

Key takeaways

  • Shai-Hulud spread by stealing npm publish tokens at install time, then republishing infected versions of the victim's own packages.
  • Over 500 packages were infected in the first wave, including the widely used @ctrl/tinycolor library.
  • Defense means pinning dependencies, removing long-lived publish tokens, using trusted publishing and scanning installs.

On September 14, 2025, a small authentication package received a poisoned update. Within a day, the worm inside it had reached one of the most downloaded libraries in JavaScript. Within days, over 500 packages were infected — not by an exploit, but by npm working exactly as designed.

What is the Shai-Hulud npm supply chain attack?

Shai-Hulud is a self-propagating supply chain worm that has hit the npm registry in waves since September 2025. A poisoned package's install script steals npm, GitHub and cloud credentials, then uses the victim's own publish rights to inject the worm into every package they maintain.

The name comes from the giant sandworms in Dune. Researchers chose it because the worm burrows through the dependency tree on its own, using each compromised maintainer's credentials to infect the next package. It needs no software vulnerability: it needs an install hook that runs arbitrary code and a publish credential sitting on the machine where packages are installed.

The campaign is attributed to a group tracked as TeamPCP. In August 2026, Australian police charged two men in connection with the campaign, after an investigation with the FBI found the malware had compromised more than 1,000 organizations and exposed roughly 500,000 credentials, according to the Cloud Security Alliance.

When did Shai-Hulud happen?

The first malicious publish was rxnt-authentication version 0.0.3 at 17:58 UTC on September 14, 2025. The next day, @ctrl/tinycolor — a color-manipulation library downloaded more than two million times a week — received two malicious versions, and the alarm went up.

By September 16, the worm had reached packages maintained by CrowdStrike, and Socket's indicator list for the first wave covered 526 package versions. CISA issued an alert on September 23, 2025, describing a self-replicating worm infiltrating npm through compromised maintainer accounts.

WaveFirst seenWhat changedScale
Shai-Hulud14 Sep 2025postinstall script runs bundle.js526 versions; over 500 packages
Sha1-Hulud24 Nov 2025Bun runtime, preinstall trigger, wiper fallbackHundreds of packages; tens of thousands of GitHub repos exposed
Mini Shai-HuludApr 2026npm and PyPI, defeated SLSA provenance attestationOver 170 packages; CVE-2026-45321

Later waves kept the same loop with new tricks. The November 2025 wave used the Bun runtime instead of Node.js to dodge detection tooling, and the 2026 Mini Shai-Hulud wave compromised packages with valid SLSA Build Level 3 provenance attestations, showing that process controls alone could be defeated. Tenable's Mini Shai-Hulud FAQ documents the later campaign and CVE-2026-45321.

How did Shai-Hulud spread?

Shai-Hulud spread in a five-step loop that repeated automatically. Each compromised machine funded the next wave of infections, with no further input from the attackers.

The Shai-Hulud loop1Installpoisoned packageruns install script2StealTruffleHog scansfor tokens and keys3Exfiltratesecrets sent toattacker server4Republishworm injected intovictim's packages5Repeatnext install startsthe loop againNo exploit needed: the victim's own publish rights did the spreading.
The Shai-Hulud self-propagation loop. Illustration by Cysoro.
  1. Install: a developer or CI system installs a poisoned package, and its postinstall script runs a large obfuscated file called bundle.js automatically.
  2. Steal: the payload downloads the open-source secret scanner TruffleHog, points it at the local filesystem and environment variables, and harvests npm, GitHub, AWS, GCP and Azure credentials.
  3. Exfiltrate: stolen secrets are sent to attacker infrastructure, and a public GitHub repository named Shai-Hulud is created in the victim's account, with a workflow file called shai-hulud-workflow.yml.
  4. Republish: the worm enumerates every package the stolen npm token can publish and releases infected versions of them.
  5. Repeat: anyone installing those newly poisoned packages starts the loop again.

The worm also made private repositories public in some cases, migrating private and internal repositories from GitHub organizations to the victim's account. That turned a credential theft into a data exposure incident as well.

What did Shai-Hulud steal?

Credentials, first and foremost. The payload harvested NPM_TOKEN and GITHUB_TOKEN values, plus AWS, GCP and Azure keys, wherever TruffleHog found them on the infected machine.

That matters because build machines and developer laptops are credential-rich: they hold publish tokens, cloud keys, CI secrets and GitHub tokens, often in environment variables or config files. One install on a maintainer's laptop could therefore compromise every package that maintainer owned, and every cloud account whose keys were present.

The second-wave variant added a destructive fallback: if credential theft failed, it could wipe data. That turned a stealthy supply chain worm into a potential availability incident too. Our small business cybersecurity checklist covers credential hygiene that limits this kind of blast radius.

Why did Shai-Hulud work so well?

It exploited defaults, not bugs. For a decade, npm packages could run arbitrary code at install time through preinstall and postinstall scripts, and developers routinely kept long-lived publish tokens on the same machines where they installed packages.

Three structural weaknesses combined. First, install scripts run with the full privileges of the user installing the package. Second, a single npm token often has publish rights to many packages, so one theft infects a whole portfolio. Third, dependency trees are deep and opaque: installing one package can pull in dozens of transitive dependencies, any of which could be poisoned.

Phishing played a role at the start. The initial maintainer compromises are assessed to have begun with phished credentials, which then let attackers publish the first poisoned versions. After that, the worm did the rest itself.

How do I check if I was affected?

Check installs, publishes and GitHub accounts, in that order. The window that matters is September 2025 onward, including later waves into 2026.

  • Check your lockfiles: look for any of the 526 first-wave package versions in Socket's indicator list, or later-wave versions flagged by your dependency scanner.
  • Check GitHub: search your account and organizations for repositories named Shai-Hulud, branches named shai-hulud, and workflow files called shai-hulud-workflow.yml.
  • Check for unexpected public repos: private repositories that became public are a strong sign of compromise.
  • Review npm publish history: look for versions you did not publish, especially ones published shortly after you installed a new dependency.
  • Audit cloud usage: look for unfamiliar API calls, new keys or unexpected costs in AWS, GCP and Azure.

If anything matches, treat it as a full incident: rotate credentials, revoke tokens, and follow the steps in our incident response guide rather than quietly deleting the package and moving on.

What should you do if you were affected?

Rotate everything the infected machine could have seen, then rebuild trust in your packages. Partial cleanup leaves the worm a way back in.

  1. Revoke and rotate: npm tokens, GitHub personal access tokens, cloud keys and CI secrets present on any machine that installed a poisoned version.
  2. Remove malicious versions: work with npm support to deprecate or remove poisoned versions, and pin your projects to known-clean versions.
  3. Clean GitHub: delete the Shai-Hulud repositories, branches and workflow files, and review organization audit logs for other changes.
  4. Rebuild affected packages: republish clean versions from a trusted, clean build environment, not from the infected machine.
  5. Check for persistence: look for new GitHub Actions workflows, new collaborators and new deploy keys.
  6. Report it: in the US, report to CISA and the FBI's IC3, and notify downstream users of your packages.

How can teams prevent the next Shai-Hulud?

Prevention has two halves: stop install scripts from being a free credential harvest, and stop one stolen token from publishing everything you own.

Six defenses against the next Shai-Hulud1. Pin dependencies and review updates2. Block or sandbox install scripts3. Replace long-lived tokens with trusted publishing4. Scope tokens to one package, short expiry5. Scan dependencies in CI before they ship6. Keep publish credentials off install machines
Defenses against npm supply chain worms. Illustration by Cysoro.
  • Pin dependencies: commit a lockfile and review version updates, especially patch releases of popular packages that arrive without explanation.
  • Control install scripts: npm 12, released in July 2026, closed the install-hook half of the problem by changing how install scripts are handled. Until you are on it, disable or sandbox install scripts where you can.
  • Use trusted publishing: publish from CI with short-lived, identity-based credentials instead of a long-lived token stored on a laptop.
  • Scope tokens: one token per package where possible, with short expiry and two-factor authentication on the npm account.
  • Scan in CI: run a software composition analysis tool on every build, and block builds that introduce new install scripts or known-malicious versions.
  • Separate install from publish: never keep publish credentials on machines that install untrusted packages.

Enable two-factor authentication on npm and GitHub for every maintainer, and require it for your organization. A phished password alone should never be enough to publish a poisoned release.

What are the lasting lessons of Shai-Hulud?

Shai-Hulud proved that a supply chain worm does not need a zero-day. It needs a trusted ecosystem, a convenient automation feature, and credentials that are easier to steal than to protect.

It also showed that provenance is not a silver bullet. Mini Shai-Hulud compromised packages with valid SLSA Build Level 3 attestations, which means a clean build record does not prove the code going in was clean. Defenders need both build integrity and code review of what is actually being published.

The arrests in 2026 closed a chapter on specific defendants, but the tooling was open-sourced in mid-2026, and copycat campaigns followed. The vulnerability is structural, so the fix has to be structural too: fewer install scripts, shorter-lived credentials, and verified publishes. Socket's Shai-Hulud glossary entry tracks the waves and indicators in detail.

Check your own public exposure with our free SSL checker and keep an inventory of the packages your business actually depends on.

The bottom line

Shai-Hulud was not a sophisticated exploit. It was a simple loop — install, steal, republish, repeat — running on defaults the whole JavaScript ecosystem had accepted for years.

Break the loop at any point and the worm stops: block install scripts, remove long-lived publish tokens, or scan dependencies before they reach production. Do one of those this week, and your project will be far harder to turn into the next wave's carrier.

Frequently asked questions

What is the Shai-Hulud npm attack?

Shai-Hulud is a self-propagating worm that infected npm packages from September 2025. Its install script stole credentials from machines that installed a poisoned package, then used those credentials to publish infected versions of other packages.

How did Shai-Hulud spread?

Through npm install scripts. When a developer or CI system installed a poisoned package, a postinstall script ran automatically, harvested npm and GitHub tokens, and republished the worm into every package those tokens could publish.

Which packages were affected by Shai-Hulud?

Over 500 packages in the first wave, including @ctrl/tinycolor, a library with more than two million weekly downloads. Later waves, including Sha1-Hulud and Mini Shai-Hulud, reached hundreds more packages across npm and PyPI.

What did Shai-Hulud steal?

Npm and GitHub tokens, plus AWS, GCP and Azure cloud credentials, harvested by running the TruffleHog secret scanner against the infected machine. It also created public GitHub repositories and workflows in victims' accounts.

Is Shai-Hulud still a threat?

Yes. Later waves appeared in November 2025 and into 2026, and the tooling was open-sourced in mid-2026, enabling copycat campaigns. The underlying risks, install scripts and long-lived publish tokens, remain in many projects.

How do I know if I was affected by Shai-Hulud?

Check whether you installed or published any package versions listed in Socket's or CISA's indicators of compromise, rotate all npm, GitHub and cloud credentials that were present on build machines, and audit your GitHub repositories for unexpected public repos or workflows.

How do I protect my project from npm supply chain attacks?

Pin dependencies with a lockfile, audit new versions before upgrading, avoid running install scripts from untrusted packages, use short-lived trusted publishing instead of long-lived tokens, and scan dependencies in CI.

Sources

  1. Socket — Shai-Hulud (npm worm)
  2. Kaspersky Securelist — Shai-Hulud worm infects npm packages
  3. Tenable — Mini Shai-Hulud Supply Chain Attack CVE-2026-45321 FAQ
  4. Cloud Security Alliance — The Shai-Hulud Playbook: TeamPCP and Supply-Chain Ecosystem Risk
  5. CISA — Cybersecurity Advisories
Written & fact-checked byCysoro Security Team

The engineers and analysts who build Cysoro's domain scanner, email-authentication checks and free security tools. We test what we write about every day — SPF, DKIM, DMARC, certificates, look-alike domains and phishing — and check each guide against the relevant standards, government guidance and vendor documentation.

  • Email authentication
  • Phishing & BEC
  • Domain & DNS security
  • Small-business security

Checked against Socket, Kaspersky Securelist, Tenable and Cloud Security Alliance research on the Shai-Hulud campaign.

How we write and fact-check →

Free tools for this topic

No account needed.

See where your domain stands

Free for up to 3 domains. No card, no installs.

Start free