Back to The Haunt
Building with AI3 min read

Slopsquatting: the package your assistant made up, and the attacker who registered it.

Ask an assistant for code and it will sometimes import a package that does not exist. The name sounds right and follows the style of real packages, and installing it fails, until someone registers it. Then it installs whatever that person published.

That attack is called slopsquatting. Seth Larson, the security developer-in-residence at the Python Software Foundation, named it in April 2025, from "AI slop" and "typosquatting". Typosquatting waits for a person to mistype a name. Slopsquatting waits for a model to invent one.

How common is it?

More common than you would guess. A study presented at USENIX Security 2025, We Have a Package for You!, generated 576,000 Python and JavaScript code samples with 16 models and checked every package they used. On average, at least 5.2% of packages suggested by commercial models did not exist, and 21.7% of those from open-source models. In total the models invented 205,474 different names.

What makes the attack practical is repetition. When the researchers ran the same prompts ten times, 43% of the invented names came back every time. An attacker does not need to guess. They ask the questions developers ask, collect the names that do not exist, and register them.

Newer models invent fewer names. A 2026 re-run on five newer models found rates between 4.6% and 6.1%, and 127 names that all five invented identically. Rarer is not gone.

Why it slips through review

In a diff, an import of a package you have never heard of looks exactly like one you use every day. Once the name is registered, the install succeeds, the lock file updates and the tests pass. Nothing in a normal review flags it.

Four checks before you install

For every dependency an AI-written change adds:

  • Does it exist, and is it the one you meant? Look it up on the registry yourself, with npm view or on the PyPI page, rather than trusting the import.
  • How old is it, and who publishes it? A package first published last week, by an account with nothing else, deserves suspicion. So does a name one letter away from a popular one.
  • Is anyone using it? Download counts, a linked repository with real history and other packages that depend on it are good signs. None of them is proof.
  • Do you need it at all? Assistants reach for a package to do a ten-line job. The standard library or a dependency you already have is often enough, and a package you never add is one you never have to check.

Make the first check routine. This shows every dependency a branch adds, in seconds:

git diff main -- package.json requirements.txt pyproject.toml

Then list new dependencies in the pull request description, so the reviewer checks them like any other new code.

Chapter 7 of the free book Checked, Not Trusted covers invented packages alongside the other places AI-written code goes wrong, with a lab. The AI code review checklist includes the dependency check.

That’s it. Come back soon; the ghost keeps writing.Follow by RSS

Read next.