Typosquatted packages: one wrong letter in an install command

Typosquats copy popular package names with small changes to catch mistyped installs. How to spot them before install, use package-health signals such as OpenSSF Scorecard and Socket, and restrict new dependencies.

Lesson 18 of 26 · 9 min read · practice only with authorization

Diagram

A near-miss install

Follow the path. One example at a time.

Step 1 of 4

Typo

A developer means requests and types something close.

Illustration: Typo
$ pip install reqeusts

The example on the open step is one illustration, or the fix you can paste into an application you own.

What this page is made of

3 pieces. Each one says what fails, who is affected, what you would notice, and what you change.

  1. Name tricks

    What fails
    Swapped letters, dropped hyphens, and added suffixes like -dev or -js.
    Who is affected
    Developers and build hosts.
    What you would notice
    New packages a few edits away from a popular one.
    What you change
    Copy names from the official docs and review lockfile diffs.
  2. Install scripts

    What fails
    npm preinstall and postinstall, and setup.py code, run on install.
    Who is affected
    The installing machine and its tokens.
    What you would notice
    New dependencies with install scripts.
    What you change
    Disable scripts in CI by default and allow-list exceptions.
  3. Health signals

    What fails
    Age, downloads, maintainers, and repository links help judge a package.
    Who is affected
    Teams choosing dependencies.
    What you would notice
    Packages days old with no repository.
    What you change
    Use Scorecard, deps.dev, or Socket in review.

Dependency review in pull requests

GitHub’s dependency review action and similar tools comment on PRs that add dependencies, showing license, vulnerability, and health data, so a typo is visible before merge.

Check yourself

Recognition and the fix. Nothing here is a procedure.

1 / 3

Why do typosquats often use install scripts?

Sibling techniques

Pages at the same depth, plus a lab and a glossary card for this one.

  1. MapBuild pipelines and the software supply chainThe build is an environment with production rights.
  1. 01Pull requests from outside the trust boundaryCode from a fork or an untrusted branch is not your code yet.
  2. 02Software supply-chain compromise: where builds get tampered withSupply-chain attacks target the path from source to shipped artifact: repositories, dependencies, build systems, and registries.
  3. 03Dependency confusion: when a public package shadows a private oneIf a build can pull from public and private registries, a public package with your internal name and a higher version may win.

Practice

  1. LabTerminal mission: One letter off, with an install scriptA developer added a dependency by hand. Compare package names with what the team normally uses, find the typosquat, and read the postinstall script it runs on every npm install.

Glossary

  1. CardTyposquatted packagesA public package name is one character off a real one, and the install runs it.