BlogSupply chain
Slopsquatting: when AI-written code installs packages that don't exist
AI coding tools invent package names, and the same fake names come back again and again. Anyone can register them. Here's what the research found, and what a small team can do this week.
Omer Bar-Ness · Founder
Ask a coding assistant to parse a file format, and it will often write pip install something or npm install something above the code. Most of the time that package is real. Sometimes it isn't. The model made up a name that sounds right.
That's annoying when the install just fails. It's dangerous when someone has already registered the made-up name and put malware in it. That attack has a name: slopsquatting.
This post covers what it is, what the research measured, what has actually happened, and what a small team can do about it this week.
What slopsquatting is
Typosquatting is an old trick. An attacker publishes reqeusts and waits for someone to mistype requests. The victim makes the mistake.
Slopsquatting is the same trick, except the AI makes the mistake. A model suggests a package that doesn't exist. An attacker notices which names models invent, registers them on npm or PyPI, and fills them with code that runs on install. The next developer, or the next coding agent, who follows the same suggestion installs the attacker's package.
Figure 1
Seth Larson, security developer-in-residence at the Python Software Foundation, coined the term. The Register reported in April 2025 that he “has dubbed it ‘slopsquatting’”, slop being a common put-down for AI output. Socket's write-up from the same month credits Larson with the term and Andrew Nesbitt with spreading it.
What the research found
The best measurement so far is a paper by Joseph Spracklen and colleagues at the University of Texas at San Antonio, the University of Oklahoma and Virginia Tech: “We Have a Package for You! A Comprehensive Analysis of Package Hallucinations by Code Generating LLMs”. It was published at the 34th USENIX Security Symposium in 2025, where it won a Distinguished Paper Award.
They tested 16 popular code-generating models on two sets of prompts: one built from real Stack Overflow questions, one written by a model. They generated 576,000 Python and JavaScript code samples and checked every package the code needed against PyPI and npm.
What they found (full paper, PDF):
- About one in five packages did not exist. Of 2.23 million packages, 440,445, or 19.7%, were hallucinations.
- That was 205,474 unique fake names. Not a short list someone could block by hand.
- Commercial models did better, but not well enough. The commercial models in the study, OpenAI's GPT models, averaged 5.2%. The open-source ones averaged 21.7%. The best, GPT-4 Turbo, was at 3.59%.
- JavaScript was worse than Python. 21.3% against 15.8% on average.
- The same fake names come back. The authors re-ran 500 prompts that had produced a hallucination, 10 times each. 43% of the hallucinated packages came back in all 10 runs, and 58% came back more than once.
| Group | Hallucinated packages |
|---|---|
| All 16 models | 19.7% |
| Commercial (GPT) models, average | 5.2% |
| Open-source models, average | 21.7% |
| Python code, average | 15.8% |
| JavaScript code, average | 21.3% |
Table 1. Share of recommended packages that did not exist on PyPI or npm. Spracklen et al., USENIX Security 2025.
That last bullet is what makes this an attack and not just a bug. In the paper's words, “a persistent hallucination is more valuable for malicious actors looking to exploit this vulnerability.” If a model invents the same name every time you ask a common question, an attacker only has to ask once and register the result.
One more detail is worth knowing. 8.7% of the hallucinated Python package names turned out to be real JavaScript packages. So a name that exists on some registry is not proof that it's the package you meant.
The paper also tested fixes on the model side, such as retrieval and fine-tuning. Combining them cut hallucinations by 85% for DeepSeek and 64% for CodeLlama. That helps, but you don't control how your coding tool was built. You control what gets installed.
Has it actually happened?
Yes, in two well-documented cases, both run by security researchers rather than attackers.
huggingface-cli (2024). Bar Lanyado at Lasso Security came across a hallucinated Python package called huggingface-cli. He uploaded an empty package under that name to PyPI. “In three months the fake and empty package got more than 30k authentic downloads!” he wrote. He also found instructions for installing it in the README of a repository for research by Alibaba. His package was empty. Someone else's might not have been.
react-codeshift (2026). Charlie Eriksen at Aikido describes claiming an npm package that had never existed: “On January 14th, 2026, I claimed a package on npm called react-codeshift.” The name looks like a blend of two real tools, jscodeshift and react-codemod. He traced it to a single commit that “dumped 47 LLM-generated ‘Agent Skills’ across 14 plugins.” Those skill files told coding agents to run npx react-codeshift, and 237 GitHub repositories were already referencing the name. After he registered it, he saw a “persistent trickle of 1-4 downloads per day,” which he attributes to AI agents following those instructions.
The second case shows where this is heading. It is no longer only a developer copying a line from a chat window. Agents now read instructions and run install commands on their own, often without a person watching. A hallucinated name written into a shared file gets installed by every agent that reads it.
Larson's advice in The Register piece is the right starting point:
“Users of LLM generated code, packages, and information should be double-checking LLM outputs against reality before putting any of that information into operation, otherwise there can be real-world consequences.”
Seth Larson, Python Software Foundation · The Register ↗
What a small team can do
You don't need a security team for this. Most of the defense is habits and settings you can turn on in an afternoon.
-
Commit a lockfile, and install from it
A lockfile records the exact version of every package. In CI, install from it and fail if it doesn't match. With npm,
npm cidoes exactly this: “If dependencies in the package lock do not match those in package.json, npm ci will exit with an error.” With Python, uv and Poetry write lockfiles. For plainrequirements.txt, pip's hash-checking mode (--require-hashes) refuses any package whose hash isn't listed.A lockfile won't stop a bad package being added. It does mean a new package shows up as a visible change in the pull request, instead of arriving quietly at install time.
-
Pin versions
Pin exact versions in what you ship. The OpenSSF guide for AI code assistants suggests telling your assistant to “Specify version ranges or exact versions.”
-
Wait before installing brand-new releases
Malicious releases tend to be found and pulled fast. pnpm's docs say: “In most cases, malicious releases are discovered and removed from the registry within an hour.” A cooldown means you never install something that has only just been published. npm has a
min-release-agesetting, so that “only versions that were available more than the given number of days ago will be installed.” pnpm'sminimumReleaseAgedoes the same in minutes, and uv'sexclude-newertakes a date or a duration such as1 week. A newly registered hallucinated name is, by definition, brand new.Lockfile installs and a 7-day cooldown# CI: install exactly what the lockfile says npm ci pip install --require-hashes -r requirements.txt # .npmrc min-release-age=7 # pnpm-workspace.yaml (minutes) minimumReleaseAge: 10080 # pyproject.toml [tool.uv] exclude-newer = "1 week" -
Check that a package is real before you add it
Before you accept a new dependency, look it up on npmjs.com or pypi.org. Does it exist? Who publishes it? When was it first released? Does it have a source repository? Does the name match the project your assistant described? A package first published last week with no repository is a red flag.
-
Tell your coding assistant the rules
Most tools read an instructions file (
AGENTS.md,CLAUDE.md, Cursor rules, Copilot instructions). The OpenSSF guide has wording you can copy, including: “Do not add dependencies that may be malicious or hallucinated. Always use the official package manager for the given language (npm, pip, Maven, etc.) to install libraries, rather than copying code snippets.” It won't make the model perfect. It reduces how often you have to catch it. -
Review new dependencies like new code
A new line in
package.jsonorrequirements.txtis a decision to run someone else's code. Look at dependency changes in every pull request, and treat agent skill files and setup scripts the same way. Eriksen's advice after react-codeshift says the same: “Treat skills as code, not documentation.” -
Know the registries are working on it, but don't count on it
The registries do remove malware. PyPI added a quarantine that lets admins mark a suspicious project and stop it being easily installed while they look at it. Admins quarantined about 140 projects between August and the end of 2024. That shortens the window. It doesn't close it, and a package can do its damage on the first install.
What MergeSafe does here
This is the problem MergeSafe's Malicious Package Guard was built for. It checks every npm and PyPI package a pull request adds for known CVEs, malicious versions, and lookalike or made-up names, for free, with or without a review. It's advisory by default, and an admin can make it block the merge until someone signs off. The hourly CVE check on the packages you already use is free too, verification included. It's a backstop for the habits above, not a replacement for them.
MergeSafe's Malicious Package Guard checks every npm and PyPI package a pull request adds, free, before it merges.
Sources and further reading
- We Have a Package for You! A Comprehensive Analysis of Package Hallucinations by Code Generating LLMsUSENIX Security 2025 · Spracklen, Wijewickrama, Sakib, Maiti, Viswanath, Jadliwala · PDF · arXiv
- LLMs can't stop making up software dependencies and sabotaging everythingThe Register · Thomas Claburn, Apr 12, 2025
- The Rise of Slopsquatting: How AI Hallucinations Are Fueling a New Class of Supply Chain AttacksSocket · Sarah Gooding, Apr 8, 2025
- Diving Deeper into AI Package HallucinationsLasso Security · Bar Lanyado, Mar 28, 2024
- Agent Skills Are Spreading Hallucinated npx CommandsAikido · Charlie Eriksen, Jan 21, 2026
- Security-Focused Guide for AI Code Assistant InstructionsOpenSSF Best Practices and AI/ML Working Groups, Aug 1, 2025
- npm ci and npm config: min-release-agedocs.npmjs.com
- pnpm settings: minimumReleaseAgepnpm.io
- uv settings: exclude-newerdocs.astral.sh
- pip: Secure installs and hash-checking modepip.pypa.io
- Project QuarantinePyPI blog · Mike Fiedler, Dec 30, 2024