Get the free coreGet core

Shai-Hulud: the npm worm explained, and what to do if you were hit

Updated 6 min readSection 05 / Threats
SHORT ANSWER

Shai-Hulud npm packages carried a post-install script that harvested secrets and sent them to public GitHub repos named Shai-Hulud, starting 15 September 2025. It was the first successful self-propagating attack in the npm ecosystem. A later variant, Mini Shai-Hulud, also leaves a background program on the Mac that tries to wipe the home folder when a stolen token is revoked. If you may have installed a poisoned version, look first for the file ~/Library/LaunchAgents/com.user.gh-token-monitor.plist. If it is there, don't revoke any GitHub token yet, from any device, until that program is stopped. Then look for repos named Shai-Hulud in your GitHub account. Only then replace credentials, from a clean device, meaning a computer or phone that never installed the package.

A worm is malware that spreads from one victim to the next by itself. Shai-Hulud is the name given to the worm that moved through npm packages. This page gives the timeline, what it took, the trap in the Mini variant that can wipe your home folder, and the order of checks.

01Timeline of the Shai-Hulud attack

WhenWhat happened
15 Sep 2025Poisoned versions of several popular npm packages carry a post-install script that sends data to public repos named Shai-Hulud. The first successful self-propagating attack in npm
11 May 2026A Mini Shai-Hulud wave hits npm and PyPI packages, including the @tanstack namespace. On developer machines it installs a persistent daemon called gh-token-monitor

A different worm, ChainDrop, is covered in the npm supply chain attack history.

02Why a worm differs from one bad package

A single poisoned package reaches only the people who install that one package. A worm reaches further, because each victim becomes a way to hit the next. That is why the Shai-Hulud npm case was ranked among the most severe JavaScript supply chain attacks seen to date. In practice the package that hit you may be one you never typed. npm install installs a package and any packages that it depends on. A lockfile is the file where npm records the exact version of everything a project installed. Read it, not only the names you chose.

03What the Shai-Hulud attack did on your machine

The malicious versions ran a post-install script. npm 11 runs preinstall, install and postinstall scripts after it places modules in node_modules, so the code started the moment the install finished, with your user's permissions. The script then did two jobs.

It looked for secrets. The payload used TruffleHog, a secret scanning tool, to identify secrets, and harvested environment variables and cloud keys exposed through IMDS when available. Then it sent what it found to public GitHub repos the attackers had created, named Shai-Hulud. Public means anyone could read the data from those repos.

That is why a Shai-Hulud npm incident is a secrets problem first. Anything the install could read, such as environment variables, .env files and tokens in your shell, should be treated as copied. A similar campaign, Nx, searched for .env files, SSH keys and wallets on macOS and Linux. It has its own page: Nx.

04The Mini Shai-Hulud program that reacts to a revoked token

This part changes your order of work, and it applies to the Mini Shai-Hulud variant only. On developer machines the malware installs a persistent gh-token-monitor daemon, through a macOS LaunchAgent or Linux systemd. The daemon polls GitHub every 60 seconds. A LaunchAgent is a small background job that macOS starts when you log in. On a Mac this one lives in ~/Library/LaunchAgents/com.user.gh-token-monitor.plist. A token is the secret string that lets a program act as your GitHub account.

The daemon triggers when the token it checks is revoked. On that error it tries to run rm -rf ~/, which deletes your home folder. So the usual first reflex, revoking the token at once, is the wrong first move on a Mac where this file exists. The daemon also exits by itself after 24 hours without triggering. Looking for the file takes seconds, so do it before anything else.

05Shai-Hulud npm: what to check, in order

  1. Find out if you installed an affected version. Shai-Hulud came in poisoned versions of specific popular packages. Compare your installs with the package list in Wiz's write-up. If you cannot tell, treat steps 2 and 3 as the test, because they are quick.
  2. Look for the file on the Mac. Run this in Terminal: `` ls ~/Library/LaunchAgents/com.user.gh-token-monitor.plist `` If Terminal prints the path, the file is there. If it prints "No such file or directory", it is not.
  3. Look in your GitHub account for public repos named Shai-Hulud. That is where the first wave sent its data. Open your GitHub profile, go to Repositories and search for the name.
  4. If the file is there, don't revoke the GitHub token yet — from this Mac or any other device. The program checks the token on GitHub and fires when it is revoked. First stop it: macOS loads and unloads background agents with the launchctl command. In Terminal on that Mac run:
   launchctl bootout gui/$(id -u) ~/Library/LaunchAgents/com.user.gh-token-monitor.plist
   rm ~/Library/LaunchAgents/com.user.gh-token-monitor.plist

The first line removes the background program from your login session, the second deletes its file, as Wiz advises before any token is revoked. Or leave the token alone until the program exits by itself after 24 hours without firing. Only then revoke.

  1. Replace credentials from a clean device: right away if the file is not there, after step 4 if it was. Include the GitHub token, npm tokens, cloud keys and anything in environment variables or .env files.
  2. Check the logs or audit trail that show a secret being used. GitHub's guidance for a leaked secret includes exactly this.
  3. Clean the project. Reinstall from a lockfile you trust, with install scripts off where you can: the npm option ignore-scripts stops npm from running scripts in package.json files. The setting is described in npm's config docs.

The detail for replacing keys is on leaked API key, and for a hijacked GitHub account on GitHub account hacked. If you are unsure whether anything ran, the infostealer check lists signs on a Mac.

06How to lower the odds next time

Shai-Hulud npm infections began with a normal install. Four habits make a second one less likely:

The same pattern exists on the Python side: see PyPI malware. For the other routes onto a Mac, see npm malware.

To see when a package script starts something on your Mac, the free, open-source core of Artificial Immunity watches program starts and reports what it finds.

FAQ

What is Shai-Hulud?

It is an npm attack that began on 15 September 2025, when malicious versions of several popular packages carried a post-install script that harvested sensitive data and sent it to public GitHub repos named Shai-Hulud. It was the first successful self-propagating attack in the npm ecosystem.

What did the Shai-Hulud worm steal?

The payload used TruffleHog to identify secrets and harvested environment variables, along with cloud keys exposed through IMDS when available. IMDS is the metadata service that cloud machines use to hand out credentials.

Should I revoke my GitHub token right away?

Not before you look for the file ~/Library/LaunchAgents/com.user.gh-token-monitor.plist on the Mac. In the Mini Shai-Hulud variant, the program that file starts tries to run rm -rf ~/ when the token it checks is revoked. If the file is there, stop that program or wait the 24 hours until it exits, then revoke — revoking from another device sets it off too.

Does Shai-Hulud affect Macs?

The Mini Shai-Hulud variant does: it installs a macOS LaunchAgent at ~/Library/LaunchAgents/com.user.gh-token-monitor.plist, and on Linux it uses systemd.

How do I know if I was hit?

Check your GitHub account for public repos named Shai-Hulud, then look for the gh-token-monitor file on your Mac.

Is the rm -rf trap permanent?

No. The daemon exits automatically after 24 hours without triggering the destructive handler.

Sources

  1. Wiz, Shai-Hulud npm supply chain attack
  2. Wiz, Mini Shai-Hulud strikes again
  3. Wiz, s1ngularity supply chain attack
  4. GitHub docs, remediating a leaked secret
  5. npm docs, scripts
  6. npm docs, config
  7. Apple, script management with launchd
  8. Artificial Immunity
Installed packages on a Mac with GitHub tokens? Artificial Immunity watches the Mac where your agents work.Get the free core