Explore our new Cybersecurity Terms Glossary, explained by our experts.

View the Glossary View the Glossary
PRIVIA

Cybersecurity Terms Glossary

What Is Dependency Confusion?

Dependency confusion is a supply chain attack in which a package uploaded to a public registry under an internal package name is installed in preference to the genuine private one.

Illustration for the cybersecurity term Dependency Confusion
Home / Blog / Cybersecurity Terms / What Is Dependency Confusion?
17 November 2026

What Is Dependency Confusion?

What Is Dependency Confusion?

Dependency confusion exploits a resolution rule rather than a bug. When a build tool is configured with both a private registry and a public one, many of them query both and install whichever copy has the highest version number. An attacker who learns the name of an internal package can publish something with the same name and a version of 99.0.0 to npm or PyPI, and the next build pulls their code instead of yours.

The Research That Named It

Alex Birsan published the technique on 9 February 2021 under the title “Dependency Confusion: How I Hacked Into Apple, Microsoft and Dozens of Other Companies”. He harvested internal package names from JavaScript bundles, leaked manifest files, and GitHub commits, then uploaded same-named packages that phoned home with the hostname and current path on installation. Callbacks arrived from more than 35 organisations, among them Apple, Microsoft, PayPal, Shopify, Netflix, Yelp, and Tesla, and the disclosures earned over $130,000 in bug bounties.

Within days of publication, researchers and opportunists had uploaded tens of thousands of speculative packages to npm named after companies they hoped were vulnerable. The technique has not gone away: it remains one of the simplest ways into a build environment, because it requires no access to any of the victim’s systems.

Why Build Tools Behave This Way

The behaviour differs by ecosystem, and the detail decides whether you are exposed.

Closing the Gap

  1. Use namespaces you own. Scoped npm packages such as @yourcompany/widget cannot be published by anyone else once the scope is registered, and the same applies to NuGet prefix reservation and Maven group IDs tied to a domain you control.
  2. Point builds at a single registry. A proxy such as Artifactory, Nexus, or Azure Artifacts should be the only source, with explicit exclude patterns so internal names are never fetched upstream.
  3. Map sources to packages. NuGet package source mapping and npm’s per-scope registry configuration bind each name to one origin.
  4. Defensively register the names of your internal packages on public registries as empty placeholders. It is inelegant and it works.
  5. Commit lockfiles and build with the frozen equivalents such as npm ci or pip install --require-hashes, so a surprise version cannot be introduced silently.
  6. Block install scripts where you can, since most proof-of-concept payloads run during installation rather than at import time.

Seeing It When It Happens

Dependency confusion is loud if you are watching the right place. A build agent making an outbound DNS or HTTP request to a domain nobody recognises, during the install step, is the signature Birsan relied on. Egress filtering from build runners turns that signal into a block. Keeping a software bill of materials for each release lets you answer the question that follows an incident: which builds contained the unexpected package, and where did they ship.

The control that covers the widest ground is software composition analysis with provenance checks, so that a dependency resolving to an unexpected registry is treated as a failure rather than a curiosity. The NCSC’s supply chain security guidance frames the same expectation for suppliers and build pipelines, and this class of attack is a standard part of the scope when we carry out a penetration test that includes the development environment.

FAQ – Frequently Asked Questions

How Would an Attacker Learn Our Internal Package Names?

From material you have already published. Names leak in JavaScript bundles served to browsers, in committed lockfiles and manifest files on public repositories, in container images pushed to public registries, in job adverts and conference talks, and in error traces posted to support forums. None of this requires access to your network, which is why the attack is so cheap to attempt.

Does a Private Registry Alone Solve It?

Only if it is the sole source. Most private registries are deployed as caching proxies that forward requests they cannot satisfy to the public registry, which recreates the exact condition the attack needs. Configure exclude patterns so internal namespaces are never requested upstream, and verify the behaviour by requesting a package name that does not exist internally.

Is This the Same as Typosquatting?

No. Typosquatting relies on a developer mistyping a name, such as an extra or missing character, so it depends on human error. Dependency confusion uses the exact correct name and relies on the resolver preferring a higher version from the wrong source. The defences differ: typosquatting is addressed by review and lockfiles, confusion by namespace ownership and source pinning.

What Should We Check First?

List every internal package name used in your builds, then check whether each one is unclaimed on the matching public registry. Next, inspect build configuration for more than one package source, particularly pip extra index URLs and proxy registries with upstream fallback. Those two checks, done once, cover the majority of the realistic exposure.

Related Terms

You May Be Interested In These

What Is an Attack Vector?

Cybersecurity Terms

17 November 2026

What Is an Attack Vector?

Read More
What Is the FREAK Attack?

Cybersecurity Terms

17 November 2026

What Is the FREAK Attack?

Read More
What Are Canary Accounts?

Cybersecurity Terms

17 November 2026

What Are Canary Accounts?

Read More