Typosquatting and dependency confusion
Supply chain attacks that trick an install into fetching a malicious package: a lookalike name, or a public copy of a private package name.
Typosquatting publishes a malicious package under a name one typo away from a popular one, or a plausible variant, and waits for a developer or a script to install it. The package usually runs code on install and steals tokens and keys. Its AI-era cousin is slopsquatting: registering names that coding assistants invent. MITRE ATT&CK lists the broader technique as compromise of software dependencies.
Dependency confusion targets internal package names. In February 2021 Alex Birsan showed that when a company’s build checks both a private and the public registry, a public package with the same name and a higher version gets installed instead; he got his code running inside Apple, Microsoft and dozens of other companies. The fixes are scopes you own on the public registry, one private registry that proxies the public one, lockfiles and review of new dependencies. Hijacked real packages, as in the 2025 npm compromises, are a different supply chain attack.
Sources
- MITRE ATT&CK: T1195.001 Compromise Software Dependencies and Development Tools attack.mitre.org
- Alex Birsan: Dependency Confusion: How I Hacked Into Apple, Microsoft and Dozens of Other Companies medium.com
- npm Docs: scope docs.npmjs.com
- CISA: Widespread Supply Chain Compromise Impacting npm Ecosystem cisa.gov
Related terms
- Slopsquatting: Registering package names that AI coding tools hallucinate, so code that installs the made-up dependency pulls in the attacker’s package instead.
- Software supply chain attack: Compromising software through what it is built from: a package, a build tool, a CI action or a maintainer’s account.
- SCA (software composition analysis): Scanning an app’s open-source dependencies for known vulnerabilities, license problems and outdated versions, usually on every build.
- Secrets management (leaked API keys): Keeping API keys, passwords and tokens out of code and chats, in a store with access control, rotation and audit.
- Dependency updates (Dependabot, Renovate): Keeping libraries and frameworks current, usually with bots that open pull requests for new versions.
- SBOM (software bill of materials): A machine-readable list of every component and version inside a piece of software, like an ingredients label.
