# Shai-Hulud Worm > A self-replicating npm (later PyPI/RubyGems) credential-stealing worm: an install hook harvests secrets, dumps them into attacker-readable GitHub repos, and uses stolen npm tokens or hijacked CI publish identities to trojanize every package the victim maintains. ## How it works Generic kill chain, stable across waves: 1. **Execution at install** — injected lifecycle hook (`postinstall` in wave 1; `preinstall` from 2.0 on, so it runs before tests/scans; `binding.gyp` in the Miasma wave; `prepare` on an injected git `optionalDependencies` entry in TanStack). 2. **Harvest** — `process.env` dump (catches `GITHUB_TOKEN`, `NPM_TOKEN`, cloud keys), `~/.npmrc`, `~/.aws/credentials`, cloud SDK/IMDS calls, and `trufflehog filesystem / --json` for high-entropy secrets (e.g. `AKIA[0-9A-Z]{16}`). Later variants scrape CI runner memory and hunt 469 credential locations, including AI agents (Cursor, Gemini, `~/.claude/projects/*.jsonl` session history), Jenkins and crypto wallets. 3. **Exfil** — create a repo under the victim's own GitHub account and commit JSON (`contents.json`, `environment.json`, `cloud.json`, `truffleSecrets.json`); later AES-256-GCM + RSA-OAEP encrypted. Side channels: `webhook.site`, Session/Oxen P2P (`filev2.getsession[.]org`), GitHub GraphQL "dead-drop" commits. 4. **Propagate** — validate token via `/whoami`, enumerate `/-/v1/search?text=maintainer:<user>&size=N`, then for each package: inject payload, `npm version patch --force && npm publish --access public --token $T`. 5. **Persist / destroy** — malicious workflows, self-hosted runners, IDE/agent hooks, OS daemons; wiper fallbacks. ## Waves | Wave | Date | Mechanics / IOCs | |---|---|---| | **Shai-Hulud (1)** | Sep 2025 | `@ctrl/tinycolor` (2M+ weekly), `ngx-bootstrap` 20.0.4–20.0.6, `ng2-file-upload`; 500+ pkgs. ~3.6 MB Webpack `bundle.js` via `postinstall`; propagates to 20 pkgs/maintainer; public repo named `Shai-Hulud`; pushes branch `shai-hulud` + `.github/workflows/shai-hulud-workflow.yml` exfiltrating `${{ toJSON(secrets) }}` to `webhook.site/bb8ca5f6-…`; flips private repos public. Believed downstream of the [[Malicious Packages#Notable cases|Nx s1ngularity]] token leak. | | **2.0 "Sha1-Hulud: The Second Coming"** | Nov 2025 | 796 pkgs / 1,092 versions, 20M+ weekly downloads, 25K+ repos exposed. `preinstall` → `setup_bun.js` installs Bun → runs `bun_environment.js` (Bun evades Node-focused monitoring). Backdoors up to 100 pkgs/maintainer. Repo description `Sha1-Hulud: The Second Coming.`; if no GitHub token, it **searches GitHub for other victims' repos** and reuses their tokens. Registers a self-hosted runner `SHA1HULUD` in `~/.dev-env` plus a workflow triggered on `discussion` with `run: echo ${{ github.event.discussion.body }}` — deliberate expression injection as C2. Fallback wiper: `find "$HOME" -type f -writable … | xargs -0 shred -uvz -n 1`. Commits authored as "Linus Torvalds". | | **3.0 "Golden Path"** | Dec 2025 | `@vietmoney/[email protected]`; re-obfuscated from source, cross-platform, better error handling; timed to holidays and the npm move to trusted publishing. | | **Mini Shai-Hulud (TeamPCP)** | Apr–Aug 2026 | `@bitwarden/[email protected]` (via compromised GitHub Actions, 334 devs); SAP `mbt`, `@cap-js/{sqlite,postgres,db-service}` (`"preinstall": "node setup.mjs"` → Bun 1.3.13 → `execution.js`; 1,200+ exfil repos); PyPI `lightning` 2.6.2/2.6.3, `intercom-client` 7.0.4; TanStack (84 versions / 42 pkgs); `@antv` (300+ versions, `"preinstall": "bun run index.js"`, beacon `niagA oG eW ereH :duluH-iahS`); `keyv`/`flat-cache`/`cacheable` (`setup.mjs` + `Math_Symbol.js`). Token-revocation monitor triggers a machine wipe. Persistence by poisoning Claude Code and VS Code config. | | **Miasma / descendants** | Jun–Nov 2026 | `binding.gyp` execution (sonatype-2026-003581); RubyGems `strutil-core` exfiltrating to `paleasbest[.]top` with Python backdoor and revocation-triggered wiper; `[email protected]` with valid provenance. | ### TanStack: worm meets CI hijack (May 11 2026) No maintainer token was stolen — TeamPCP hijacked the legitimate release pipeline: 1. [[Pwn Requests|Pwn Request]]: fork PR (commit spoofing `claude <[email protected]>`, `[skip ci]`) against a `pull_request_target` workflow sharing the base repo's cache scope. 2. Cache poisoning: wrote a 1.1 GB poisoned pnpm store under the exact key `release.yml` restores (`actions/cache@v5` post-job save doesn't block writes); sat ~8 h until a push to `main`. 3. OIDC theft: attacker binaries found `Runner.Worker` via `/proc/*/cmdline` and dumped `/proc/<pid>/mem` for the on-demand OIDC token (technique from [[tj-actions changed-files Compromise]]). 4. Published 84 versions **with valid SLSA provenance** — the first documented malicious npm packages with valid provenance — even though the workflow's publish step was skipped. Payload `router_init.js`; downstream OpenAI had two employee devices compromised and rotated macOS code-signing certs. The AntV wave went further: an `optionalDependencies` entry pointing at an **orphan commit** in the real `antvis/G2` repo (fork created, commit pushed, fork deleted — GitHub keeps the object), plus Fulcio certificates minted with stolen OIDC tokens to forge Sigstore attestations. See [[SBOM and Provenance]]. ## Notable cases - Attribution: TeamPCP (aka DeadCatx3, PCPcat, ShellForce, CipherForce) claimed TanStack; shared hardcoded strings link Bitwarden, SAP and TanStack to one codebase. Victims include Trivy, LiteLLM, Mercor, OpenAI, Mistral AI and the European Commission. - May 2026: TeamPCP open-sourced the worm and ran a BreachForums "biggest attack" contest; clones followed within days (`chalk-tempalte`, alongside Axios typosquats `axois-utils`, `@deadcode09284814/axios-util`). - 26 Aug 2026: AFP/FBI charged two Western Australian men over TeamPCP. ## Defenses - Hunt: GitHub code search `org:<org> path:**/shai-hulud-workflow.yml`; branches named `shai-hulud`; repos with the 2.0 description or beacon string; self-hosted runners named `SHA1HULUD`; `DiscussionEvent` on unexpected repos; outbound `*.getsession.org`. - Treat any host that installed an affected version as **fully compromised**: rebuild, then rotate npm/GitHub/cloud/Vault creds. Revoking a GitHub token can trigger the wiper — image first. - `npm ci --ignore-scripts` / disable lifecycle scripts (npm 12 disables `preinstall` by default); dependency cooldowns / soak time (a 72 h rule blocked `[email protected]`); isolate CI install from publish. - Publishing: npm [trusted publishing](https://docs.npmjs.com/trusted-publishers) (OIDC, short-lived) instead of long-lived tokens, 2FA on publish — but TanStack shows OIDC publishing is only as strong as the workflow; avoid `pull_request_target` + shared caches ([[GitHub Actions Security]]). - Commit-signature verification (fake "Linus Torvalds"/`claude` authors), Harden-Runner style egress monitoring on CI. ## Related - [[Software Supply Chain Security]] - [[Malicious Packages]] - [[GitHub Actions Security]] - [[Pwn Requests]] - [[tj-actions changed-files Compromise]] - [[CI-CD Pipeline Attacks|CI/CD Pipeline Attacks]] - [[SBOM and Provenance]] - [[Secret Scanning]] - [[Leaked Cloud Credentials]] - [[AI Coding Assistant Risks]] ## Sources - [[raw/stepsecurity.io/shai-hulud-self-replicating-worm-compromises-500-npm-packages-4047|Shai-Hulud: Self-Replicating Worm Compromises 500+ NPM Packages — StepSecurity]] - [[raw/reversinglabs.com/shai-hulud-npm-supply-chain-attack-overview-4048|Shai-Hulud npm supply chain attack overview — ReversingLabs]] - [[raw/snyk.io/zero-day-extensive-npm-package-compromise-shai-hulud-supply-chain-atta-9011|Zero-day Extensive NPM Package Compromise — Snyk]] - [[raw/wiz.io/shai-hulud-ongoing-package-supply-chain-worm-delivering-data-stealing-9222|Shai-Hulud: ongoing package supply chain worm — Wiz]] - [[raw/securitylabs.datadoghq.com/shai-hulud-2-0-npm-worm-analysis-4052|Shai-Hulud 2.0 npm worm: analysis — Datadog]] - [[raw/wiz.io/shai-hulud-2-0-25k-repos-exposed-4050|Shai-Hulud 2.0: 25K+ Repos Exposed — Wiz]] - [[raw/microsoft.com/shai-hulud-2-0-detection-and-defense-guidance-4051|Shai-Hulud 2.0: Detection and Defense Guidance — Microsoft]] - [[raw/unit42.paloaltonetworks.com/shai-hulud-worm-compromises-npm-ecosystem-4049|Shai-Hulud worm compromises npm ecosystem — Unit 42]] - [[raw/snyk.io/the-holiday-whisper-shai-hulud-3-0-8915|The Holiday Whisper: Shai-Hulud 3.0 — Snyk]] - [[raw/ox.security/shai-hulud-the-third-coming-bitwarden-cli-backdoored-in-latest-supply-6743|Shai-Hulud: The Third Coming — Bitwarden CLI backdoored — OX]] - [[raw/aikido.dev/mini-shai-hulud-targets-sap-npm-packages-with-a-bun-based-secret-steal-7750|Mini Shai-Hulud Targets SAP npm Packages — Aikido]] - [[raw/snyk.io/tanstack-npm-packages-hit-by-mini-shai-hulud-7901|TanStack npm Packages Hit by Mini Shai-Hulud — Snyk]] - [[raw/snyk.io/mini-shai-hulud-hits-antv-300-malicious-npm-packages-published-via-com-8709|Mini Shai-Hulud Hits AntV — Snyk]] - [[raw/ox.security/the-antv-ecosystem-was-compromised-with-shai-hulud-malware-300-package-8117|The @antv Ecosystem Was Compromised — OX]] - [[raw/blog.gitguardian.com/mini-shai-hulud-s-latest-wave-280-new-places-it-hunts-for-your-secrets-11184|Mini Shai-Hulud's Latest Wave: 280 New Places — GitGuardian]] - [[raw/aikido.dev/keyv-and-friends-compromised-in-active-shai-hulud-supply-chain-attack-11081|Keyv and friends compromised — Aikido]] - [[raw/sonatype.com/new-shai-hulud-miasma-wave-hits-hundreds-of-npm-packages-8647|New Shai-Hulud Miasma Wave — Sonatype]] - [[raw/socket.dev/shai-hulud-descendant-surfaces-in-malicious-ruby-gem-that-steals-crede-13842|Shai-Hulud Descendant in Malicious Ruby Gem — Socket]] - [[raw/securityweek.com/first-shai-hulud-worm-clones-emerge-8079|First Shai-Hulud Worm Clones Emerge — SecurityWeek]] - [[raw/bitdefender.com/shai-hulud-hackers-two-men-charged-over-teampcp-s-global-supply-chain-11794|Shai-Hulud hackers: two men charged — Bitdefender]] - [[raw/hextrap.io/tensorlake-0-5-144-a-worm-with-valid-provenance-and-the-firewall-rule-12277|[email protected]: A Worm With Valid Provenance — Hextrap]] - [[raw/ox.security/8-3m-downloads-compromised-lightning-intercom-client-infected-in-lates-7726|Lightning / intercom-client infected — OX]]