PRACTITIONER GUIDE | SUPPLY CHAIN
Practitioner Guide11 min read

Slopsquatting: How AI-Hallucinated Packages Became a Supply Chain Attack

Why AI coding assistants sometimes recommend software packages that do not exist, and how attackers pre-register those exact names with malware waiting inside

19.7%
average package hallucination rate found across 16 LLMs and 576,000 code samples (USENIX Security 2025)
43%
of hallucinated package names repeated across all 10 queries against the same prompt in that study
53
hallucinated names still available for registration (41 PyPI, 12 npm) after Socket's April 2026 study of 5 frontier LLMs
237
GitHub repositories that pulled in react-codeshift, a hallucinated npm package name, via AI-generated agent skills

SponsoredHorizon3.ai

Proactive Security for the AI Era

NodeZero continuously and autonomously pentests infrastructure, identity, cloud, and now web applications, chaining weaknesses across every domain the way real attackers do. Every finding ships with replayable proof showing exploitable business impact, not theoretical risk.

See NodeZero WebApp in action

Ask an AI coding assistant to solve a problem and it will, with total confidence, sometimes hand you an install command for a package that was never published. This is not a rare glitch. Researchers who tested 16 code-generating LLMs across 576,000 code samples for the USENIX Security 2025 paper "We Have a Package for You!" found that recommended packages were hallucinated, meaning they do not exist on the registry the model implied, in 19.7% of responses on average, with 205,474 unique hallucinated names generated across the study.

Slopsquatting is the attack that turns that statistic into a compromise. An attacker does not need to guess what a developer might mistype, the way classic typosquatting works. Instead, they run the same or similar prompts through popular LLMs, collect the names those models hallucinate most reliably, and register those exact names on PyPI or npm with a credential stealer or backdoor inside. The Spracklen study found that 43% of hallucinated package names repeated across all 10 repeated queries against the same prompt, which is what makes this economically viable for an attacker: a name a model invents once by chance is not worth squatting on, but a name a model invents reliably, every time a similar question is asked, is a predictable target that will keep sending victims to it.

The mechanism that completes the attack is mundane. A developer, or increasingly an AI coding agent acting with less human review than a person would apply, runs the suggested pip install or npm install command. On npm, a malicious postinstall script executes the moment the package is installed, before any code that imports it is even run. On PyPI, malicious code can execute at import time or, in more persistent variants, be dropped into a location that runs automatically on every future Python process. Either way, the compromise happens at install, not at some later point a security review might catch.

This piece separates the peer-reviewed research on hallucination rates from the handful of documented cases that have actually surfaced, and lays out what a team can concretely do about it. For the broader software supply chain detection playbook this fits into, see how to detect supply chain compromise in a software build pipeline; this article focuses specifically on the AI-hallucination angle within that larger problem.

How a Slopsquatting Attack Actually Works

Slopsquatting runs in three steps, and none of them require the attacker to compromise anything that already exists.

First, reconnaissance. The attacker queries one or more LLMs with common coding prompts, the kind a developer would actually ask (build a REST client, parse a CSV, connect to Redis) and records which package names the model recommends that do not correspond to anything actually published on PyPI or npm. The USENIX researchers categorized how these hallucinated names arise: some are pure fabrications with no real analog, some are typo-like variants of a real package, and a large share are conflations, where two real, similarly-purposed packages get merged into a plausible-sounding name that matches neither. Socket's own 2026 research on five frontier models (Claude, Gemini, DeepSeek, and GPT variants, tested in April 2026 against 199,845 code responses) found 127 hallucinated names shared across all five models it tested, meaning the same fabricated name showed up regardless of which AI assistant a developer happened to be using. After PyPI's and Socket's own security review filtered out names that were already claimed or flagged, 53 of those shared names, 41 on PyPI and 12 on npm, remained available for anyone to register.

Second, registration. The attacker claims the hallucinated name on the relevant registry and publishes a package designed to look legitimate enough to survive a glance: a working facade that does something plausible, wrapped around a payload that runs on install. Because the name is not a typo of anything (a human proofreading a requirements.txt file has nothing to catch), and because it did not arrive through a phishing email or a suspicious link, it slips past the review habits most teams have actually built.

Third, distribution, and this is the part slopsquatting does not need to build itself. Every developer, and every AI coding agent, that asks a similar question later gets served the same hallucinated recommendation, because the underlying behavior that produced it in the model has not changed. The attacker does not have to advertise the malicious package or trick anyone individually; the LLM does the recommending for them, repeatedly, for free, to anyone who asks a similar enough question.

The Research Behind the Hallucination Rates

Two separate studies, run about a year apart, give a reasonably solid picture of how often this actually happens and whether it is getting better or worse.

The USENIX Security 2025 paper by Spracklen and colleagues remains the most rigorous public dataset. It tested 16 code-generating models, both commercial and open source, across 576,000 generated code samples and found an average hallucination rate of 19.7% for recommended package names. The gap between model classes was large: commercial models clustered around 5%, while open source models averaged closer to 21%. The study also found that 8.7% of hallucinated names invented in a Python context turned out to be real, valid JavaScript packages instead, a specific conflation pattern worth knowing about because it means a name flagged as "not real for this language" is not automatically safe to dismiss.

Socket's April 2026 follow-up, run by researcher Aleksandr Churilov against five current frontier models (Claude Haiku 4.5 and Sonnet 4.6, Gemini 2.5 Pro, DeepSeek V3.2, and GPT-5.4-mini) across 199,845 responses, found materially lower per-model rates, ranging from 4.62% to 6.10%. That is a real improvement over the 2025 baseline, consistent with model providers tightening up on code generation accuracy generally. But the more useful finding for defenders was not the raw rate, it was the overlap: 127 hallucinated names were shared across all five models tested, and after PyPI and Socket's own review removed names that were already registered or already flagged as suspicious, 53 names (41 on PyPI, 12 on npm) remained genuinely available for anyone to claim. Socket's own writeup is explicit that this is an exposure finding, not a confirmed attack: there is no evidence in that study that any of the 53 available names had actually been registered maliciously at the time of publication.

That distinction matters for how a team should read this whole topic. The hallucination rate has come down since 2025, and the frontier-model study found no confirmed malicious registrations among the names it surfaced. What has not come down is the predictability: names that repeat across models and across queries are, by definition, the ones worth squatting on, and that predictability does not go away just because the raw percentage does.

Free daily briefing

Briefings like this, every morning before 9am.

Threat intel, active CVEs, and campaign alerts, distilled for practitioners. 50,000+ subscribers. No noise.

Documented Cases: From Proof of Concept to Confirmed Malware

Slopsquatting has moved from a theoretical risk to a documented pattern in stages, and it is worth being precise about which cases were proof-of-concept research and which were confirmed malicious campaigns, because the two get conflated often in coverage of this topic.

The earliest and best-documented case is huggingface-cli on PyPI. In late 2023, security researcher Bar Lanyado noticed that AI coding assistants repeatedly recommended installing a package called huggingface-cli, when the actual Hugging Face command-line tool installs as part of the huggingface_hub package with a bracketed extra. Lanyado registered the hallucinated name himself and published a deliberately harmless package to test whether the phenomenon had real reach. It did: the package logged more than 30,000 authentic downloads over roughly three months, and Alibaba's GraphTranslator project ended up referencing the hallucinated install command directly in its own public README, having apparently copied it from an AI-generated suggestion without checking it against the real package. This was reported independently by The Register, Slashdot, and InfoWorld at the time, and it remains the clearest evidence that a hallucinated name can achieve real, sustained developer trust with zero attacker outreach.

A more recent case is react-codeshift on npm. In January 2026, Aikido Security researcher Charlie Eriksen found that AI coding assistants were hallucinating this name as a conflation of two real packages, jscodeshift and react-codemod, and that the hallucinated name had already propagated into 237 GitHub repositories through AI-generated agent skills that invoked it directly via npx, with no human necessarily reading the command before it ran. Eriksen registered the name himself as a proof of concept before an actual attacker could, which means, like huggingface-cli, this case demonstrates reach and plausibility rather than a confirmed live compromise. What makes it a meaningfully different data point than huggingface-cli is the delivery mechanism: the hallucinated name was not copy-pasted by a human from a chat window, it was executed automatically by agentic tooling acting on the model's suggestion.

A separate npm package, unused-imports, is reported as a confirmed malicious registration rather than a research proof of concept: it mimics the real eslint-plugin-unused-imports, a name pattern AI assistants are documented to confuse, and researchers at ReversingLabs have linked the campaign to the North Korea-attributed threat group tracked as Famous Chollima. As of early February 2026 it was still recording roughly 233 weekly downloads despite npm security-holding it. Because this attribution comes from third-party threat intelligence reporting rather than a primary source this article independently verified in full, treat the specific attacker attribution as reported rather than confirmed, while the existence of a malicious package targeting that naming confusion is well documented across multiple outlets.

None of this is the same incident as the March 2026 LiteLLM PyPI compromise, and it is worth being explicit about why. That attack, covered in full in our LiteLLM supply chain attack writeup, involved threat actor TeamPCP compromising the real, legitimate LiteLLM package's publishing pipeline (by first breaching Aqua Security's Trivy scanner and using stolen tokens to push malicious LiteLLM releases) rather than registering a name an AI model hallucinated. It is a different supply chain vector: a trusted, already-popular package's build and release process was hijacked, not a fabricated name that developers were tricked into trusting for the first time. Both belong in a supply chain threat model, but they call for different controls, and conflating them understates how many distinct ways a dependency can turn hostile.

Why AI Coding Workflows Make This Worse, Not Just Different

The react-codeshift case is the clearest illustration of what changes when AI moves from suggesting code to executing it. A human developer who is handed a suspicious install command at least has the option to pause and Google the package name. An AI coding agent operating with tool-use permissions, wired into an agent skill or automated pipeline, can go from "the model suggested this package" to "npx just ran it" with no intermediate checkpoint at all, which is exactly the path Eriksen documented: agent skills invoking the hallucinated name directly, no human review in the loop.

This is not a hypothetical concern specific to one vendor's tooling. Any workflow where an LLM's output is piped directly into a shell, a CI job, or an autonomous coding agent's next action removes the one control that has protected developers from this class of risk for years: a human pausing before running an unfamiliar install command. The same pattern that makes AI coding assistants valuable, reducing the friction between "I need a library for this" and "the code that uses it is running", is the pattern that removes the friction an attacker needs eliminated to make slopsquatting work.

CI/CD pipelines compound this further. A build script that pins dependencies loosely, or a Dockerfile that runs pip install -r requirements.txt against a file an AI assistant helped draft, inherits whatever hallucinated name made it into that file, and runs it in an environment that often holds far more valuable credentials than a single developer's laptop. If a hallucinated or slopsquatted package does make it into a build environment, the detection and containment steps look the same as for any other build pipeline compromise: see how to detect supply chain compromise in a software build pipeline for the general playbook, and the GitHub Actions supply chain incident response checklist for the CI-specific forensic steps once a bad package is confirmed to have run.

How to Defend Against Slopsquatting

None of the controls below are exotic. Slopsquatting succeeds because ordinary install-time hygiene gets skipped when the recommendation came from an AI assistant that developers implicitly trust more than they would trust a random forum post. Restoring that scrutiny is most of the work.

Verify a package exists and is legitimate before installing anything an AI assistant suggested

Before running an install command an LLM produced, check the package's registry page directly: publish date, maintainer history, download count, and source repository. A package with no history, a maintainer account created the same week, or a suspiciously round or newly-spiking download count is worth a second look regardless of how confidently the assistant recommended it.

Pin dependencies with lockfiles and hash verification

Use package-lock.json, poetry.lock, or an equivalent, and enable hash verification where the ecosystem supports it (pip's --require-hashes, npm's integrity field). This does not stop a first-time install of a malicious package, but it stops a slopsquatted name from silently substituting itself into a build later once someone else has already vetted the dependency tree.

Route installs through a private registry or proxy with an allowlist

Tools like a scoped Artifactory or Verdaccio proxy, or an internal PyPI mirror, let a team require that any new package name be explicitly approved before it is available to pull in a build, which directly blocks the failure mode where a developer or an AI agent installs a hallucinated name nobody on the team has ever seen before.

Run software composition analysis that flags brand-new or low-adoption packages

SCA and dependency scanning tools that surface a package's age, maintainer count, and download volume at the point a new dependency is introduced catch the specific signal a hallucinated or slopsquatted name almost always carries: it did not exist, or was barely used, until very recently.

Require a human approval step before an AI coding agent executes an install command

If an agent or automated coding workflow has permission to run pip install or npm install as part of its own tool use, gate that specific action behind explicit human confirmation rather than letting the agent execute it as a normal part of task completion. This is the control that would have interrupted the react-codeshift propagation pattern, where agent skills ran the install with no human in the loop at all.

Treat a confirmed slopsquatted package the same as any other supply chain compromise once it is found

If a hallucinated or maliciously-registered package is discovered in a build environment or CI pipeline, the response is not specific to AI: contain the affected systems, rotate any credentials the build had access to, and audit what the package's install-time payload could have reached. [The GitHub Actions supply chain incident response checklist](/blog/github-actions-supply-chain-incident-response-checklist) covers those forensic steps in detail.

The bottom line

Slopsquatting is a real and mechanically simple attack pattern built on a well-documented behavior of code-generating LLMs, not a hypothetical. The USENIX Security 2025 research puts the average hallucination rate at 19.7% across 16 models, and Socket's 2026 follow-up on frontier models found the rate has come down but the underlying predictability, the same fabricated names repeating across different models and different queries, has not. Confirmed cases so far are a mix of researcher-run proofs of concept that demonstrated real reach (huggingface-cli, react-codeshift) and at least one reported malicious campaign (unused-imports) rather than a wave of large-scale breaches, which is a reason for disciplined attention rather than alarm. The defense is not exotic: verify before you install, pin and hash your dependencies, route new packages through a reviewed registry, and never let an AI agent run an install command without a human checkpoint. Do that consistently and a hallucinated name has nowhere to land, whether or not anyone has registered it yet.

Frequently asked questions

What is slopsquatting?

Slopsquatting is a software supply chain attack where an attacker registers a package name that AI coding assistants commonly hallucinate, publishes malicious code under that name on a registry like PyPI or npm, and waits for a developer or AI coding agent to run the model's suggested install command without checking whether the package genuinely exists.

How often do AI coding assistants recommend packages that do not exist?

A USENIX Security 2025 study of 16 code-generating LLMs across 576,000 code samples found an average hallucination rate of 19.7%, with commercial models around 5% and open source models around 21%. A 2026 Socket study of five newer frontier models found lower per-model rates of 4.62% to 6.10%, but 127 hallucinated names were shared across all five models tested, showing the behavior is consistent regardless of which assistant is used.

Has slopsquatting caused a confirmed real-world security incident?

Confirmed cases exist but are limited so far. Researchers have run proof-of-concept registrations, such as huggingface-cli on PyPI and react-codeshift on npm, to demonstrate that hallucinated names achieve real developer trust, and at least one package, unused-imports on npm, is reported as a confirmed malicious registration by security researchers. Large-scale breaches directly traced to slopsquatting have not been documented as of this writing.

How is slopsquatting different from typosquatting?

Typosquatting relies on a human mistyping a package name, such as installing reqeusts instead of requests. Slopsquatting does not require any human error at all; the attacker targets a name an AI model reliably invents on its own, then waits for that model's own suggestion to be the source of the compromise rather than a typing mistake.

Is the March 2026 LiteLLM supply chain attack an example of slopsquatting?

No. The LiteLLM incident involved threat actor TeamPCP compromising the real, already-trusted LiteLLM package's build and publishing pipeline through a prior breach of the Trivy scanner, not registering a name an AI model hallucinated. It is a distinct supply chain vector covered in full in our separate LiteLLM supply chain attack article, and it should not be conflated with slopsquatting even though both are software supply chain risks.

What is the single most effective control against slopsquatting?

Requiring a human checkpoint before any install command an AI assistant or coding agent produces actually executes is the most effective single control, since it directly targets the mechanism that turns a hallucinated name into a compromise: an install running without anyone confirming the package is real. Pinned lockfiles, hash verification, and a reviewed private registry reinforce that check for team-wide and CI environments.

Sources & references

  1. Socket.dev: Slopsquatting Targets Across Frontier LLMs
  2. Aikido: Slopsquatting, the AI Package Hallucination Attack Already Happening
  3. USENIX Security 2025: We Have a Package for You! A Comprehensive Analysis of Package Hallucinations by Code Generating LLMs (Spracklen et al.)
  4. The Register: AI Bots Hallucinate Software Packages and Devs Download Them
  5. InfoWorld: Supply-Chain Attacks Take Aim at Your AI Coding Agents
  6. Decryption Digest: LiteLLM Supply Chain Attack Exposed 434,000 CI/CD Pipelines

Free resources

25
Free download

Critical CVE Reference Card 2025–2026

25 actively exploited vulnerabilities with CVSS scores, exploit status, and patch availability. Print it, pin it, share it with your SOC team.

No spam. Unsubscribe anytime.

Free download

Ransomware Incident Response Playbook

Step-by-step 24-hour IR checklist covering detection, containment, eradication, and recovery. Built for SOC teams, IR leads, and CISOs.

No spam. Unsubscribe anytime.

Free newsletter

Get threat intel before your inbox does.

50,000+ security professionals read Decryption Digest for early warnings on zero-days, ransomware, and nation-state campaigns. Free, daily, no spam.

Unsubscribe anytime. We never sell your data.

Eric Bang
Author

Founder & Cybersecurity Evangelist, Decryption Digest

Cybersecurity professional with expertise in threat intelligence, vulnerability research, and enterprise security. Covers zero-days, ransomware, and nation-state operations for 50,000+ security professionals every morning.

Giveaway: InfoSec World 2026 All Access Pass ($3,895 value)

Details →
Daily Briefing

Subscribe to enter the giveaway

Every subscriber is automatically entered. You also get daily threat intel every morning: zero-days, ransomware, and nation-state campaigns. Free. No spam.

Already subscribed? You're already entered.

Giveaway

Win a $3,895 InfoSec World 2026 pass.