This repository contains guidance and scripts for responding to the Shai-Hulud Supply Chain Attack on npm Packages.
If you are looking for guardrails against similar attacks, see:
- vet for scanning your projects for malicious packages
- vet-action for integrating
vetinto your GitHub workflows - pmg for preventing malicious package installation in developer machines
The Shai-Hulud supply chain attack started with compromise of multiple npm packages to distribute malware to developers. The malware was designed to steal credentials, source code and other sensitive information from infected systems. Technical details of the attack and the payload can be found in the SafeDep Incident Report.
If you believe you are affected by this attack, follow the steps below:
- Scan your systems for indicators of compromise (IoCs) listed below
- Rotate credentials available in compromised systems
- Follow the guidance to harden against similar attacks in the future
- Setup guardrails to protect against malicious open source packages
- Harden your developer workflows to prevent npm based supply chain attacks
- Malicious package versions data/ioc/malicious-package-versions.jsonl
- Malicious payload hashes data/ioc/malicious-payload-hashes.jsonl
vet is required to run this scan. Install vet using:
brew install safedep/tap/vetLook at vet/README.md for other installation options.
Run a full file system scan using vet and create an sqlite3 database of all discovered package versions:
./scripts/pv-scan.shNote
Enrichment is explicitly disabled for this scan because malicious package versions are already known from the IOC list.
Tip
You can optionally set the WORKSPACE_DIR environment variable to specify a custom directory for storing scan results. If not set, /tmp will be used by default.
export WORKSPACE_DIR=/path/to/your/workspace
./scripts/pv-scan.shRun the query script to query the generated database for known malicious package versions:
./scripts/pv-query.shWarning
Scanning for payload hashes is compute intensive and may take a long time to complete.
Run the script to scan the file system for files matching known malicious payload hashes:
./scripts/pv-payload-hash-scan.shOptionally, you can specify a custom path to scan instead of the entire filesystem:
./scripts/pv-payload-hash-scan.sh /path/to/scanThe malicious payload delivered through the attack compromised credentials available in the infected systems. Rotate all known credentials, particularly the following:
- Npm credentials available in
$HOME/.npmrcor$NPM_TOKENenvironment variable - GitHub credentials of developers using affected systems
- AWS credentials available in
$HOME/.aws/credentialsor$AWS_ACCESS_KEY_IDand$AWS_SECRET_ACCESS_KEYenvironment variables - AWS credentials available in AWS Secrets Manager that were accessible from affected systems
- Google Cloud credentials and credentials stored in Google Cloud Secret Manager that were accessible from affected systems
- SSH private keys, especially if they were passwordless
The malicious payload also used TruffleHog to extract secrets from source code repositories available in the infected system. Consider running TruffleHog and rotating any secrets found in infected systems.
- Install SafeDep vet or similar tools to scan open source packages for malicious code before merging pull requests or deploying code.
- Install SafeDep pmg or similar tools to prevent installation of malicious packages in developer machines.