Key Takeaways
- Slopsquatting is when an attacker registers a package name an AI tool invented and waits for someone to install it.
- It works because hallucinations repeat, and 43% came back in all ten reruns in the USENIX study.
- A repository that refuses anything outside an approved catalog stops an invented name from resolving at all.
- Coding agents that install dependencies on their own remove the last human checkpoint.
Someone on your team pastes a Python snippet from an AI assistant, runs the pip install line that came with it, and the terminal scrolls past without complaining. The import works. Slopsquatting is what happens when that package name pointed at nothing until an attacker claimed it. The model invented it, somebody registered it first, and the install handed them a foothold.
This guide walks through what slopsquatting means, how the attack chain runs, what the research actually shows about how often it happens, and which defenses hold up before it reaches a real pipeline.
What Is Slopsquatting?
Slopsquatting is a software supply chain attack in which an attacker registers a package name that large language models tend to hallucinate, then publishes malicious code under it. The developer installs it because their AI assistant said it existed. That is a package hallucination: the model recommends a dependency that is not in the registry it just pointed you at.
The term was coined by Seth Larson, security developer-in-residence at the Python Software Foundation, and picked up more widely by Andrew Nesbitt, who runs the open source data platform Ecosyste.ms. It bolts “AI slop” onto typosquatting.
Nobody mistyped anything here. The install command was correct, the name was spelled exactly as the model wrote it, and the confidence behind it came from a system that never verified the name against the registry it was recommending from.
Slopsquatting vs Typosquatting
Typosquatting exploits human error. reqeusts instead of requests. Or python3-dateutil, uploaded to PyPI in 2019 to shadow python-dateutil and removed days later once someone noticed it pulled in a second package that harvested SSH and GPG keys. Slopsquatting exploits machine error, and machine error turns out to be far more organized.
| Typosquatting | Slopsquatting | |
| What triggers the install | Human typo or a misremembered name | An AI recommends a name that is not in the intended registry |
| Scale seen in one study | Clustered around a handful of high-value targets | 205,474 unique hallucinated names observed |
| Predictability | Attacker guesses likely misspellings | Attacker harvests names by prompting models |
| Similarity to real names | Usually a small edit away from the real thing | 13.4% of Python hallucinations within edit distance 1–2 of the nearest real package; 48.6% six edits or more away |
| Who is exposed | Developers and automated workflows resolving a mistaken name | Anyone accepting AI-generated dependency lists, agents included |
Many hallucinated names are nowhere near a real package. Only 13.4% of the hallucinated Python names landed within one or two characters of the closest existing name, while 48.6% were six edits or more away. These are plausible-sounding inventions rather than near misses, which is why edit-distance and name-similarity checks miss so many of them.
The names also recur. The USENIX researchers took 500 prompts that had produced hallucinations and re-ran each one ten times. 43% of the hallucinated names appeared in all ten runs, and 58% appeared more than once. An attacker does not have to guess. That recurrence is the real separation from classic typosquatting, where the attacker is predicting how humans mistype rather than measuring what a model reliably invents.
How a Slopsquatting Attack Works
Four steps, none of them technically demanding, which is part of why AI-hallucinated packages make such an efficient delivery mechanism. A successful attempt maps onto MITRE ATT&CK T1195.001, Compromise Software Dependencies and Development Tools, so it lands inside a threat model you already have rather than off to one side as something exotic.
1. Harvest the hallucinations
The attacker runs code-generation prompts at volume, collects every package name in the output, and checks each one against PyPI or npm. Names that do not resolve go on the list. Names that keep not resolving, across repeated runs of the same model, go to the top.
One finding is worth sitting with. In the USENIX study, hallucinated names were far more often specific to one model than shared across models: 81% of the unique names came from exactly one of the 16 models tested. Recurrence and overlap vary by model, so the sensible move is to measure the assistants your own team actually uses rather than assume a shared blacklist covers you.
Measurement at research scale is not cheap, but it does not need to be. The USENIX team generated 576,000 code samples across 16 models to cover two languages and a broad prompt set. The volume required to probe one framework, one cloud SDK, or one internal-sounding use case is a different and much smaller problem.
Model choice mattered a great deal in the models that the study tested in early 2024, where open source models hallucinated at 21.7% on average against 5.2% for the commercial ones. A 2026 preprint applying the same methodology to five newer frontier models found overall rates clustering between 4.62% and 6.10%. It has not been peer reviewed, so treat it as an early signal rather than a settled trend. The invented names have not gone anywhere either way.
Insider Tip: Plausible suffixes such as -utils, -helpers, -client, and -sdk can make an invented name look credible at a glance. Treat a sensible-looking naming convention as a prompt to check, never as evidence that a package is real.
2. Register the name and make it look alive
The attacker registers the best names and publishes something that works. Functional code doing roughly what the name implies, a README, a license that reads normally.
The payload sits in the install path or in an import nobody hits often. An install hook that makes an outbound request when it runs, or code that behaves one way on a laptop and another way somewhere with credentials and network access worth having. Benign-looking functionality buys time precisely because the expected import appears to work.
The download numbers make the point better than any hypothetical. Lasso Security registered an empty package under the hallucinated name huggingface-cli and recorded more than 30,000 downloads over three months, including an Alibaba research repository whose README told people to install it. A benign proof of concept, with no payload in it at all, still ended up referenced in real development artifacts.
3. A developer installs it on the AI’s word
The install itself is unremarkable. Someone asks an assistant how to do a thing, gets working-looking code, and runs the command that came with it.
pip install PACKAGE_NAME
Absent registry controls or endpoint alerting, no warning fires. The package resolves, installs, imports. If the developer checks anything, they check that the import works, which it does.
The model’s confidence transfers here. A package name sitting inside otherwise-correct code borrows the credibility of that code, and on a fast-moving team a new dependency introduced in an otherwise routine change gets less attention than the logic around it unless review explicitly surfaces dependency additions. A person still has to read the suggestion and choose to run it. Where an agent is allowed to install dependencies and no approval gate sits in the way, nobody reads it at all.
4. It persists through builds and CI
Once the name is in requirements.txt or package.json, it stops being a decision and becomes infrastructure. Builds that install from that manifest pull it. New container images bake it in. Every environment that resolves the dependency inherits it, from laptops to CI runners to build systems holding deployment tokens and registry credentials.
Transitive spread makes it worse. If the compromised package gets pulled in as a dependency of an internal library, it reaches services whose maintainers never saw the original suggestion. By then the audit question is no longer who installed this. It is where it ended up.
From there the outcomes are the ordinary catalogue for any compromised dependency: credential theft, cryptomining, unexpected outbound traffic, or a broader compromise of whatever the build environment can reach, Linux hosts included.
Watch Out: Lockfiles pin the malicious package as faithfully as a legitimate one. A lockfile guarantees reproducibility; it says nothing about what got locked in. It will reproduce the compromise on every host that installs from it until the dependency and its lockfile entry are deliberately removed.
What the Research Shows
These numbers come from We Have a Package for You! A Comprehensive Analysis of Package Hallucinations by Code Generating LLMs, presented at USENIX Security 2025. It is the large-scale study everyone else in this space ends up citing, and every figure in the table below traces back to it rather than a secondhand summary.
| Finding | Figure |
| Hallucinated package recommendations | 440,445 of 2.23 million (19.7%) |
| Unique hallucinated names observed | 205,474 |
| Open source model hallucination rate | 21.7% |
| Commercial model hallucination rate | 5.2% |
| Hallucinations repeated in all 10 reruns | 43% |
| Hallucinations that never repeated | 39% |
| Python hallucinations valid as npm packages | 8.7% |
Three things here matter more than the headline percentage.
Recurrence is the attack enabler. 43% of hallucinated names came back in all ten reruns and 58% came back more than once, which puts the bulk of them outside the range of one-off noise. Repeatable is what makes harvesting worth an attacker’s time.
The cross-ecosystem number is the one that trips people up. 8.7% of the hallucinated Python names were valid npm packages, so a developer who checks whether a name exists somewhere gets a green light that means nothing. Existing in another registry is not evidence that it is the dependency you asked for.
The language split moves. Across the 2024-era models in the USENIX study, JavaScript hallucinated at 21.3% against Python’s 15.8%. The 2026 preprint reported that relationship inverted across its five newer models. Treat it as a property of the model in front of you rather than of the language.
Why AI Agents Raise the Stakes
Step 3 above assumes someone reads an AI code suggestion before running it. Agentic tooling can remove that assumption. An agent that reads an error, decides a dependency is missing, and installs it has closed the loop, and without a preview, a policy check, or an approval gate, the package name reaches disk before anyone sees it.
Vendor testing suggests the tooling is improving without solving it. Trend Micro’s slopsquatting research found that coding agents with chain-of-thought reasoning and live web search cut hallucination rates by roughly half in its evaluation, with the setups doing live validation producing the fewest phantom dependencies of all. Names still got through. Trend Micro puts the residual errors down to context-gap filling, surface-form mimicry, and cross-ecosystem name borrowing, where the agent assembles something that follows the conventions of real packages without corresponding to one.
A 50% reduction is meaningful. It is not a control you can hand to an auditor.
Then there is vibe coding, which here means accepting AI-generated code quickly without independently reviewing its dependencies or what they do on install. The safer default is the opposite one. Any AI-suggested third-party dependency stays unverified until something other than the model confirms the package and version. Pair that gap with agents that install on their own and the review checkpoint stops existing.
How to Defend Against Slopsquatting
No single control catches this. Verification catches the obvious cases, pinning limits the blast radius, an enforced allowlist closes the resolution path, and scanning and review policy keep the first three honest. Run them together.
If your builds resolve straight from public registries, the allowlist in defense 3 is the one that changes the shape of the problem. If you already run an internal mirror, find out first whether it enforces an allowlist or simply caches whatever it is handed, because an unrestricted pull-through cache leaves this exposure roughly where it was.
1. Verify the package exists and has history
Before an AI-suggested package goes into a manifest, check when it was first published, who maintains it, whether the repository behind it is real and active, and whether the artifact on the registry corresponds to that source. Publication and maintainer data come straight from registry metadata, without installing anything or executing package code.
curl -s https://pypi.org/pypi/PACKAGE_NAME/json
npm view PACKAGE_NAME time.created maintainers
Adoption is a separate lookup. PyPI’s JSON endpoint returns -1 in its download fields, so pull that from pypistats or the BigQuery dataset if download volume is part of your bar. Repository authenticity and source-to-artifact correspondence need their own verification too; a registry link on its own proves nothing about who owns what it points at.
Set the bar as policy rather than instinct. Age, adoption, maintainer identity, verified source-to-artifact match. Those four will surface obvious inconsistencies before a dependency enters the graph, and a well-built malicious package can still clear all of them. They are review signals, not proof of safety.
2. Pin dependencies with lockfiles and hashes
Lockfiles give you reproducibility. Hashes give you integrity: assuming the hash was obtained and protected through a process you trust, they confirm the artifact you installed is the artifact you approved.
pip install –require-hashes -r requirements.txt
Hash-checking mode is all or nothing. Every requirement and every transitive dependency has to be pinned with == and carry a hash, or the install fails outright, so budget for the first pass being a chore. What pinning does not do is tell you the thing you pinned was ever safe. npm’s registry data is immutable, so a given name and version cannot be republished even after an unpublish; the realistic failure is approving and freezing the wrong package on day one, which is why pinning belongs after verification rather than instead of it.
Install-time script execution is a separate lever, and npm has already pulled it. Current npm blocks dependency install scripts by default, skipping lifecycle scripts for anything without a matching entry in allowScripts and listing what it skipped at the end of the install. npm install-scripts approve and npm install-scripts deny maintain that list, with approvals pinned to the version you actually reviewed.
npm ci –ignore-scripts
On older npm, that flag is the blunt version of the same idea, minus the allowlist. Either way it only covers install time. Code that runs at import, at build, or at runtime is untouched.
3. Pull only from a curated source
The strongest structural move is to change what a name is able to resolve to. A repository that refuses anything outside an approved catalog fails an invented name at resolution, which is the cheapest place in the whole chain to fail.
That property comes from the allowlist, not from the repository being curated. Plenty of private registries serve vetted builds for the packages they cover and proxy everything else from upstream, which leaves the original exposure intact for every name outside the covered set. Worth checking before you assume a mirror has closed the door.
TuxCare’s SecureChain is built for the covered set. It spans six ecosystems, JavaScript, Python, Java, Go, Rust, and PHP, all served from the same curated catalog. Rollout timing varies a little by ecosystem and one or more may still be in pre-launch, so email [email protected] if you need current status for a particular stack.
Packages are rebuilt from source in hardened, isolated environments, screened for known malware and suspicious code patterns, and patched under SLA as CVEs land, with SLSA Level 3 provenance and SBOM and VEX data available. Point your package or repository manager at the TuxCare registry and the regenerated lockfile records TuxCare URLs and checksums rather than public tarballs. Per TuxCare’s own documentation, that registry serves SecureChain builds where they exist and public upstream packages for the rest through the same endpoint, so the anti-slopsquatting guarantee comes from the allowlist you enforce on top of it, not from the registry swap alone.
4. Scan and watch behavior on new dependencies
Signature and reputation scanning works best against threats somebody has already identified. A freshly registered malicious package has not made it into those databases yet, which is exactly the window slopsquatting operates in.
Behavioral checks fill the gap. Unexpected network access during install, obfuscated or minified source in a package that should be plain, credential and environment-variable reads, writes outside the package directory. Plenty of legitimate packages do one or two of these, native-module builds especially, so the job is to surface them for review rather than block on them automatically.
Scan dependency changes in CI before they merge, and keep a scheduled rescan running as well. The first catches what you are adding; the second catches the package that was fine when it went in and stopped being fine three weeks later.
Expert Tip: Diff the dependency manifest in every pull request and require explicit sign-off on additions, separate from the code review. Separating dependency changes from general code changes is what makes supply chain review visible enough to insist on.
5. Write a review policy for AI-generated code
Tooling does not fix a process gap. Decide, in writing, what happens when an AI tool proposes a dependency.
A workable policy treats any AI-suggested package as untrusted until a person has run it through the checks in defense 1, and approves new dependencies by name and version rather than on the strength of a green build. Agents do not get unreviewed write access to dependency manifests; additions and version changes go through an approval gate. The approved source list gets enforced in the package manager or repository policy layer, so a policy failure shows up as a build failure instead of as a trust exercise.
What TuxCare SecureChain Changes About What You Install
Slopsquatting works because an install command will cheerfully resolve a name nobody vetted. SecureChain changes what you get when it resolves one. Packages in the catalog are rebuilt from verified source and screened for known malware and suspicious patterns before they are available to install, and they keep getting patched after upstream maintainers move on, which covers the compromised-dependency problem sitting right next to the hallucinated-name one.
Enforce an allowlist on top, so the build cannot reach past that catalog, and an invented name has nothing to install from at all, whether or not an attacker got there first.
See how it fits your stack on the SecureChain for OSS page, or ask us a question about your specific environment.
FAQs
As of this writing, no publicly documented case runs cleanly from a specific model hallucination through to a confirmed compromise at a named organization. Malicious packages using slopsquatted names are well documented, though, and the clearest is the PhantomRaven campaign. Reporting citing Koi Security puts the first wave on npm in October 2025 at 126 packages and more than 86,000 downloads, with Endor Labs later tracing 88 more across three waves through February 2026, several mimicking Babel plugins, GraphQL tooling, and ESLint presets. Attribution is disputed. The packages were claimed to be a security research exercise, a characterization Endor Labs rejected after finding credential harvesting and live command-and-control infrastructure.
Sometimes. Compare when the package was published against when your assistant suggested it, then look at the repository, the maintainer history, and the release history. A newly published package with no verifiable upstream project warrants a hard look. Age on its own proves nothing, because assistants with web search and registry tooling can legitimately recommend something published last week.
Only if it enforces an allowlist and your builds actually resolve through it. A pull-through cache that fetches any requested name from upstream on demand reproduces the same exposure with an extra hop between you and the attacker.
A bit. In the USENIX self-detection test, three of the four models asked to re-check their own output identified hallucinated names with better than 75% accuracy. That is the model auditing its own memory under controlled conditions, not verifying anything against a registry. Pairing the assistant with live search and validation tooling did more in Trend Micro’s evaluation, roughly halving hallucination rates, because the check finally comes from outside the model that made the error.
No stable answer. The 2025 USENIX study measured JavaScript higher than Python, 21.3% against 15.8%, while the 2026 preprint reported the reverse across its five newer models. Exposure tracks the model, the prompt set, and the workflow more than it tracks the language.




