Typosquatting on Package Registries: What Researchers Have Found
Typosquatting is the trick of publishing a package whose name is one slip of the keyboard away from a popular one, then waiting for someone to install it by mistake. Security researchers and registry operators have studied the pattern for years. This page summarises the kind of evidence that exists and what it implies for anyone choosing or publishing a package name.
Where the evidence comes from
Three sources dominate. Academic security papers collect malicious packages removed from npm, PyPI and RubyGems and classify how they were named, how they ran code and what they stole. Security vendors publish write-ups each time they detect a campaign, often describing dozens or hundreds of look-alike names uploaded in a short burst. Registry operators publish policy changes and incident notes after removing packages. Each source has a bias: vendors report what their scanners catch, and academic datasets only contain packages someone already flagged.
Recurring patterns
The naming techniques show up again and again:
| Technique | Illustrative example |
|---|---|
| Character omission or doubling | reqests for requests |
| Swapped or adjacent keys | lodsah for lodash |
| Separator games | python-dateutil vs python_dateutil vs dateutil |
| Scope confusion | an unscoped name copying a scoped package |
| Combosquatting | a real name plus "-js", "-utils" or "-dev" |
| Dependency confusion | a public package with the same name as a company's private one |
The payloads usually run during installation, through npm lifecycle scripts or a Python setup.py executed at build time, which is why so many reports focus on install hooks rather than on the library code itself.
How registries have responded
Registries have tightened rules over time rather than in one step. npm blocks new names that differ from an existing package only by punctuation, so you cannot register a dotted or dashed twin of a well-known name. PyPI normalises names, treating case, hyphens, underscores and dots as equivalent, as described in the Python Packaging User Guide. PyPI's name-retention process is set out in PEP 541. Go sidesteps much of the problem because a module path is a repository URL, although look-alike domains and repository names remain possible. Scanning of new uploads and faster takedowns are now common across major registries, but research consistently notes that detection happens after publication, so some installs still occur.
What it means for you
If you publish:
- Use a scope or organisation namespace where the registry offers one; it is the cleanest defence against impersonation.
- Avoid names that are a single edit away from a popular package. Users will mistype in both directions.
- Consider registering obvious variants of your own name only if the registry's policy permits it; do not squat other people's names.
If you consume:
- Copy install commands from the project's own README rather than typing from memory.
- Commit lockfiles and review new entries in pull requests; a new top-level name in a diff is a cheap warning sign.
- For private packages, configure your client so internal names can only resolve from your internal registry.
Our walkthrough on typosquatted names covers the naming side in more depth, and the naming conventions essay explains how to pick a name that is hard to imitate.