Tech AI News - 테카이

12. Slopsquatting — Why You Shouldn't Blindly Install a Package an AI Suggests

· 5 min read

This post was translated from the Korean original by AI.한국어 원문 읽기 →

If you're in the habit of copying a package name an AI coding tool recommended straight into an install command, you're running code without ever checking whether that name is a real package. The name itself may have been invented by the AI, and an attacker may have already registered it in a public registry and planted malware inside it.


Background — why this term matters now

AI coding tools like GitHub Copilot, Cursor, and Claude Code suggest the libraries (packages) you need as they write code. The problem is that some of these suggestions are packages that don't actually exist. Large language models (LLMs) generate names based purely on statistical plausibility — "a package with a name like this probably exists" — and this is called package hallucination.

Take this one step further and you get slopsquatting. It's a supply-chain attack where attackers find the fake names AI repeatedly invents, register real packages under those names, and plant malicious code in the scripts that run on install. The term was coined by Seth Larson, a security developer at the Python Software Foundation (PSF), who noted its structural similarity to traditional typosquatting, which preys on human typos. Here, though, the attacker waits for an AI's mistake rather than a human's. A study published in March 2025 put numbers behind the phenomenon and the security industry began taking it seriously, and by 2026 real-world exploitation cases have started being reported one after another.

Key data & current state

ItemFigureSource / date
Package hallucination rate (16 models, 576,000 code samples)19.7% overall; open-source models averaged 21.7%, commercial models averaged 5.2%USENIX Security 2025, Spracklen et al.
Reproducibility of hallucinated namesAcross 10 reruns of the same prompt, 43% repeated the exact same name every time, 58% repeated two or more timesSame study
Real damage — unused-imports (npm)Kept getting roughly 233 downloads per week even after npm's security holdCSA research note, as of 2026.02
Real damage — huggingface-cliDiscovered by security researcher Bar Lanyado. Alibaba cited it in public documentation without verification, racking up over 30,000 downloads in three monthsCSA research note, 2026.04
Real damage — react-codeshift (npm)Discovered by security researcher Charlie Eriksen. Spread to 237 repositories through an "agent skill" AI agents generated and sharedCSA research note, 2026.04

Interpretation: open-source models hallucinate more, but commercial models still show errors around 5%. What matters more is repeatability. Repeating the same question keeps producing similar fake names, so an attacker only needs to ask a handful of questions to pick a name worth registering. All three real-world cases above exploited exactly this predictability.

Deep dive

1) What exactly is slopsquatting

Slopsquatting happens in two steps. First, an AI coding tool plausibly invents a package name that doesn't actually exist (package hallucination). Second, an attacker registers that name first on a public registry like npm or PyPI and puts malicious code in the install script (squatting). If a developer or an AI agent installs that name as-is, tokens such as cloud keys or Git credentials stored in environment variables can be exfiltrated, or the malicious code can spread through build artifacts and lockfiles across an entire CI/CD pipeline.

2) Common misconceptions — why people read it this way

The most common misconception is thinking "since an AI suggested this name, it must be somewhat verified." In reality, an LLM has no way to check whether a package actually exists — it simply combines patterns it saw often in training data to generate a name. A second misconception is that typo checks or name-similarity checks would catch this. Since it's not a human typo but a name the AI invented from scratch, spell-checking won't catch it. Research shows that about 38% of hallucinated package names are "composites" blended from the names of two real packages, which is exactly why they look plausible even to a human.

3) How to actually judge a package

Before installing a package an AI suggests, you need to check: whether that name actually exists on a registry (npmjs.com, pypi.org), how long ago it was registered, and whether the download count and maintainer history look natural. Be suspicious of a package that was registered recently or has an abnormally low download count while claiming to offer well-known functionality. Cross-checking against the install command in official documentation or a GitHub repository is also basic hygiene. As the huggingface-cli case shows, even documentation written by a trustworthy source may have copied an AI-generated command without verifying it.

4) Why AI agents are riskier than humans here

A human developer who sees an unfamiliar package name will often search for it once, but an AI agent that autonomously writes code and immediately runs npm install or pip install trusts and installs a package the moment it sees the name sitting in a registry. The react-codeshift case wasn't a human copying and installing it directly — it spread to 237 repositories because other agents ran an "agent skill" an AI had created and shared, exactly as written. The more a pipeline is automated with no human review step at all, the bigger this risk gets.

In practice — 5 rules to avoid slopsquatting

  1. Before installing a package name an AI suggests, directly check the registry for whether it exists, when it was registered, its download count, and its maintainer history.
  2. Be especially suspicious of packages registered within the last 30–90 days, and where possible, run automated verification with a software composition analysis (SCA) tool before install.
  3. When giving an AI agent permission to install packages, restrict it to an allowlist and require human approval for any new dependency not already on the list.
  4. Keep the lockfile under version control and check it against known-good hashes in the CI/CD pipeline.
  5. Even an install command written in official documentation or a tutorial may have been copied straight from AI-generated content — double-check it against the registry as well.

References

  • #ai
  • #security
  • #slopsquatting
  • #supply-chain-attack
  • #ai-coding-tools
  • #npm