A quick tool for npm package scanning
Published September 15th, 2025
tl;dr: npm stands for nerfed package manager
In case you missed it, two popular npm packages (chalk
and debug
) were compromised last week.
I wrote a short script for quickly testing if a repo depends on any of the affected libraries. It makes use of CycloneDX to create a Software Bill of Materials (SBOM), and then queries that SBOM using jq
. Let’s walk throug how to use it.
How to scan for compromised packages
Make a local copy of the script
Copy the following code into a file named node-guard.sh
:
Run the script
Run the script by using the following command:
If it is not a Node.js project, the script will exit with code 0
, after logging:
If no compromised package versions are detected, the script will exit with code 0
and output logs similar to the following:
If an affected package was found, the script will exit with code 1
and output logs similar to the following (note that this is flagging version 4.4.1 of debug
, which is not actually the compromised version— this is for testing/illustrative purposes):
If you have a lot of projects to run this on, you can use something like all repos to automate running this script against all your repositories.
Conclusion
Supply chain security has been neglected for too long in the history of the tech industry. It became more important after the SolarWinds cyber attack. The SLSA Framework is the best model we have for thinking about supply chain security, but it doesn’t really address dependency threats.
We must focus on preventing/detecting maliciously-modified dependencies, or managing vulnerabilities in dependencies, since those would be brought into the final software being built. SBOMs help in this regard, as they serve to document what versions of what dependencies go into the software. They can be used with SLSA to make a lot of progress.
Open source maintainers are the target of increasingly sophisticated social engineering attacks, and we must be vigilant. Every software that team relies on open source should be package scanning. Here is one more tool for your toolbox. Feel free to use it the next time a vulnerability arises.