Safeguard
Supply Chain•

Dependency confusion vs typosquatting: what is the difference?

Typosquatting relies on a human typing a wrong name. Dependency confusion relies on a tool choosing the wrong source. Different causes, different fixes.

Safeguard Security Team
3 min read

Typosquatting tricks a person into installing a package with a name close to the real one. Dependency confusion tricks a package manager into choosing a public package over a private one with the same name. The first is a human error, the second a configuration flaw, so the defenses differ.

Definitions

Typosquatting: a malicious package is published under a name resembling a popular one, hoping someone mistypes or misremembers it. SLSA's threat model puts this in the category of using a compromised package where users are tricked into installing the wrong one, and says typosquatting is mostly outside its scope.

Dependency confusion: a public package is published under the exact name of a private one. If the build can search a public source, it may pick the attacker's version.

Compared

TyposquattingDependency confusion
NameSimilarIdentical
Who errsA personA tool configuration
TargetAnyone installing from a public registryOrganizations with private packages
Where it shows upA manual install or a copied commandA build that resolves several sources
Best fixReview additions, check names, allow listsSingle source registry, scoped names

Defenses for typosquatting

  1. Review new dependencies. A pull request that adds a package should be looked at, including the name.
  2. Use an approved list or internal mirror for packages that may be added.
  3. Copy install commands from official sources, not from search results or chat.
  4. Watch for very new, low usage packages with names near known ones.

Defenses for dependency confusion

  1. Resolve from one source. The pip documentation warns against using an extra index for packages not in the main repository, calling it a dependency confusion risk.
  2. Map scopes to registries. In npm a scope can be tied to a specific registry.
  3. Install from lockfiles in CI, so changes are explicit. The npm ci command errors on a mismatch.

Shared controls

Both are helped by an inventory, by lockfile review in pull requests, and by policy that treats a very new package as needing approval.

Which one should you prioritize?

If you have private packages, fix dependency confusion first because the fix is configuration and cheap. If your developers add dependencies often, invest in review and an approved list for typosquats.

Quick check

Can the same scanner address both?

Partly. A scanner can flag unusual names and sources, but the durable fixes are process and configuration.

Is a typosquat the same as a compromised package?

No. A typosquat is a separate package with a deceptive name. A compromised package is a legitimate one that was altered.

Where Safeguard fits

Safeguard offers dependency scanning and policies and gates for pull requests, so new dependencies can be reviewed. The free scan lists a project's dependencies.

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.