NPM typosquatting is a supply chain attack that uses package names that closely resemble legitimate ones, hoping a developer or automated process will install the wrong dependency. In Node.js environments, the tactic becomes especially dangerous when a typo is introduced into a lockfile or build process accepts it without review.
Expanded Definition
NPM typosquatting is a software supply chain tactic that exploits human error and automation trust in the JavaScript ecosystem. It targets package managers, CI pipelines, and dependency review workflows by registering names that are visually similar to legitimate packages, then waiting for a mistyped install command or an unreviewed dependency update. In practice, the risk is not limited to developers typing the wrong package name. It also appears when build scripts, templating systems, or compromised tooling introduce a package reference that looks plausible enough to pass casual review.
The concept sits within broader package confusion and dependency trust problems, but it is narrower than generic malware delivery because the attacker relies on naming resemblance as the initial access path. That makes it relevant to software supply chain governance and to identity-adjacent controls where automated systems consume untrusted artifacts without strong verification. The NIST Cybersecurity Framework 2.0 is useful here because it frames supply chain risk, protective controls, and detection expectations in a governance context. Definitions vary across vendors on how far “typosquatting” extends into package impersonation versus broader dependency confusion, so precision matters when writing policy or incident findings.
The most common misapplication is treating typosquatting as a developer training issue only, which occurs when teams ignore automated dependency ingestion, lockfile manipulation, and CI install steps.
Examples and Use Cases
Implementing controls against NPM typosquatting rigorously often introduces friction in developer workflows, requiring organisations to balance fast dependency resolution against stronger verification and review.
- A developer intends to install a common utility package but misses one character, and the malicious lookalike package is pulled into a project during routine setup.
- A build pipeline resolves dependencies automatically from a package index, so a newly published impostor package is accepted before anyone notices the naming similarity.
- A compromised or careless internal script references a near-match package name, causing the wrong code to be embedded in a release artifact.
- An organisation uses allowlisting and provenance checks to block suspicious package names before they reach the repository, aligning with controls discussed in OWASP guidance on software and model supply chain risks.
- Security teams monitor package publisher behaviour, sudden namespace changes, and first-seen dependencies to detect lookalike packages before they spread across environments.
These use cases show why the problem is not just a typo, but a trust failure at the point where build systems decide what code is allowed to enter the software estate. In modern delivery pipelines, that decision can affect release integrity, downstream consumers, and any service that inherits the compromised package.
Why It Matters for Security Teams
NPM typosquatting matters because it turns routine dependency management into an attack surface. Once a malicious package is installed, it can steal secrets, alter build outputs, or create a persistent foothold inside development and deployment environments. Security teams need to understand the term in the context of software supply chain risk, not just endpoint malware, because the compromise often begins before runtime detection has a chance to help.
The issue also intersects with identity and secret management when package install scripts can reach tokens, certificates, or CI credentials stored in build contexts. That makes controls around signing, provenance, privilege separation, and dependency approvals especially important. Teams that track supply chain guidance through the NIST Cybersecurity Framework 2.0 can map the term to governance, protection, and detection outcomes, while package verification practices can be reinforced with internal policy and repository controls. The risk is often discovered only after a suspicious dependency has already been built, shipped, or used to exfiltrate credentials, at which point NPM typosquatting becomes operationally unavoidable to address.
Standards & Framework Alignment
This section maps relevant standards and security frameworks to the operational risks and controls described in this guidance.
OWASP Non-Human Identity Top 10 address the attack and risk surface, while NIST CSF 2.0 and NIST SP 800-53 Rev 5 set the governance and control requirements practitioners need to meet.
| Framework | Control / Reference | Relevance |
|---|---|---|
| NIST CSF 2.0 | ID.SC-2 | Covers supply chain risk management relevant to lookalike package abuse. |
| OWASP Non-Human Identity Top 10 | Highlights secret and token exposure risks when untrusted code executes in automation. | |
| NIST SP 800-53 Rev 5 | SA-12 | Addresses supply chain protection for system components and acquired software. |
Treat dependency install paths as secret-exposure surfaces and restrict build credentials.