AI Coding Assistants Keep Suggesting Packages That Don't Exist, and Attackers Are Ready

Ask an AI coding assistant to pull in a library for retrying HTTP requests or parsing a CSV, and there's a real chance it will suggest a package that does not exist. Security researchers call this slopsquatting — attackers registering the exact names that large language models hallucinate, then waiting for a developer's AI assistant to recommend installing them. The malicious package runs the moment someone types pip install or npm install on the assistant's suggestion.
The term was coined in 2025 by Seth Larson, security developer-in-residence at the Python Software Foundation, after researchers at the University of Texas at San Antonio, Virginia Tech, and the University of Oklahoma ran 16 code-generation models against tens of thousands of coding prompts and found that roughly one in five recommended packages did not exist on PyPI or npm. Open-source models hallucinated at nearly double the rate of commercial ones, but no model tested was immune, and about 43 percent of the hallucinated names repeated across multiple prompts and multiple runs — meaning an attacker only has to register a package once to catch a steady stream of victims.
That repeatability is what makes slopsquatting more dangerous than old-fashioned typosquatting. A typosquat relies on a human fat-fingering reqeusts instead of requests — a narrow, somewhat random attack surface. A hallucinated package name is a prediction an LLM will make again and again for the same prompt, because the model is pattern-matching against plausible-sounding library names it half-remembers from training data. Register huggingface-cli-utils or node-fetch-retry-wrapper once, and the same name will surface to different developers, on different days, from different models, with uncomfortable consistency.
Why models do this
LLMs generate package names the same way they generate any other token sequence: by predicting what's statistically likely to come next, not by checking a registry. A model trained on millions of GitHub repositories learns that import statements for HTTP retries tend to look a certain way, and it will confidently produce a plausible-looking name even when no such package was ever published. Retrieval-augmented or tool-using coding assistants that can actually query PyPI or npm in real time are less prone to this, but plenty of IDE autocomplete and chat-based assistants still generate suggestions from pretrained weights alone, especially for less common libraries where training data is thin.
The problem compounds with model confidence. Researchers found models rarely hedge on invented package names — no "I'm not certain this package exists," just a clean import line and a clean install command. Developers under deadline pressure copy-paste first and verify never.
What attackers actually do with it
Once a hallucinated name is identified — through manual probing of popular coding assistants, or by scraping public hallucination research like the UTSA study — an attacker registers that exact name on PyPI or npm with a working package that does something harmless on the surface and malicious underneath: a credential harvester, a reverse shell dropped on import, a crypto-miner spun up on a background thread. November's incident with Microsoft's own agent-framework PyPI package being hijacked via two poisoned releases — which ran a credential stealer through a Python .pth startup hook and exposed roughly 190,000 monthly downloads before the package was pulled — used a different initial vector (a compromised maintainer account), but it demonstrates the same underlying payload pattern slopsquatting relies on: code that executes automatically at install or import time, before any human reviews it.
The asymmetry favors the attacker badly. Publishing a package to PyPI or npm costs nothing and takes minutes. Each successful install is a developer machine, CI runner, or production container with a backdoor already planted — often with the same permissions as whatever pipeline ran the install command.
What actually reduces the risk
Banning AI coding assistants isn't realistic and isn't the fix — the hallucination rate is a model property, not an assistant-choice problem, and it shows up in chat-based tools too. What does help:
Pin dependencies and commit lockfiles. A package-lock.json, poetry.lock, or requirements.txt with hashes means a newly-suggested package name has to clear an explicit review step before it enters the dependency tree, rather than being silently pulled on the next build.
Treat any AI-suggested new dependency as a diff to review, not a command to run. Before installing, check the package's registry page: publish date, download count, maintainer history. A library that supposedly solves a common problem but was published three weeks ago with zero prior releases is a signal, not a coincidence.
Use a private registry proxy with an allowlist for CI and build systems. Tools like Artifactory, Nexus, or npm's own scoped registries let a team gate which packages can resolve in automated pipelines, closing the highest-value target — CI runners with broad credentials — even if a developer's local machine isn't locked down as tightly.
Run install-time scripts in a sandbox. npm's --ignore-scripts flag and equivalent Python packaging options prevent a malicious package's install hooks from executing arbitrary code the moment it's pulled, which blunts the most common slopsquatting payload mechanism even if the bad package slips through.
The deeper fix is cultural: AI-generated code suggestions, including the dependencies they pull in, need the same scrutiny as a pull request from an unfamiliar contributor — not the trust developers extend to their own typed-out imports. The 2025 research made the scale of hallucinated packages measurable; the Microsoft agent-framework incident made the blast radius concrete. Treat every new package name an assistant suggests as unverified until the registry says otherwise.