Slopsquatting: packages that AI hallucinated and attackers registered
Slopsquatting is registering a package name that an AI model made up, then waiting for an assistant to recommend it. A study presented at USENIX Security 2025 tested 16 models on 576,000 code samples. The average share of hallucinated packages was at least 5.2% for commercial models and at least 21.7% for open-source models. If an agent suggests a package you do not recognise, do not install it until you have looked it up and found the same name in the real project's own instructions.
An AI model that writes code often reaches for a library. Sometimes the library is real. Sometimes the model produces a plausible name that no one ever published. In AI terms that is a hallucination: output that sounds right and is not. Slopsquatting turns the second case into an attack. The attacker publishes a package under the invented name, so that the next person who accepts the suggestion installs the attacker's code.
01What slopsquatting is
The term was coined by Seth Larson, the Python Software Foundation's Developer-in-Residence. It echoes typosquatting, where the attacker waits for a human to mistype a real name. Here the slip belongs to the model. A supply-chain attack reaches you through something you depend on rather than through your own machine.
The two cases differ in one practical way. A typo happens once, to one person. A model that reaches for the same invented name again and again keeps sending people to it, which is why the repeat numbers below matter.
02The USENIX study: method and numbers
| Item | Value |
|---|---|
| Venue and year | USENIX Security 2025, Distinguished Paper Award |
| Authors' institutions | UTSA, Oklahoma, Virginia Tech |
| Models tested | 16 popular models |
| Prompt sets | Two unique prompt datasets |
| Code samples | 576,000, in two programming languages |
| Average hallucinated packages, commercial models | At least 5.2% |
| Average hallucinated packages, open-source models | At least 21.7% |
| Unique hallucinated names | 205,474 |
The researchers had the models generate code and analysed the samples for package hallucinations. A package name that does not exist is a hallucination. Read the percentages as averages across many models, and read "at least" as a floor: the study reports that the average is no lower than these figures. A single model can be far better or worse than the average.
03Why the same fake name matters
The part that makes this practical for an attacker is repetition. When 500 prompts that had triggered hallucinations were rerun ten times each, 43% of hallucinated packages were repeated every time, and 39% never reappeared. So about four in ten invented names came back each time. An attacker does not have to guess which name will be suggested to you: they can collect the ones that keep coming back and register those.
Some models can recognise a hallucinated name they have just generated. GPT-4 Turbo and DeepSeek identified such names with over 75% accuracy in internal tests. Treat that as a research result, not a safety check. The reliable check is to look the name up yourself.
04Why agents and vibe coding raise the risk
Developers who rely on vibe coding may never type or search for a package name. Vibe coding means describing what you want and letting the AI write the code. The name comes from the model, and the install command comes from the model too.
AI agents are one way npm modules get installed without a manual step. So the question is who chose the name and who ran the install. The permission rules help here. In Claude Code, the rule Bash(npm run *) matches npm run build and npm run test but not npm install. Allowing your scripts does not allow an install of a name you have not seen. The rule syntax is on Claude Code permissions.
05What to do when an agent suggests an unknown package
Do these steps, in order, before the package gets installed.
- Stop the install. Ask the agent for the reason it picked the package. Do not run
npm installon a name you have not seen. - Run
npm view. It shows data about a package and prints it to the terminal:
npm view <package-name>Put the suggested name where the placeholder is, with no angle brackets. If npm says the package is not found, the name may be made up, but that is not final: an attacker can register it later. If the package exists, read what it is and what it depends on. A package that exists is not a clean package. Registering the name is the whole attack.
- Find the name in the project's own instructions. Open the README or website of the library you wanted. The install line there is the source of truth. If the project never mentions the name, do not install it, and ask the agent which library it meant.
- Look at the version age. The npm option
min-release-ageinstalls only versions that were available for more than a given number of days. A brand-new version is the one nobody has had time to inspect. - Turn off install scripts if you do not need them. npm 11 runs
preinstall,installandpostinstallby default after the modules are placed; npm 12 blocks install scripts of dependencies unless you approve them. On npm 11,ignore-scriptsset to true stops npm from running scripts specified inpackage.jsonfiles. - After the install, verify signatures.
npm audit signaturesverifies the registry signatures of installed packages.
PyPI follows the same logic: not every package and release there should be treated as trusted, and you review before installing. The full checking list for npm is on check an npm package for malware.
06Watch the lockfile
The lockfile, package-lock.json for npm, describes the exact tree of packages a project installed. When an agent finishes a task, read its diff, the list of changed lines. A new package you did not ask for needs an answer before you merge. Claude Code hooks are scripts that run at set moments, and an example hook script blocks edits to package-lock.json with exit code 2. Hook examples are on Claude Code hooks.
07Limit what an installed package can touch
Checking is the first layer. A sandbox is the second: a boundary that limits what a program can read, write or reach. In Codex, package managers inherit the sandbox boundaries. In Docker's sandbox, packages the agent installs stay inside it, and removing the sandbox discards them. Cursor's default sandbox network mode allows common package managers and language tools. A sandbox limits the reach of the code; it does not tell you the package was bad. Options are on AI agent sandbox.
08Related name attacks
Three attacks depend on a name that you did not check. Typosquatting uses a lookalike of a real name (typosquatting). Dependency confusion uses a public package that replaces a private one with the same name (dependency confusion). Slopsquatting uses a name that a model invented. The broader history of poisoned packages is on npm supply chain attack, and what to do if one ran is on npm malware.
For the code the model writes, as opposed to the packages it names, see AI-generated code vulnerabilities.
09The routine in short
Slopsquatting needs one thing from you: an install you did not look at. The study shows the supply of invented names is large and often repeats. Look up the name, find it in the project's own instructions, and let new versions age before you let them in.
If you want to see when a package script or a new program starts on your Mac, the free, open-source core of Artificial Immunity watches package scripts and every program start and reports what it finds.
FAQ
What is slopsquatting?
It is registering a non-existent package name that a language model hallucinated, hoping that someone guided by an AI assistant will copy and install it without realising it is fake.
Who coined the term slopsquatting?
Seth Larson, the Python Software Foundation's Developer-in-Residence.
How common are hallucinated packages?
In a USENIX Security 2025 study of 16 models and 576,000 code samples, the average share of hallucinated packages was at least 5.2% for commercial models and 21.7% for open-source models.
Do models repeat the same fake package name?
Often. In a follow-up test, 500 prompts that had triggered hallucinations were rerun ten times each: 43% of the hallucinated packages came back every time, while 39% never reappeared.
Is slopsquatting the same as typosquatting?
No. Typosquatting waits for a human slip, a slopsquatting name comes from a model. The first is covered on typosquatting.
What should I do when my agent suggests a package I do not know?
Do not install it yet. Run npm view with the name to see whether it exists and what it is, then find the name in the real project's own instructions.
Related guides
Sources
- USENIX Security 2025, package hallucination paper
- arXiv 2406.10279, We Have a Package for You
- Socket, slopsquatting
- npm docs, npm view
- npm docs, verifying registry signatures
- npm docs, scripts
- npm docs, config
- Claude Code docs, permissions
- Docker docs, sandboxes
- OpenAI Codex, sandboxing
- Cursor docs, run modes
- Artificial Immunity