Explainer
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
react-server-fetch, and writes an import or
an npm install for it. Nothing by that name has been published.CLAUDE.md or AGENTS.md. Some models
produce the same invented name again and again for similar prompts.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
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
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.
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
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.
npx commands in READMEs and agent files.
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
| Attack | Where the name comes from | Example |
|---|---|---|
| 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
npm view <name>
or the package page on npmjs.com or pypi.org. A 404 means nobody has published it. A
package created last week with one version and no downloads deserves a closer look too.npm ci installs exactly
what was reviewed and fails instead of fetching something new.npx commands. Write
npx --package=dependency-cruiser depcruise, not npx depcruise,
so the command can't resolve to a different package on a fresh clone.CLAUDE.md, AGENTS.md and Cursor rules as scripts an agent will
run. Every install and npx line should name a package that exists.npx command
before it runs. Install-time firewalls such as Socket Firewall and Aikido Safe Chain check
packages as they download.
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.
$ npx ghostimport ./your-repo
Questions
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.
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.
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.
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
huggingface-cli experiment.One command in Claude Code. Node 22+. Nothing to configure before it's useful.
/plugin install ghostimport --marketplace FGuerreir0/ghostimport