How to check your project for malicious or compromised packages
When a supply-chain attack hits the news, the first question is always the same: did we install it? This guide shows how to answer that for every major ecosystem, what to do if the answer is yes, and how to be ready for the next one.
1. Find out whether the package is in your dependency tree
Attackers usually compromise a package you don’t depend on directly, so always search the full tree, including sub-dependencies, and check the exact version against the advisory.
| Ecosystem | Command |
|---|---|
| npm | npm ls <package> --all |
| pnpm | pnpm why <package> |
| Yarn | yarn why <package> |
| pip | python -m pip freeze | grep -i <package> |
| Poetry / uv | poetry show --tree · uv tree |
| .NET / NuGet | dotnet list package --include-transitive |
| Maven | mvn dependency:tree -Dincludes=<groupId>:<artifactId> |
| Gradle | ./gradlew dependencies |
| Go | go mod why -m <module> |
| Rust | cargo tree -i <crate> |
Also search lockfiles directly (package-lock.json, pnpm-lock.yaml, yarn.lock, poetry.lock, uv.lock, packages.lock.json) in every repository and branch you build from, plus CI caches and container images. A clean main doesn’t help if a release branch installed the bad version.
2. Check it against advisory databases
- OSV.dev aggregates CVEs, GitHub advisories and the OpenSSF malicious-packages feed (ids starting with
MAL-). - GitHub Advisory Database lists malware advisories for npm, PyPI, NuGet, Maven, RubyGems and more.
- CISA KEV tells you whether a CVE is being exploited in the wild, which matters more than its CVSS score.
3. If you installed a malicious version
- Assume the machine is compromised. Most recent npm malware runs at install time and steals credentials before you notice anything.
- Rotate secrets from a clean machine: cloud keys, GitHub and npm tokens, SSH keys, CI secrets, and anything in
.envfiles the install could read. - Remove the package and pin a known-good version, then clear package-manager caches (
npm cache clean --force, pip and CI caches). - Look for persistence: new GitHub tokens, repositories or workflow runs you didn’t create, and unexpected
.vscode/tasks.jsonor.claude/files in your repositories. - Rebuild anything built while the bad version was installed.
4. Be ready for the next one
- Commit lockfiles and install with
npm ci(or the equivalent), so builds don’t silently pick up a new release. - Don’t run install scripts by default. npm 12 only runs dependency install scripts you approve; on older versions set
ignore-scripts=truein.npmrc. - Wait before adopting new versions. Most compromised releases are caught within days, so a short release-age cooldown avoids many attacks.
- Harden CI: avoid
pull_request_targetworkflows that build fork code, pin third-party actions to commit SHAs, and give publish permissions only to the publish job. - Prefer packages with build provenance, but remember that provenance proves where a package was built, not that its source is safe.
- Check dependencies continuously, not only when an attack makes the news.
Automate the check with DepSentinel. DepSentinel is a free VS Code extension that does steps 1 and 2 for you in the background. It reads lockfiles and manifests for npm, yarn, pnpm, Maven, Gradle, Python, Go, Rust, Ruby, PHP and .NET, checks every dependency (including sub-dependencies) against OSV, marks CISA KEV vulnerabilities as exploited, and flags supply-chain warning signs such as new install scripts, brand-new packages, typosquats and dropped provenance. It also has a CLI for CI. No account or API key.
Recent incidents
- Nine PyPI “text-to-speech” packages that were really remote-code loaders (November 2026)
- CVE-2026-131914: an 18-year-old .NET library, actively exploited, with no patch coming (November 2026)
- Hijacked npm packages that read their next address from Ethereum (August 2026)
- ChainDrop: the npm worm that started in keyv and reached hundreds of packages (August 2026)
- Fake Paysafe, Skrill and Neteller SDKs: a credential stealer that looks like a payment library (July 2026)
- Red Hat’s npm packages backdoored: how the “Miasma” worm got in (June 2026)
- Shai-Hulud: from the first npm worm to the TanStack compromise (May 2026)