Explainer

What is slopsquatting?

Slopsquatting is registering a package name that AI coding tools make up. Language models sometimes write imports and install commands for packages that were never published. Anyone can register such a name on npm or PyPI. After that, every project or agent that installs it gets the attacker's package instead of an error.

How it works

Four steps, and only the last one needs an attacker

  1. A model invents a package name. It predicts what a package for the job would plausibly be called, such as react-server-fetch, and writes an import or an npm install for it. Nothing by that name has been published.
  2. The name gets written down. It ends up in code, a README, a tutorial or an agent instruction file like CLAUDE.md or AGENTS.md. Some models produce the same invented name again and again for similar prompts.
  3. Someone registers it. npm and PyPI names are first come, first served. Publishing a package takes a free account and a minute.
  4. The install succeeds. Until now the install failed with a 404, which is harmless. Now it downloads the attacker's package, and any postinstall script in it runs on the developer's machine or in CI.

An invented name is harmless while nobody owns it. The danger is that installing it stops failing once someone registers it, and nothing tells you that changed.

Where the term comes from

"Slop" plus "typosquatting"

Seth Larson, the Python Software Foundation's security developer-in-residence, coined the word. It spread in April 2025, when The Register covered research on how often code models invent package names. "Slop" is low-quality AI output. "Typosquatting" is the older trick of registering misspellings of popular packages.

The idea came before the name. In March 2024, Bar Lanyado of Lasso Security reported that chatbots kept recommending a Python package called huggingface-cli, which didn't exist. The real tool comes from the huggingface_hub package. He published an empty placeholder under the invented name. A README in Alibaba's GraphTranslator repository was found telling people to pip install huggingface-cli.

How often it happens

Models invent names often, and repeat them

The largest study so far is We Have a Package for You! by Spracklen et al., presented at USENIX Security 2025. The authors had 16 code models write Python and JavaScript code, then checked every package name against the registries.

576,000
Code samples
From 16 models, in Python and JavaScript.
205,474
Unique invented names
Package names that didn't exist on PyPI or npm.
43%
Came back every time
Share of invented names repeated in all ten reruns of the same prompt.

On average, at least 21.7% of the packages recommended by open-source models and at least 5.2% of those from commercial models didn't exist. 39% of the invented names never came back when the prompt was rerun.

Repetition is what makes this attack practical. If a model produced a different invented name every time, registering one would be a lottery ticket. Because many names come back reliably, an attacker can generate code, collect the names that recur, and register those.

What turns up in real repositories

The invented names are in the instructions, not the code

We scanned 174 public repositories in August 2026 and 991 built with AI agents in November. In both, invented imports did not reach committed code: an import that doesn't resolve breaks the build the first time someone runs it, so it gets fixed. The risk was in places nothing checks.

0
Invented imports in code
Across 991 repos built with AI agents and 649,213 source files.
560
Command names not on npm
In install and npx commands in READMEs and agent files.
404
Repos, one unowned name
From a project scaffold. The vendor reserved it after our report.

Coding agents read READMEs and instruction files and run the commands in them. A person who sees npm install your-cli-package-name knows it's an example; an agent may just run it. npx adds another gap: npx foo runs a local command called foo if one is installed, and otherwise downloads the npm package named foo, which may be someone else's.

Related attacks

Slopsquatting vs typosquatting vs dependency confusion

AttackWhere the name comes fromExample
Slopsquatting An AI model invents a name that was never real huggingface-cli for huggingface_hub
Typosquatting A person mistypes a real, popular name axois for axios
Dependency confusion A company's private package name is registered on the public registry An internal acme-utils published publicly with a higher version

Typosquatting needs a misspelling people actually make. Slopsquatting only needs a name a model is likely to produce again. Since the name never existed, nothing like it is in a vulnerability database, and it never reaches your lockfile while it fails to install.

Prevention

How to prevent slopsquatting

Where ghostimport fits

ghostimport is a free, open-source checker for npm with no runtime dependencies. In Claude Code it runs as a hook: it blocks install, npx, dlx and create commands for packages that don't exist or look like typosquats, and checks imports right after the agent writes them. It also works as an MCP server for Cursor, Windsurf and other clients, and as a CLI for CI.

check a repo
$ npx ghostimport ./your-repo

Questions

More about slopsquatting

Has slopsquatting been used in a real attack?

The public cases so far are researchers and defenders registering invented names first. In 2024 a researcher published a harmless placeholder under huggingface-cli, a name chatbots kept recommending, and a README from Alibaba's GraphTranslator project told people to install it. Security vendors have registered placeholder packages for command names that docs get wrong. The attack needs nothing more than a free npm or PyPI account.

Does a lockfile protect me from slopsquatting?

Only for packages already in it. A lockfile pins what you installed before. It does nothing for a new install command an AI agent runs, or for an npx command, which downloads and runs a package without adding it to your project.

Is slopsquatting only an npm problem?

No. Any registry where names are first come, first served is exposed, including PyPI. The USENIX Security 2025 study measured invented package names in both Python and JavaScript code.

Why does it matter more with AI coding agents?

A person who reads an install command for a package that doesn't exist usually notices. An agent runs it. Agents also read README files and instruction files like CLAUDE.md and AGENTS.md and follow the install and npx commands in them, so an invented or mistyped name in those files gets executed without anyone looking at it.

Sources

Where these numbers come from

Check the name before your agent installs it

One command in Claude Code. Node 22+. Nothing to configure before it's useful.

claude code
/plugin install ghostimport --marketplace FGuerreir0/ghostimport