What Is Malicious Package?
A malicious package is malware delivered as an open source library and published to a public registry such as npm or PyPI. It is built or altered to steal credentials, open a backdoor or damage systems, often runs as soon as it is installed, and usually has no CVE, so vulnerability scanners alone can miss it.
Also known as:
What a Malicious Package Is
A malicious package is malware delivered as an open source library and published to a public package registry such as npm or PyPI. OpenSSF, which runs the largest shared database of these reports, treats a package as malicious when installing or using it would require incident response because of a loss of confidentiality, integrity or availability, or when it exfiltrates an identifier an attacker can use for a follow-up attack. A malicious package is different from a vulnerable one. A vulnerable package has a bug that someone might exploit, while a malicious package was built or altered to do harm, so it is often reported without any CVE at all.
How Malicious Packages Get Into Your Code
- Typosquatting. An attacker publishes a package whose name is one keystroke away from a popular one and waits for someone to mistype an install command.
- Dependency confusion. A public package reuses the name of a company's internal package, so a build tool that checks the public registry pulls the attacker's version instead.
- Account and maintainer takeover. An attacker steals a maintainer's credentials or token and publishes a poisoned version of a trusted package, which then flows to everyone who depends on it, including through transitive dependencies.
- Install scripts. Ecosystems such as npm run lifecycle scripts like
preinstallandpostinstallduring installation, so malicious code can run on a developer laptop or CI runner before the application ever imports it.
Why Malicious Packages Are So Damaging
A malicious package runs with the access of whatever installs it. On a CI runner or a developer machine that often means source code, cloud credentials, registry tokens and deployment keys. In September 2025, CISA warned about a self-replicating worm known as Shai-Hulud that had compromised over 500 npm packages. Its malware scanned for credentials such as GitHub personal access tokens and cloud API keys, exfiltrated them, and used the stolen npm access to publish compromised versions of other packages. Because these packages often carry no advisory, scanners that only match known CVEs can report a clean result while the malware is already installed.
How to Defend Against Malicious Packages
- Check every dependency against malware intelligence. Use sources such as the OpenSSF Malicious Packages repository, published in the OSV format, and GitHub's malware advisories, not just vulnerability advisories.
- Gate installs, not only builds. Check lockfiles before packages are installed, so a malicious install script never gets the chance to run.
- Pin and lock dependencies. Commit lockfiles, avoid floating version ranges and pin CI actions, so a new poisoned release can't slip in silently.
- Wait before adopting new releases. A dependency cooldown keeps freshly published versions out until the community has had time to spot and report a compromise.
- Know where every package runs. When a compromise is disclosed, you need to answer which repositories use the package, at which versions and for how long.
- Report what you find. Registries such as npm accept malware reports and remove confirmed malicious packages.
How Nullify Stops Malicious Packages
The Nullify Defender GitHub Action blocks known-malicious and vulnerable packages before they are installed. It reads the lockfiles in a repository, checks every locked coordinate against the Nullify vulnerability database, and fails the check when a package is malicious or when its resolved artifact does not come from the public registry. It downloads and executes nothing from the dependency tree, and a confirmed malicious package always blocks unless a reviewed allowlist entry exempts it. Nullify Supply Chain Posture Management flags dependencies at a version Nullify's malware index has confirmed malicious, along with typosquatting, dependency confusion and packages that run install scripts. Malicious-package findings block pull requests at their own severity, whatever the enforcement floor is set to. A match against the OpenSSF malicious-package feed can produce a malicious verdict even when no vulnerability advisory exists. When a malicious package is disclosed, Dependency Exposure answers whether you use it and where, with version-aware and time-aware precision. Explore Nullify Code Security.
Key Takeaways
- A malicious package is malware published to a registry such as npm or PyPI, not a library with an accidental bug.
- Typosquatting, dependency confusion, maintainer account takeover and install scripts are the main ways they reach your code.
- They often have no CVE, so checks must use malware intelligence such as the OpenSSF Malicious Packages repository.
- Gating installs from lockfiles, pinning dependencies and knowing where each package runs limit the damage.
Read More About Malicious Package
Code Security
See Nullify in Action
Block known-malicious packages before they install.