# Shai-Hulud 2.0: npm worm hit hundreds of packages, including PostHog SDKs, via preinstall scripts

Source: https://botpassword.com/incidents/2025-11-shai-hulud-2-npm-worm
Disclosed: 2025-11-24 · Type: Supply chain · Status: Contained · Updated: 2026-10-25

On 24 November 2025 a second wave of the Shai-Hulud worm published malicious versions of hundreds of npm packages, including PostHog's SDKs, that ran a `preinstall` script to install the Bun runtime and steal GitHub, npm and AWS, Google Cloud and Azure credentials. Stolen data went to public GitHub repositories described as "Sha1-Hulud: The Second Coming", and stolen npm tokens were used to infect more packages. Anyone who installed an affected version that day should rotate every credential on that machine or runner and check for a rogue self-hosted runner.

## What was exposed

Environment variables, local credential files such as Google Cloud application default credentials, cloud instance-metadata credentials, secrets read from AWS, Google Cloud and Azure secret stores, GitHub and npm tokens, and anything TruffleHog found on disk. Because the hook ran at `preinstall`, it executed even if the install later failed. Data was published to public GitHub repositories with 18-character random names. The malware also registered the machine as a GitHub self-hosted runner named `SHA1HULUD`, giving the attacker a remote command channel, and Datadog reports it tried to delete files in the home directory when it found no tokens to use.

## Who is affected

You are affected if a developer machine or CI runner installed a compromised version on or after 24 November 2025. PostHog's affected versions are `posthog-node` 4.18.1, 5.13.3 and 5.11.3, `posthog-js` 1.297.3, `posthog-react-native` 4.11.1, `posthog-docusaurus` 2.0.6, `posthog-react-native-session-replay` 1.2.2, `@posthog/agent` 1.24.1, `@posthog/ai` 7.1.2 and `@posthog/cli` 0.5.15; the PostHog script tag was not affected. For other packages, compare your lockfiles with Datadog's consolidated indicator list. On disk, look for `setup_bun.js`, `bun_environment.js`, `truffleSecrets.json` or a `~/.dev-env` directory, and in GitHub look for a runner named `SHA1HULUD` or repositories with the description "Sha1-Hulud: The Second Coming".

## What to do

1. Compare lockfiles and caches with the published indicator lists, delete `node_modules`, clear npm, yarn and pnpm caches, and reinstall versions published after the attack was contained.
2. Rotate GitHub tokens, npm tokens and cloud credentials on every affected machine and runner, and rotate secrets stored in AWS Secrets Manager, Google Secret Manager and Azure Key Vault that those credentials could read.
3. Remove any self-hosted runner named `SHA1HULUD`, delete the `~/.dev-env` directory, and review workflows that run on discussion events.
4. Delete any exfiltration repositories in your GitHub accounts and organizations, after saving what they reveal about which secrets leaked.
5. Disable install scripts by default (pnpm 10 does) and set a minimum release age for new versions, as PostHog did after the incident.

## Keys to rotate

- [GitHub](https://botpassword.com/keys/github)
- [npm](https://botpassword.com/keys/npm)
- [AWS (IAM access keys)](https://botpassword.com/keys/aws)
- [Google Cloud (service account keys and API keys)](https://botpassword.com/keys/google-cloud)
- [Azure (Microsoft Entra app client secrets)](https://botpassword.com/keys/azure)

## Timeline

- 2025-11-18: An external pull request to a PostHog repository abuses a `pull_request_target` workflow to send a bot's GitHub token to an attacker-controlled webhook, according to PostHog. ([source](https://posthog.com/blog/nov-24-shai-hulud-attack-post-mortem))
- 2025-11-23: PostHog says the attacker used that token to push a workflow change that dumped the repository's secrets, including the npm publishing token. ([source](https://posthog.com/blog/nov-24-shai-hulud-attack-post-mortem))
- 2025-11-24: Malicious PostHog versions are published from 04:11 UTC. PostHog deletes them, revokes publishing tokens and starts rotating credentials by 09:30 UTC. ([source](https://posthog.com/blog/nov-24-shai-hulud-attack-post-mortem))
- 2025-11-24: Datadog counts 796 unique packages and 1,092 versions affected, with the last affected package published at about 18:00 UTC, and more than 14,000 exfiltration repositories. ([source](https://securitylabs.datadoghq.com/articles/shai-hulud-2.0-npm-worm/))

## Indicators

- Files `setup_bun.js` and `bun_environment.js` with a new `preinstall` script in `package.json`.
- GitHub repositories described as "Sha1-Hulud: The Second Coming" with 18-character lowercase alphanumeric names.
- A self-hosted GitHub Actions runner named `SHA1HULUD` installed under `~/.dev-env`.
- A local file named `truffleSecrets.json`.

## Sources

- https://posthog.com/blog/nov-24-shai-hulud-attack-post-mortem
- https://securitylabs.datadoghq.com/articles/shai-hulud-2.0-npm-worm/
- https://status.posthog.com/incidents/kv3nj636f59c
