Companion Notes: Typosquatting and Your Package Name
These notes are structured like the chapter list of a short talk-through video, but they stand on their own as text and nothing needs to be played. They cover typosquatting from two angles: making sure your new name is not dangerously close to someone else's, and reducing the chance that someone squats on yours.
Part 1: What typosquatting looks like
A typosquat is a package published under a name that a hurried developer might type by mistake, or confuse with a popular one. The patterns are predictable:
- Swapped or doubled letters, such as an extra character in the middle of a well-known name.
- Separator games: a hyphen added, removed or replaced with an underscore or dot.
- Plausible suffixes like
-js,-utils,-devor-clion a famous name. - Combining a known brand with a generic word to look like an official companion package.
The payload is usually an install script or import-time code that harvests environment variables, credentials or tokens. Security teams across the major registries regularly report and remove such packages, which is why this is worth thinking about even for small projects.
Part 2: Checking a name before you claim it
When you choose a name, you want it to be clearly yours and not accidentally one keystroke from an established package. A quick routine:
- Search the registry for the name and for its separator variants. On PyPI, normalisation means hyphens, underscores and dots are already treated as the same, but similar-looking names may still exist.
- Try common misspellings of your own name and of any popular package it resembles.
- If your name differs from a popular package by only one or two characters, choose another. Even an honest project in that position will attract suspicion and misdirected installs.
npm also refuses some new names that are too similar to existing ones, for example differing only in punctuation, so a name that seems free may still be rejected.
Part 3: Defending your own users
Once you have users, you are a potential target. A few low-cost measures help:
- Use a scope or namespace for an organisation's packages, so the owner is visible in every install command.
- Make the install command copy-pasteable in the README and docs, so fewer people type it from memory.
- Consider reserving the most obvious misspellings as clearly labelled placeholders, if the registry's policies allow it. Check the registry's rules first, because some discourage name squatting even for defensive reasons.
- Publish with provenance, so users who check can see your package was built from your repository.
Part 4: If you find a lookalike
Do not install it to investigate on a machine with real credentials. Report it through the registry's official abuse or security reporting channel, which npm, PyPI and crates.io all provide, and include the package name and why you believe it is impersonating yours. Then add a short note to your README stating the one correct package name.
Recap
Choose a name with breathing room, check its variants, put your packages under a visible owner, and report lookalikes rather than arguing with them. Most of the defence is simply making the right name easy to find and type.