Skip to main content

Slopsquatting: the package names AI coding assistants invent, and how to check one before you install it

Ask an AI coding assistant for code that parses a niche file format and it will often import a package to do it. Most of the time the package is real. Sometimes the name is plausible, consistent with the naming conventions of the ecosystem, and does not exist. If an attacker has registered that name first, the next npm install or pip install runs their code.

That is slopsquatting: typosquatting where the typo is made by a model instead of a person. The difference matters, because a model's mistakes are repeatable in a way a person's typos are not.

What the research measured

The most thorough study is "We Have a Package for You!" by Spracklen and colleagues, accepted at USENIX Security 2025 (arXiv:2406.10279). The authors generated 576,000 code samples in Python and JavaScript with 16 code-generation models and checked every imported package against the registries. Their headline numbers:

  • The average hallucination rate was at least 5.2% for commercial models and 21.7% for open-source models.
  • They collected 205,474 unique hallucinated package names.

The second number is the attack surface. The paper also tested repetition: when prompts that had produced a hallucination were rerun ten times, 43% of the hallucinated names came back in all ten runs, while 39% never came back. That repeatability is is what makes registration worthwhile for an attacker: a name that a model suggests once is a lottery ticket, a name it suggests every time is a target.

There is also a real-world demonstration from before the term caught on. In March 2024, a researcher at Lasso Security reported that models repeatedly suggested pip install huggingface-cli, a name that was not the official package. He uploaded an empty package under that name and counted more than 30,000 authentic downloads over roughly three months, and found the install instruction in the README of a repository belonging to a large company. The package was harmless. It did not have to be.

Why AI coding agents make it worse

A chat assistant suggests a name, and a person decides whether to type it. An AI coding agent with shell access types it. When the agent writes the import, adds the dependency to the manifest and runs the install in one turn, there is no moment where a human reads the name. The same is true of agent-written CI scripts and Dockerfiles that install packages at build time.

Two habits amplify the risk:

  • Auto-approved shell commands. If npm install * or pip install * is on the agent's allow list, a hallucinated name goes from suggestion to execution with no review.
  • Install scripts. npm preinstall and postinstall hooks, and Python packages that build from source, run code at install time, before anything imports the package.

How to verify a dependency before install

None of these checks are hard. The point is to do them every time a name is new to your project.

1. Confirm the name exists and is the one you meant

# npm: does it exist, who publishes it, when was it first published?
npm view some-package name version maintainers repository time.created

# PyPI: the JSON API returns 404 for a name that was never published
curl -s -o /dev/null -w '%{http_code}\n' https://pypi.org/pypi/some-package/json

A 404 means the model invented the name. Do not "fix" that by publishing or installing something close to it. Go to the library's own documentation and copy the install command from there.

2. Look at age, history and source

A package that exists is not automatically the right one. Red flags for a newly suggested name:

  • First published days or weeks ago, with one or two versions.
  • No linked source repository, or a repository that does not contain the published code.
  • A name that is a popular package plus a suffix such as -js, -cli or -py, or one or two characters away from a well-known package.
  • An install script in package.json for a library that should be pure code.

3. Install without running scripts, then inspect

npm install some-package --ignore-scripts

This stops install hooks from running on the first install, so you can read what the package does before it does it.

4. Lock what you have

Lockfiles turn "whatever resolves today" into a reviewed list:

npm ci                                        # fails if package.json and the lockfile disagree
pip install --require-hashes -r requirements.txt   # every package must match a recorded hash

npm ci installs exactly what the lockfile says and refuses to update it. pip's hash-checking mode refuses any package whose hash is not recorded. Neither stops you from adding a bad name in the first place, but both make an addition visible as a diff someone has to review.

5. Allowlist for agents

For AI coding agents, the strongest control is to take the install out of their hands:

  • Remove package install commands from the agent's auto-approve list, so every install needs a click.
  • Tell the agent, in its instruction file, to propose new dependencies with the exact name and registry URL rather than installing them.
  • If your organisation runs a private registry or proxy, have it serve only approved packages, so a hallucinated name fails to resolve.
  • In CI, fail the build when the lockfile gains a package that is not on the approved list.

Checking a list with Vulkro

vulkro slopcheck checks a manifest, or a pasted list of names, before you install anything (docs):

vulkro slopcheck --manifest ./package.json
pbpaste | vulkro slopcheck --list - --ecosystem pypi
vulkro slopcheck --manifest . --online     # also ask the registry whether each name exists

It flags names on a known-malicious list and on a curated list of documented AI hallucinations (both High), names one or two edits from a popular package (Medium), and popular-name-plus-suffix decoys (Low). It runs offline from data in the binary; only --online contacts the registry, and it exits 1 when something is flagged, so it works as a CI step. Separately, the dependency scan reports a catalogued typosquat that is already installed as SUP-COMPROMISE-002.

A check like this complements the steps above rather than replacing them. A curated list only knows names someone has seen, and a brand new registration that matches no popular package will only show up as "does not exist" or "first published yesterday".

FAQ

What is slopsquatting?

An attacker registers a package name that AI coding assistants tend to invent, so developers or AI coding agents who install the suggested name get the attacker's code. It is typosquatting where the model, not a person, makes the mistake.

How often do AI models hallucinate package names?

In the USENIX Security 2025 study, at least 5.2% of packages suggested by commercial models and 21.7% by open-source models did not exist, across 576,000 samples. Rates vary by model, language and prompt.

Does a lockfile protect against slopsquatting?

Partly. A lockfile with hashes stops a known package from silently changing, and makes a new dependency show up in review. It does not judge whether a newly added name is legitimate, so pair it with an existence and age check before install.

To check dependency lists before your AI coding agents install them, start a 14-day trial. Related reading: supply chain attacks are a code problem and the npm worms of 2026.