Dependency Confusion
Dependency confusion is a type of software supply chain attack in which an attacker publishes a malicious package to a public registry using the same name as a private, internal package used by a target organization. When a package manager fetches dependencies, it may retrieve the attacker's public package instead of the intended private one, causing malicious code to be executed in the target environment. The attack exploits how certain package managers resolve naming conflicts between public and private registries.
A dependency confusion attack exploits the dependency resolution logic of package managers (such as npm, pip, or RubyGems) that, when configured to check both public and private registries, may preferentially fetch a package from the public registry if it exists there with a matching or higher version number than the internally hosted equivalent. An attacker identifies a private package name used by a target organization (typically via disclosed build artifacts, job postings, or source code) and registers a package with the same name on a public registry, often with an artificially high version number to maximize the likelihood of selection. If the victim's build environment resolves the public package before the private one, the malicious payload is pulled and executed during the build or install process. This attack is a subset of software supply chain security concerns focused on component integrity, and is distinct from typosquatting in that it uses an exact name match rather than a visually similar one.
Why it matters
Dependency confusion attacks are significant because they exploit a trusted, automated process: dependency resolution during software builds. When package managers silently fetch a malicious public package in place of a legitimate internal one, the malicious code executes in a privileged build environment, often with access to secrets, credentials, and internal infrastructure. This makes the attack particularly dangerous because it requires no direct compromise of the target organization's source code or infrastructure. The attacker merely needs to register a package on a public registry.
In 2021, security researcher Alex Birsan demonstrated the viability of dependency confusion at scale by successfully executing proof-of-concept attacks against major technology companies including Apple, Microsoft, and others, receiving significant bug bounty payouts. This disclosure drew widespread industry attention to the attack class and prompted many organizations to audit their package manager configurations and private registry setups.
The attack is difficult to detect through conventional means. Static analysis of an application's declared dependencies may not flag the issue, because the package name itself appears legitimate in configuration files. The confusion exists at the resolution layer, meaning detection typically requires runtime or build-time controls such as registry pinning, version verification, or integrity checks, rather than code review alone.
Who it's relevant to
Inside Dependency Confusion
Common questions
Answers to the questions practitioners most commonly ask about Dependency Confusion.