Keep bad packages out
Typosquatting detection for npm and PyPI
A typosquat is a package whose name imitates one everyone uses: lodahs for lodash, reqeusts for requests, python-numpy for numpy. Somebody publishes it and waits for a typo.
Every name asked for is compared against a built in list of well known npm and PyPI names, the names you add under Also protect these names, your exact allow rules, and the packages this registry serves most. It catches:
- a letter or two out, and two letters swapped
- separators moved or dropped, like
lo-dashorpythondateutil - look-alike characters, like
l0dashordjang0 - extra words bolted on, like
lodash-js,node-expressorpython-numpy - a scoped name flattened, like
babel-preset-envfor@babel/preset-env
A name that is itself well known, pinned by an exact allow rule, on a Never flag these list, or marked "not a typosquat" by an approver is never flagged. Being popular on your box protects a name from imitation, and never makes a lookalike legitimate.
In warn mode, the default, the package is still served, npm prints a TYPOSQUAT: line during the install, and the name shows under Lookalike packages. In block mode it is refused with a 403 naming what it looks like, and the refusal opens a request carrying that reason. In whitelist mode a typo usually never gets that far, since the unknown name is not on the list anyway.
In short
- Edit distance, swaps, separators, homoglyphs, added words and flattened scopes
- Built in npm and PyPI name lists, plus your own protected names
- Warn during install, or refuse with a 403 that says what it imitates
- Approvers can clear a false positive once, for good
- Check a package warns about a lookalike before anybody installs
In the documentation
- Whitelist, blacklist and audit mode Administrator Guide
- When something is blocked Developer Guide
Goes well with
- Dependency confusion protection Reserve your npm scopes, PyPI prefixes, image namespaces and NuGet ids. A public package with your internal name is never fetched.
- Malware scanning ClamAV, a hash blocklist, your own scanner and the OpenSSF known malicious feed, on every cached file. Optionally before the first download.
- Cooling off new releases Brand new versions wait a few days before your builds see them, which is when hijacks get caught.
One container, about two minutes
A Linux box with Docker, or one without it, and a reverse proxy for TLS. The installer does the rest and it is safe to run twice. Free, MIT licensed, nothing to sign up for.