Safeguard
Supply Chain•

What is typosquatting in package registries and how to spot it

Typosquatting publishes malicious packages with names close to popular ones, hoping for a typo. Learn the common patterns and simple habits that stop it.

Safeguard Security Team
3 min read

Typosquatting, in package registries, means publishing a package whose name is almost the same as a popular one, so that a developer who mistypes the name or picks the wrong search result installs the attacker's code instead. It relies on speed and habit, not on any flaw in the real package.

Common name patterns

Attackers vary a legitimate name in small ways:

  • a swapped, dropped or doubled letter
  • a hyphen added or removed, or an underscore swapped for a hyphen
  • a plural or singular form
  • a prefix or suffix that sounds official, such as a made-up "official" or "js" tag
  • look-alike characters

Why it works

Installing a package is one command, and the cost of a typo is invisible until the code runs. Many packages run install scripts or execute code on import, so harm can start immediately, often on a laptop or build server that holds credentials.

Copy and paste from tutorials, chat answers and old notes also spreads wrong names. Package names suggested by AI assistants deserve the same check, since a suggested name might not exist or might belong to someone else. See AI hallucination and package confusion attacks.

Habits that help

  1. Check the package page before installing: publisher, age, download history, repository link, and whether the repository really links back.
  2. Prefer packages you already use, and copy names from your own manifest rather than from memory.
  3. Install from a lockfile in CI so a typo cannot slip in unnoticed.
  4. Review new dependencies in pull requests. A name nobody recognizes is worth a question.
  5. Disable install scripts where you do not need them, if your package manager supports it.

What teams can add

  • A proxy or allowlist so only approved packages can be installed.
  • Automated checks that compare new names to popular ones and flag near matches.
  • Alerts when a dependency's publisher or maintainer list changes.

How it differs from dependency confusion

Typosquatting targets a mistake in a name. Dependency confusion targets a resolver that mixes private and public sources. For a deeper look at how attackers choose targets, read the anatomy of a typosquatting campaign.

Safeguard scans dependencies and applies policies and gates before packages reach production. A free scan is at gold.safeguard.sh/scan.

Quick check

Is a package with many downloads always safe?

No. Download counts can be inflated, and popular packages can be compromised. Treat the count as one signal.

Can I rely on spelling carefully?

It helps but is not enough. Pasted names and suggestions bypass your typing, so verify the package itself.

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.