Explore our new Cybersecurity Terms Glossary, explained by our experts.
Cybersecurity Terms Glossary
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.

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.
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.
The behaviour differs by ecosystem, and the detail decides whether you are exposed.
--index-url rather than --extra-index-url is the difference between one source and two.@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.npm ci or pip install --require-hashes, so a surprise version cannot be introduced silently.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.
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.
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.
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.
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.
You May Be Interested In These
We use a few cookies that are needed to make this website work, and they are always on. We would also like to set analytics cookies, to see which pages are useful; functional cookies, so that our live chat works; and advertising cookies, to measure our campaigns. We will not set any of those until you say yes, and you can change your mind at any time from the Cookie Settings link in the footer.
Choose the cookies you are happy for us to use. Strictly necessary cookies are always on; everything else is off until you turn it on.
These cookies keep the website working: they hold your security checks, your form submissions and the choice you make here. The site cannot run without them, so they are always on.
These let our live chat open and remember your conversation, and let the newsletter sign-up work. Switch them off and the chat window will not appear.
These tell us which pages are read and how people find us, so that we can improve the site. The reports are about groups of visitors, never about you personally.
These let us measure our advertising and show you our adverts on other websites, such as LinkedIn, Google and Meta. Switch them off and you will still see adverts, but they will be less relevant.