Malicious Code Vulnerability in @selfpentest/bin-confusion: A Threat to npm Users
Summary
MAL-2026-17292: Malicious code in @selfpentest/bin-confusion (npm). Affects @selfpentest/bin-confusion versions 1.0.0 – 1.0.1. No fix is published. How to fix ↓
Check if this vulnerability affects your application
Upload a manifest or SBOM and we'll show whether you're affected, plus every other risky package in the same scan.
No signup required · Results in about 60 seconds
Background
The package @selfpentest/bin-confusion is an npm package that is designed to demonstrate security vulnerabilities in dependency management. It contains a malicious script that collides with the core npm CLI, potentially compromising the security of projects that include it as a dependency. This package is particularly concerning due to its ability to exfiltrate sensitive information from the environment and SSH configurations.
Vulnerability Detail
The vulnerability arises from the package registering a 'bin' entry named 'npm' that points to a malicious script (npm.js). When this package is installed, any invocation of 'npm...' in the consuming project's scripts resolves to this malicious shim, executing harmful code instead of the legitimate npm CLI. The malicious script collects sensitive data, including environment variables and SSH known_hosts, and sends it to a local server, creating a significant risk for users who inadvertently include this package in their projects.
How To Fix
This package is malicious. Remove it and rotate any credentials it could have accessed.
npm uninstall @selfpentest/bin-confusion
If it arrived as a transitive dependency, remove the package that pulled it in, then reinstall.
Tip — Not sure whether your app is affected? Vulert can check the versions your app actually runs. Scan free →
Workaround
As a temporary workaround, avoid using any scripts that invoke 'npm...' commands in your project until you have removed the malicious package. Additionally, you can manually check your package-lock.json file for any references to @selfpentest/bin-confusion and remove them.
Conclusion
The @selfpentest/bin-confusion package poses a significant security risk due to its malicious code that can exfiltrate sensitive information. It is essential for developers to remove this package from their projects and to utilize tools like Vulert for ongoing monitoring of vulnerabilities in their dependencies.
See every vulnerability recorded for @selfpentest/bin-confusion →
FAQ
The vulnerability can lead to the exfiltration of sensitive information from your environment, including SSH keys and secrets, which can be exploited by attackers.
You can use Vulert, which monitors open-source vulnerabilities in your software. By simply uploading your package-lock.json file, you can receive real-time alerts about vulnerabilities.
To prevent similar vulnerabilities, regularly audit your dependencies and use tools like Vulert to monitor for known vulnerabilities in your packages.
If you have installed @selfpentest/bin-confusion, immediately uninstall it using 'npm uninstall @selfpentest/bin-confusion' and check your environment for any compromised data.
Yes, you can continue to use npm normally after removing the malicious package. Ensure that your other dependencies are secure and up to date.