Skip to content

Lesson 2 of 14 · 12m

Typosquats: Names Are a Nonce

Flat registries serve whoever registered the confusable name first — how to verify the artifact instead of the vibes.

The namespace is the vulnerability

PyPI is a flat namespace. python-dateutil belongs to whoever registered it first, and python3-dateutil belonged to whoever registered it first — which, until December 2019, was an attacker. The package itself stayed clean — its payload was a dependency: jeIlyfish, a capital-I lookalike for jellyfish the same actor had registered. Anyone typing pip install python3-dateutil — a plausible guess, since Python 2 was dying — pulled in jeIlyfish, which fetched a stealer from GitLab that harvested private SSH keys from ~/.ssh and posted them to a hard-coded IP. A researcher named Lukas Martini caught it and reported it; PyPI yanked both. python3-dateutil had been live about two days; jeIlyfish had been live nearly a year — December 11, 2018 to December 1, 2019.

npm scopes help, but only where they exist. @babel/cli can only be published by the babel org — the @ prefix binds the namespace to an account. But babelcli is unscoped and squattable, and the unscoped part of npm is as flat as PyPI. Maven Central binds groupId to domain ownership you prove. crates.io and RubyGems are flat like PyPI. The registry's moderation is reactive: names get removed after someone reports them, not checked before someone installs them.

Wrong model: downloads equal legitimacy

The instinctive defense is "I'll only install packages with real download counts." Two failures there. First, a typosquat accumulates downloads because people typo it — crossenv, a 2017 npm squat of the popular cross-env, harvested environment variables and still got downloaded thousands of times before removal. Second, download counts measure resolution volume, not trust; bots, mirrors, and CI all inflate the number. colourama, a 2017 PyPI squat of colorama, ran a clipboard hijacker that watched for copied Bitcoin addresses and swapped in the attacker's. It looked ordinary in every way metrics can express.

Combosquatting is the same attack with a different dictionary: npm-mailer, node-sqlite, flask-dev. Brandjacking is the third variant — names like amzn- or goog- trading on assumed affiliation. And starjacking is the fourth, subtler one: register an obscure package, then point its metadata — repository, homepage fields — at a popular GitHub repo it doesn't own. The registry page shows someone else's stars and commit history next to your package, and nobody checks that the link is a claim, not a proof.

Registries have added partial defenses — PyPI checks candidate names against existing packages for confusability, and npm rejects publishes whose names land too close to well-known packages — a 403 at upload, not a warning at install — but the filters are shallow, not exhaustive. The typo that survives is the one nobody flagged.

What verification actually looks like

Get the package name from the project's own documentation or repository — not from a search result, a Stack Overflow answer's typo, or muscle memory. Then check the artifact, not the vibes:

  • npm view <pkg> and pip index versions <pkg> — when did it first publish, how often does it release, who owns it? A package published last week with fifty downloads claiming to be a core utility is a flag.
  • The publisher identity on npmjs.com / pypi.org — does the maintainer match the GitHub repo's owner?
  • deps.dev (Google's Open Source Insights) cross-releases, advisories, and dependency graphs in one page.
  • npm view <pkg> scripts before install — a typosquat almost always has a lifecycle script because the whole point is install-time execution.
  • The GitHub link test: does the registry page's repository field point at the repo you meant, or at an attacker-chosen famous one? Starjacking lives in that mismatch.

For your own footprint: if you run an internal package named acme-utils, its confusable names and likely typos are cheap to register publicly. Claiming them is cheaper than incident response.

The registry is not a curated store. It is a DNS zone file for code — first-come, flat, and indifferent to whether python3-dateutil is the library you meant.

Was this lesson helpful?

Sign in to rate

Keep reading

Related articles from the SudoSecurity blog.