“Slopsquatting” is a supply-chain attack on AI-assisted coding. Large language models sometimes recommend software packages that do not exist; attackers register those made-up names on npm or PyPI and fill them with malware, waiting for a developer or coding agent to install them. Research published in 2025 found that roughly one in five package suggestions from the models tested were hallucinated, and many of the fake names repeated across runs. Defend with lockfiles, a private registry or allow-list, automatic checks on package age and reputation, and strict limits on what coding agents can install.
Developers increasingly let AI assistants write the import line and the pip install command. Usually that saves time. Sometimes the assistant confidently names a library that has never existed. If an attacker has registered that name first, the next command installs their code on a developer laptop or, worse, in a CI pipeline with access to production secrets.
Where the name comes from
The term slopsquatting was coined by Seth Larson, security developer-in-residence at the Python Software Foundation, as a play on typosquatting (registering misspellings of popular packages) and “AI slop”. The difference is that typosquatting waits for a human typo; slopsquatting waits for a machine’s confident invention.
How big is the problem?
An academic study presented at USENIX Security 2025 (“We Have a Package for You!”, Spracklen et al.) generated over half a million Python and JavaScript code samples with 16 popular code-generating models and checked every package they referenced. Key findings:
- About 20% of recommended packages did not exist, more than 200,000 unique invented names in total.
- Open-source models hallucinated far more often than the leading commercial models, but none were at zero.
- Hallucinations were repeatable: a large share of invented names came back every time the same prompt was rerun. That predictability is what makes the attack practical, because an attacker can harvest likely names in advance.
- Many invented names were plausible (“sounds right” combinations of real library names), so they are hard to spot by eye.
The risk is not only theoretical. In 2024 a researcher at Lasso Security noticed that AI models kept recommending a non-existent Python package called huggingface-cli. He uploaded an empty placeholder under that name as an experiment; it was downloaded tens of thousands of times in three months, and installation instructions for it even appeared in a large company’s public repository.
Why AI coding agents raise the stakes
With autocomplete, a human still reads and runs the install command. Agentic coding tools can now resolve dependencies, run npm install and execute tests on their own. That means:
- the hallucinated package may be installed without a human ever seeing its name;
- npm
postinstallscripts and Python build hooks run code at install time, before any test or review; - agents often run with the developer’s credentials, cloud CLI sessions and SSH keys available.
Defences for development teams
1. Lock what you install
- Commit lockfiles (
package-lock.json,pnpm-lock.yaml,poetry.lock,uv.lock) and usenpm ciorpip install --require-hashes -r requirements.txtin CI, so builds only install what was reviewed. - Treat any change to a lockfile in a pull request as something a human reviews, line by line for new packages.
2. Put a registry proxy in front of the internet
Route npm and PyPI through an internal proxy (Artifactory, Nexus, GitHub Packages, Google Artifact Registry, or similar). Configure it to block packages that are newly published (for example, younger than 14–30 days), have very few downloads, or are not on an approved list for production builds. Most slopsquatted packages are brand new.
3. Check reputation automatically
- Use a dependency-scanning tool that flags new, unpopular, or install-script-carrying packages in pull requests (several open-source and commercial supply-chain scanners do this).
- Disable install scripts by default where you can (
npm config set ignore-scripts true, enabling them only for known packages that need them).
4. Constrain AI coding agents
- Run agents in a container or VM with no production credentials and limited network egress, ideally only to your internal registry proxy.
- Require human approval before an agent adds a new dependency; many tools have an allow-list or “ask before running commands” setting.
- Add a project instruction file (for example, in the repo’s agent guidelines) listing the approved libraries for common tasks, which also reduces hallucination.
5. Verify before you install
A ten-second habit catches most cases: before installing an unfamiliar package an assistant suggested, open its registry page and check the publish date, download count, maintainer and linked source repository. A package published last week with no repository and a name that “should” exist is a red flag.
Detection
- Alert when a CI job installs a package that is not already in the lockfile.
- Monitor build runners and developer machines for unexpected outbound connections during install steps.
- Periodically diff your dependency inventory (SBOM) against a known-good baseline; new packages with very low global download counts deserve a look.
For Indian organisations
Indian software and fintech teams have adopted AI coding assistants quickly, and many ship to regulated customers such as banks and insurers. SEBI’s Cybersecurity and Cyber Resilience Framework (CSCRF) and RBI’s IT outsourcing directions both expect software supply-chain controls and an inventory of third-party components. A registry proxy plus lockfile review gives you a clear, auditable answer when a client asks how you control AI-introduced dependencies.
RingSafe reviews CI/CD pipelines and AI-assisted development workflows for supply-chain risk. Get in touch.
Get a free attack-surface review
We check what an attacker would see about your business — leaked credentials, exposed services, dark-web mentions. 30 minutes, no obligation.