Zennoxa Shield
Application Security Glossary

Dependency Confusion

Dependency confusion is a supply chain attack where an attacker publishes a malicious package to a public registry using the same name as an organization's private internal package, tricking the build system into installing the attacker's version instead.

Dependency confusion exploits how package managers resolve names when a project depends on internal packages that share a namespace with public registries. If a build tool is configured to check both a private registry and a public one, and the public registry has a package with the same name and a higher version number, the resolver may fetch the public — attacker-controlled — package by mistake.

The attack works because many package ecosystems default to preferring the highest available version across all configured sources. An attacker who learns the name of a company's internal package (often leaked in a manifest file, error message, or public repository) simply publishes a package with that exact name and a large version number to the public registry, and waits for a CI build to pull it in and execute its install scripts.

Developer defenses include scoping or namespacing internal packages, explicitly pinning trusted source registries per package, using version pinning and lockfiles, and configuring the package manager so internal names can only ever resolve from the private registry. This is a well-documented class of supply chain risk that automated scanners and registry policies now specifically look for.

Frequently asked questions

What is dependency confusion?
Dependency confusion is a supply chain attack in which an attacker uploads a malicious package to a public registry using the same name as a company's private internal package. Build tools that prefer the highest version across sources may then install the attacker's package.
How do you prevent dependency confusion?
Namespace or scope internal packages, pin each dependency to a specific trusted source registry, use lockfiles and version pinning, and configure the package manager so internal names resolve only from your private registry rather than the public one.
Dependency confusion vs typosquatting?
Dependency confusion abuses a name that legitimately exists as a private package by publishing a public collision, whereas typosquatting registers a misspelled variant of a popular public package hoping developers install it by accident. Both are supply chain attacks.

Related terms

Dependency Confusion — Zennoxa Glossary — Zennoxa Shield