Get the free coreGet core

Slopsquatting: packages that AI hallucinated and attackers registered

Updated 6 min readSection 05 / Threats
SHORT ANSWER

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

ItemValue
Venue and yearUSENIX Security 2025, Distinguished Paper Award
Authors' institutionsUTSA, Oklahoma, Virginia Tech
Models tested16 popular models
Prompt setsTwo unique prompt datasets
Code samples576,000, in two programming languages
Average hallucinated packages, commercial modelsAt least 5.2%
Average hallucinated packages, open-source modelsAt least 21.7%
Unique hallucinated names205,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.

  1. Stop the install. Ask the agent for the reason it picked the package. Do not run npm install on a name you have not seen.
  2. 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.

  1. 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.
  2. Look at the version age. The npm option min-release-age installs 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.
  3. Turn off install scripts if you do not need them. npm 11 runs preinstall, install and postinstall by default after the modules are placed; npm 12 blocks install scripts of dependencies unless you approve them. On npm 11, ignore-scripts set to true stops npm from running scripts specified in package.json files.
  4. After the install, verify signatures. npm audit signatures verifies 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.

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.

Sources

  1. USENIX Security 2025, package hallucination paper
  2. arXiv 2406.10279, We Have a Package for You
  3. Socket, slopsquatting
  4. npm docs, npm view
  5. npm docs, verifying registry signatures
  6. npm docs, scripts
  7. npm docs, config
  8. Claude Code docs, permissions
  9. Docker docs, sandboxes
  10. OpenAI Codex, sandboxing
  11. Cursor docs, run modes
  12. Artificial Immunity
An agent adds a package you never heard of. Artificial Immunity watches the Mac where your agents work.Get the free core