Slopsquatting: when your AI assistant installs a package that does not exist

Slopsquatting is a supply chain attack: someone registers a package name that AI coding models tend to invent, and waits for an assistant or an agent to install it. A 2025 USENIX Security study of 16 models found that 19.7% of the packages they recommended did not exist. Check each new dependency on the registry before it is installed: that it exists, how old it is, who uses it.

The team behind Keybrum's attacksUpdated 10 min read

In short

  • The term was coined by Seth Larson, Developer-in-Residence at the Python Software Foundation, and spread in April 2025. It blends "slop", for careless AI output, with typosquatting.
  • In the study by Spracklen and colleagues, 440,445 of 2.23 million recommended packages were hallucinations, with 205,474 distinct invented names.
  • Commercial models hallucinated a package 5.2% of the time on average, open-source models 21.7%. JavaScript fared worse than Python: 21.3% against 15.8%.
  • The invented names are stable enough to target: 58% were repeated more than once across 10 runs of the same prompt. Only 13.4% were one or two characters away from a real name, so a typo filter misses most of them.
  • The defense is a check before install: the name exists, the package is not days old, it has real users, and the lockfile change is reviewed like code.
On this page

What slopsquatting is

Ask an AI assistant for code and it will sometimes import a library that sounds right and was never published. That is a package hallucination. On its own it is a small bug: the install fails and you move on. Slopsquatting is what happens when someone has registered that name first. The install then succeeds, and code written by a stranger runs on your machine or in your build, with your tokens within reach.

The word is modelled on typosquatting, where an attacker registers reqeusts and waits for a typing mistake. Here the mistake is made by a model, and the same model makes it for many people. According to Socket, which documented the term on 8 April 2025, it was coined by Seth Larson, Developer-in-Residence at the Python Software Foundation, and popularised by Andrew Nesbitt of Ecosyste.ms.

In the terms of the OWASP Top 10 for LLM applications, we read it as a supply chain risk (LLM03:2025) that starts as misinformation (LLM09:2025). It concerns anyone who lets a model choose dependencies, which includes anyone who builds with Cursor, Claude Code, Lovable, Bolt or Replit.

The research behind it, with its figures

The reference study is "We Have a Package for You! A Comprehensive Analysis of Package Hallucinations by Code Generating LLMs", by Joseph Spracklen and five co-authors, accepted at the USENIX Security Symposium 2025. The team ran 16 popular code-generating models on two sets of prompts, in Python and JavaScript, and produced 576,000 code samples. They then checked every package those samples asked for against PyPI and npm.

FindingFigure
Packages recommended in total2.23 million
Packages that did not exist440,445, or 19.7%
Distinct invented names205,474
Average rate, commercial models5.2%
Average rate, open-source models21.7%
Average rate, Python against JavaScript15.8% against 21.3%
Invented names repeated in all 10 runs of the same prompt43%
Invented names repeated more than once in 10 runs58%
Invented names never repeated39%
Invented names within 1 or 2 characters of a real package13.4%
Invented Python names that are real JavaScript packages8.7%
From Spracklen et al., arXiv 2406.10279, version 3. The models tested date from 2023 and 2024, so current models may score differently.

Three of these numbers explain why the attack is practical. First, the rate is far from zero even for the best models. Second, the errors repeat: a name that comes back in most runs of a prompt will come back for other developers who ask something similar, so an attacker knows which names to register. Third, most invented names are not near-misses of real ones. In the authors' words, "most package hallucinations are not simple off-by-one errors". A tool that only looks for look-alike names catches a small share.

The paper also has encouraging news. Several models were good at spotting their own inventions when asked, with detection accuracy above 75% for GPT-4 Turbo, GPT-3.5 and DeepSeek. A second pass that asks "does this package exist?" helps. A lookup on the registry helps more, because it is a fact and costs nothing.

How an agent ends up installing a package that does not exist

A few years ago a developer would have typed the install command and perhaps noticed the odd name. Coding agents changed the path. The agent writes the import, decides it needs the library, and runs the install itself.

  1. 1

    The model writes plausible code

    It needs a helper for a task, and produces an import whose name follows the conventions of the ecosystem. Nothing marks it as invented. The code reads well.

  2. 2

    The agent runs the install

    It calls npm install, pip install or npx with that name. In an agent set to run commands without asking, no human sees the line.

  3. 3

    The registry answers

    If nobody registered the name, the install fails and the agent tries something else. If somebody did, the package downloads like any other.

  4. 4

    Install scripts run

    npm runs a package's install scripts by default: the ignore-scripts setting defaults to false. Code can run before any of your own code imports the package.

  5. 5

    The lockfile records it

    The name and version are now pinned. Every teammate, every CI run and every deploy installs the same package from then on.

The same path applies to npx some-tool and to an MCP server added from a registry: each one downloads and runs a package by name. See MCP security for that side.

How to check a project

There are two moments to check: once now, on what is already in the project, and then every time a dependency is added. Both rely on the same three questions. Does the name exist on the registry? How old is the package? Does anyone else use it?

Review what changed in the lockfile

Treat the dependency list as code. After a session with an agent, look at which names were added, and look up each one you do not recognise.

bash
# Which dependencies were added on this branch?
git diff main -- package.json requirements.txt pyproject.toml

# The direct dependencies of a Node project
npm ls --depth=0
The lockfile diff is longer but complete: it also shows what each new package pulled in.

Ask the registry about a name

bash
# npm: when was the package first published, and where is its source?
npm view some-package time.created repository.url

# npm: downloads last week
curl -s https://api.npmjs.org/downloads/point/last-week/some-package

# PyPI: date of the first upload
curl -s https://pypi.org/pypi/some-package/json | jq -r '[.releases[][]?.upload_time] | min'
A 404 means the name does not exist: the model invented it. Find the real library before trying a similar name.
What you seeWhat it suggestsWhat to do
The name does not existA hallucination. Anyone can register it tomorrowRemove the import. Ask for the real library or write the few lines yourself
First published days or weeks ago, few downloadsPossibly registered to catch a hallucinated nameRead the package's files before installing. Prefer a known alternative
No repository link, an empty README, one versionNot built for usersDo not install
One letter away from a famous nameTyposquattingCheck the spelling against the official docs
Years old, a real repository, many downloadsAn ordinary packageGo on, and keep it updated

Make the package manager wait

A cooling period blocks the newest releases, which is when a malicious version is most likely to be live. npm has a min-release-age setting, counted in days and off by default: with it, npm only installs versions that have been available for longer than the number you set. pnpm has a matching minimumReleaseAge setting, counted in minutes. A cooling period does not help against a squatted name that was registered months ago, so it complements the registry check.

ini
; .npmrc at the root of the project
min-release-age=3
ignore-scripts=true
With ignore-scripts=true, packages that need a build step must be allowed one by one. That friction is the point for a project whose dependencies are chosen by an agent.

If you think you installed one

Act as if the machine was read. An install script runs with your user's rights, so it could reach your shell history, your .env files, your cloud and npm tokens and your SSH keys.

  • Remove the package and the lines that import it, then reinstall from a clean lockfile
  • Rotate every secret that was on the machine or in the CI job: provider keys, database passwords, deploy tokens, npm and GitHub tokens
  • Check your registry and GitHub accounts for packages, tokens or workflow files you did not create
  • Look at the deploy that followed: if the package reached production, the server's environment variables are in scope too
  • Report the package to the registry so that it is taken down

The order to rotate keys in, provider by provider, is in what to do about a leaked API key.

What Keybrum does about it, and what it does not

Keybrum is the automated pentest we build for apps made with AI tools. Slopsquatting happens on the developer's machine, before there is an app to attack, so this part of Keybrum is a check that runs before an install. It exists in three places, all with a Keybrum API key.

  • A hook for Claude Code and Cursor. A few lines in .claude/settings.json or .cursor/hooks.json send each shell command that names a package manager (npm, pnpm, yarn, bun, npx, pip, uv, poetry and a few more) to Keybrum before it runs. Only the command is sent. The setup is on the docs page.
  • An MCP tool, `check_packages`. The agent calls it itself with package names, an install command or the text of a lockfile.
  • A pipeline step, on paid plans, that checks the lockfile on each build.
CaseWhat the install check does
The name exists on neither npm nor PyPIStops the install and says the name was probably made up
The package is listed as malicious (OSV, with the OpenSSF malicious packages list)Stops the install
The version was published less than 24 hours agoStops the install and names the previous release
A high or critical advisory has a fixed versionStops the install and names the version to take
First published under 30 days ago with few downloads, or one letter from a well-known nameWarns and asks you to look first
A service on Keybrum's side does not answerLets the install through and says it was not checked

The limits are real. It covers npm and PyPI only. It does not read a package's code, so a squatted package that is old enough, has downloads and is not yet on a malware list passes with at most a warning. The lockfile check covers known malware and advisories only: it does not look at a package's age or at whether the name exists. And a developer who types the install in a terminal outside the agent is not covered by the hook.

Once the app is live, the other half applies: Keybrum attacks it as a stranger and as two accounts, and reports each leak with the request that worked. A one-time report is €49 for one app, and plans start at €29 a month excluding VAT. For the code an assistant wrote around those packages, see auditing AI-generated code.

Questions

What is slopsquatting?

It is registering a package name that AI models tend to invent, so that a developer or an agent who follows the model's suggestion installs the attacker's code. The name mixes "slop", for low-quality AI output, with typosquatting. It was coined by Seth Larson of the Python Software Foundation.

What is a package hallucination?

It is a reference, in code written by a model, to a library that does not exist on the registry. In the 2025 USENIX Security study by Spracklen and colleagues, 19.7% of 2.23 million recommended packages were hallucinated, across 16 models.

How is slopsquatting different from typosquatting?

Typosquatting bets on a human typing a famous name wrong. Slopsquatting bets on a model producing a name that never existed. The study found that only 13.4% of invented names were one or two characters from a real package, so the two need different checks.

Do newer AI models still hallucinate packages?

The published figures cover models from 2023 and 2024, where commercial models averaged 5.2% and open-source models 21.7%. We have not seen a study of the same size on current models. Since a registry lookup is free and exact, check every new name whatever the model.

How do I check that a package is real before installing it?

Look it up on the registry: npm view name time.created for npm, or the package's page on PyPI. Check that it exists, when it was first published, how many downloads it has and whether it links to a source repository. A name that is days old with no users deserves a read of its files first.

Can a coding agent be stopped from installing a bad package?

Yes, in two ways. Keep command approval on for installs, so that you see each one. Or add a hook that checks the command before it runs: Claude Code and Cursor both support hooks on shell commands, and a hook can refuse an install whose package does not exist or was published hours ago.

Sources

  1. 1.We Have a Package for You! A Comprehensive Analysis of Package Hallucinations by Code Generating LLMs, Spracklen et al., USENIX Security 2025
  2. 2.The Rise of Slopsquatting: How AI Hallucinations Are Fueling a New Class of Supply Chain Attacks, Socket
  3. 3.Diving Deeper into AI Package Hallucinations, Lasso Security
  4. 4.npm config: min-release-age, ignore-scripts, npm Docs
  5. 5.Settings: minimumReleaseAge, pnpm
  6. 6.OWASP Top 10 for LLM Applications 2025, OWASP GenAI Security Project

Your app is public. So are its mistakes.

Check what any attacker can already see in it, free, in ten seconds. The full attack, with proof and fixes: €49 once, or €29 a month on a plan.

or continue with Google or GitHub