Hunter-Case-06 - Shai-Hulud Worm NPM Package Supply Chain

- Shai-Hulud: The novel self-replicating worm infecting hundreds of NPM packages

1.) Information

Hunter Blue's day started everyday with researching the cyber security news for new Threat Huntings tasks to execute them on customer datalakes.

-> Interesting report from sysdig: https://www.sysdig.com/blog/shai-hulud-the-novel-self-replicating-worm-infecting-hundreds-of-npm-packagesarrow-up-right

>>>>>>Once executed, this novel worm — dubbed Shai-Hulud — steals credentials, exfiltrates them, and attempts to find additional NPM packages in which to copy itself. The malicious code also attempts to leak data on GitHub by making private repositories public.<<<<<<

You should investigate the initial Entry and Execution to search through the logs with these IoCs / IoAs to find the right artifacts for Threat Hunting.

Compromised npm Packages and Versions but many more are affected

The following packages were confirmed to include malicious code on September 8, 2025. Only the versions listed below are known to be compromised.

Color & Styling Utilities

ANSI / Terminal String Handling

General Utilities

Debugging & Logging

Experimental / Miscellaneous

Attacker-Controlled Cryptocurrency Wallets

Ethereum (ETH)

  • 0xFc4a4858bafef54D1b1d7697bfb5c52F4c166976 (primary)

  • 0xa29eeFb3f21Dc8FA8bce065Db4f4354AA683c024

  • 0x40C351B989113646bc4e9Dfe66AE66D24fE6Da7B

Bitcoin (BTC)

  • 1H13VnQJKtT4HjD5ZFKaaiZEetMbG7nDHx

  • bc1qms4f8ys8c4z47h0q29nnmyekc9r74u5ypqw6wm

Solana

  • 5VVyuV5K6c2gMq1zVeQUFAmo8shPZH28MJCVzccrsZG6

Function Selectors Targeted (Ethereum)

  • 0x095ea7b3 – approve()

  • 0xa9059cbb – transfer()

  • 0x23b872dd – transferFrom()

  • 0xd505accf – permit()

Malware Code Characteristics

  • Hooks into fetch(), XMLHttpRequest, and window.ethereum.request.

  • Environment checks for browser objects (typeof window !== ‘undefined’).

  • Levenshtein algorithm for wallet address substitution.

  • Hidden control object: window.stealthProxyControl.

Phishing Infrastructure

  • Domain: npmjs[.]help

  • IP: 185.7.81.108

  • Email: support[at]npmjs[dot]help

  • Malicious CDN: static-mw-host.b-cdn[.]net, img-data-backup.b-cdn[.]net

  • Remote host: websocket-api2.publicvm[.]com

  • Example phishing URL: https://www.npmjs[.]help/settings/qix/tfa/manageTfa?action=setup-totp

2.) Indicators of Compromise

Indicators of compromise

Type
Value
Notes / usage

SHA256

46faab8ab153fae6e80e7cca38eab363075bb524edd79e42269217a083628f09

Malicious bundle.js listed in report. Unit 42arrow-up-right

SHA256

b74caeaa75e077c99f7d44f46daaf9796a3be43ecf24f2a1fd381844669da777

IOC from report. Unit 42arrow-up-right

SHA256

dc67467a39b70d1cd4c1f7f7a459b35058163592f4a9e8fb4dffcbba98ef210c

IOC from report. Unit 42arrow-up-right

SHA256

4b2399646573bb737c4969563303d8ee2e9ddbd1b271f1ca9e35ea78062538db

IOC from report. Unit 42arrow-up-right

URL (webhook)

https://webhook[.]site/bb8ca5f6-4175-45d2-b042-fc9ebb8170b7

C2 / exfil endpoint used by the malware. Use webhook.site (dot replaced) when searching. Unit 42arrow-up-right

Filename / Workflow

shai-hulud-workflow.yml

Malicious YAML workflow filename called out. Unit 42arrow-up-right

GitHub repo name

Shai-Hulud

Malware creates public repo named Shai-Hulud to publish exfiltrated secrets. Unit 42arrow-up-right

Tool abuse indicator

trufflehog

Legit tool abused by actors for secrets discovery — hunt for usage. Unit 42arrow-up-right

  • Tool: trufflehog execution

  • Defender XDR Hunting

  • Other SOC Customer Case where Defender already flagged the malicious npm packages

2.1) Executions from Threat Actor - Steps

  • worm executes during the post-install phase of the compromised NPM packages, running a huge bundle.js script

  • code targets Linux and macOS machines, performing multiple operations in parallel to spread itself in the NPM package registry and steal sensitive information like credentials

  • Shai-Hulud conducts local system discovery

  • searching for sensitive details on the machine, including GitHub and NPM credentials, as well as credentials for AWS and GCP

  • spread itself and compromise other ecosystems

  • worm uses the GitHub user and their credentials ( ghp_* and gho_* tokens), iterating over the repositories belonging to the user

  • gain persistence and steal their associated secrets via a malicious GitHub action that is invoked on a “push” action

  • receive the credentials, the site https://webhook[.]site is used

  • trufflehog binary is downloaded and used to search for other sensitive credentials in the filesystem

  • Shai-Hulud also contains code that looks for AWS and GCP credentials, searching both locally in the file system and any Instance Metadata Service (IMDS) endpoints

  • malicious JavaScript checks again if the GitHub user is authenticated. If so, it creates a new GitHub repository named “Shai-Hulud”, where the previously found credentials are uploaded in a base64 encoded JSON file

2.2) Indicators of Compromise - Executions

3.) Initial Access

  • worm executes during the post-install phase of the compromised NPM packages, running a huge bundle.js script

4.) Finding through Threat Hunting

  • We hunted through the Datalake logs in the whole infrastructure and yes you guess it right we found a malicious execution not related to legit admin tasks which was also confirmed by the system owner (macOS user), so we saved the "life" of this company.

5.) Mitigation

Strengthen Supply Chain Controls

  • Pin dependencies to verified versions and use ‘npm ci’ instead of ‘npm install’ to enforce lockfile consistency. While this strengthens supplychain integrity, it adds complexity for developers (slower iteration, lockfile conflicts, harder testing of new versions). Whether to enforce strict reproducibility should be decided based on each team’s risk appetite and operational needs.

  • Conduct security awareness training for developers to identify phishing and credential harvesting attempts. Include this case-study to demonstrate the risk.

  • Integrate automated dependency scanning tools (e.g., Snyk, Semgrep, Mend.io, Socket.dev) into CI/CD pipelines to flag malicious or anomalous packages early.

  • Mirror critical open-source packages in private registries and vet updates before internal distribution.

Rebuild and Redeploy

  • Recompile and redeploy all applications that previously included compromised dependencies to remove malicious code from runtime environments.

  • For web applications, publish clean client-side builds immediately to eliminate malware exposure for new sessions.

Remove and Replace Malicious Packages

  • Uninstall compromised versions immediately and upgrade to patched releases (e.g., [email protected] or later).

  • If a patch is not out yet, roll back to the last known good version before the incident (e.g., downgrade [email protected] to 6.0.0) and lock your dependency there.

  • Perform a clean reinstall:

  • Delete the node_modules directory.

  • Clear the npm cache.

  • Regenerate lockfiles to ensure all code is sourced from trusted versions.

HOST and user

  • reset all passwords

  • clear NPM Cache

  • remove NPM node_modules

  • generate new package-lock.json

  • rotate All Tokens

  • restage the host

Secure Secrets and Tokens

Assume that secrets may have been exfiltrated from ‘build’ or ‘runtime’ environments where compromised packages were present.

  • Rotate all private keys, API tokens, and credentials used in affected CI/CD pipelines and applications.

Audit Dependencies

  • Inventory all applications, services, and build pipelines for use of affected package versions.

  • Use lockfiles (package-lock.json, yarn.lock) or a Software Composition Analysis (SCA) tool to pinpoint instances of vulnerable packages.

  • Use a read-only dependency scanner to identify compromised package versions listed in this advisory. For example, the Open Tools Vulnerable Packages Scannerarrow-up-right supports npm, yarn, pnpm, and bun lockfiles, generates a JSON report, and can be integrated into CI pipelines to fail builds when a match is detected.

  • Begin with a scan only or dry run mode. Once confirmed, replace affected packages, regenerate lockfiles, and redeploy updated applications.

6.) Detection and Hunting

6.1) Sigma Rules

6.2) Linux Commandline Hunting

6.3) Hunting Queries Microsoft Defender XDR

6.4) Hunting Queries Palo Cortex XDR

6.5) Hunting Queries Tanium EDR

7.) Conclusion and Learning for a Hunter Blue

  • The NPM incident reveals Supply chain attacks are increasing in frequency. It is more important than ever to monitor third-party packages for malicious activity. Since malicious code can be hidden in many different ways, using runtime threat detection is critical to catching these attack

  • its definitely necessary to check during Hunting or Initial Triage how Malware was staged

  • -> showcasing how fruitful Compromise Assessment Hunting and Time Line Analysis can be and should be used in such cases -> it is essential.

Last updated