Safeguard
Supply Chain•

Does an SCA scanner catch dependency confusion?

Sometimes, but not reliably. Dependency confusion is a resolution problem, so the fix is registry configuration, with scanning as a second check.

Safeguard Security Team
3 min read

Only partly. Dependency confusion happens when your package manager picks a public package over your private one of the same name. A software composition analysis (SCA) scanner can flag an unexpected source or a package that looks new, but the dependable fix is how your registries and package manager are configured.

What the attack actually is

Dependency confusion is an attack on name resolution. If your build can look in more than one place for a package, an attacker may publish a public package with the same name as an internal one and rely on the tool choosing it. The pip documentation warns about exactly this setup: it advises against using the extra index option to find packages that are not in the main repository, because that is a dependency confusion risk.

Notice what is missing. There is no vulnerability and no CVE. The package is simply the wrong one.

Why a CVE-based scan misses it

Classic SCA reads your manifests and lockfiles, identifies components and matches them to known vulnerabilities. A confused package carries no known vulnerability, so a pure CVE match returns nothing. A scanner needs extra signals to help:

  • the registry or source each package was resolved from
  • whether a package name that you consider private now resolves publicly
  • how new the package is and how few versions it has
  • install scripts and network behavior in the package

Ask a vendor which of these they actually check, and ask for a demonstration with a seeded test case, not a slide.

Controls that work better

  1. Use one source. Point the package manager at a single internal registry that proxies the public one, instead of listing several indexes.
  2. Scope private names. In npm, a scope can be mapped to a specific registry, so packages under that scope resolve to your registry only.
  3. Pin and verify. Lockfiles with integrity data, and in pip a hash requirement, make an unexpected swap fail loudly. The pip docs describe the require hashes option as a way to get repeatable installs.
  4. Install from the lockfile in CI. The npm ci command requires a lockfile and errors if it does not match package.json, rather than quietly updating it.

Where scanning helps

Scanning is a useful second layer. It can tell you that a build resolved something from an unexpected place, and it gives you an inventory to check after an advisory. Treat it as detection, with configuration as prevention.

Try it yourself

Open the demo and see how components and their sources are listed. Check whether you can tell where each package came from.

Click through it at your own pace, or open it full screen.

Where Safeguard fits

Safeguard provides SBOM and dependency scanning with an inventory of what your projects resolve, plus policies and gates you can apply on pull requests. Registry settings stay with you. Try the free scan on a repository.

Quick check

What is the cheapest defense against dependency confusion?

Resolve packages from one controlled registry and map private scopes or names to it, so a public package of the same name cannot win.

Do lockfiles prevent it?

They help once a good version is recorded, but the first resolution can still be wrong. Combine them with registry configuration.

Sources

Last reviewed: 19 October 2026.

Never miss an update

Weekly insights on software supply chain security, delivered to your inbox.

Self-healing security runs on Safeguard.

Your first fix PR is minutes away.

No sales call required, even your agent can complete the purchase over MCP.