This tool helps you detect compromised npm packages in your project's lock files (package-lock.json and pnpm-lock.yaml). It was created in response to the S1ngularity/nx supply chain attack that affected numerous packages, as documented in the Aikido Security blog post.
The attack involved malware that:
- Steals secrets and credentials
- Exfiltrates data to attacker-controlled servers
- Self-propagates through npm by infecting other packages
- Turns private repositories public
- Creates malicious GitHub Actions workflows
The tool scans your lock files against a list of known compromised packages and versions, alerting you if any are found in your dependencies.
- Node.js must be installed on your system (version 18 or higher recommended)
- The script files should be in the same directory as your
bad-packages.txtfile
This tool uses zero external dependencies - it only requires Node.js built-in modules (fs, path, etc.) and doesn't need any npm install commands. All functionality is self-contained within the script files.
./check-compromised.shcheck-compromised.bator
check-compromised.cmdFor ES module projects:
node check-compromised.jsFor CommonJS projects:
node check-compromised.cjs- Loads the bad packages list from
bad-packages.txt(187+ packages currently) - Scans recursively for
package-lock.jsonandpnpm-lock.yamlfiles in:- The current directory
- All subdirectories
- Including inside
node_modulesfolders
- Checks dependencies against the compromised list
- Reports findings:
- Lists all found lock files with full paths
- Shows compromised packages in red text
- Displays a green success message if no issues are found
Loaded 187 bad packages from bad-packages.txt
Found 2 pnpm-lock.yaml file(s):
- /path/to/project/pnpm-lock.yaml
- /path/to/project/node_modules/.pnpm/some-package/pnpm-lock.yaml
Checking /path/to/project/pnpm-lock.yaml...
Checking /path/to/project/node_modules/.pnpm/some-package/pnpm-lock.yaml...
Check complete.
Everything looks good! No compromised packages found.
If compromised packages are found:
Compromised in pnpm-lock.yaml: @ahmedhfarag/ngx-perfect-scrollbar@20.0.20
The bad-packages.txt file contains the list of compromised packages. To update it:
- Edit
bad-packages.txt - Add new entries in the format:
package-name<TAB>version1,version2 - Save the file
- Re-run the script
The current list is based on the packages documented in the Aikido Security blog post.
check-compromised.js- ES module versioncheck-compromised.cjs- CommonJS versioncheck-compromised.sh- macOS/Linux shell scriptcheck-compromised.bat- Windows batch filecheck-compromised.cmd- Windows command filebad-packages.txt- List of compromised packageshow-to-check.md- This documentation
If compromised packages are found:
- Remove them from your dependencies
- Clear your npm/pnpm cache
- Reinstall all packages
- Check for any leaked secrets or credentials
- Consider using tools like Aikido SafeChain for future protection
For more details about the attack, see: S1ngularity/nx attackers strike again