Slopsquatting is registering a package name that AI models invent, so that anyone who pip installs it runs the attacker's code. The term was coined by Seth Larson, the Python Software Foundation's Security Developer-in-Residence: "slop" for low-quality AI output, "squatting" from typosquatting.

The best-known Python case is huggingface-cli. The real Hugging Face CLI is installed with pip install -U "huggingface_hub[cli]"; huggingface-cli was a name AI models kept suggesting. Bar Lanyado of Lasso Security registered an empty package under that name to see what would happen, and published the results in March 2024. Lasso reported more than 30,000 authentic downloads in three months (The Register, earlier in the experiment, reported over 15,000), and an Alibaba research repository, GraphTranslator, had put pip install huggingface-cli in its README (Lasso Security, The Register).

That name is free again today. This is what Skylos's pre-install hook answered when we fed it pip install huggingface-cli on 10 Oct 2026:

{"hookSpecificOutput": {"hookEventName": "PreToolUse", "permissionDecision": "deny", "permissionDecisionReason": "Skylos blocked this install: 1 package looks hallucinated or typosquatted.\n- PyPI package 'huggingface-cli' does not exist on PyPI (likely hallucinated; an attacker can register it).\nCheck the real package name (docs, registry search) and retry. If the package is internal, install it with your private index/registry flag so Skylos skips the public-registry check. If this package is correct, add it to [tool.skylos] hooks_allow_packages in pyproject.toml."}}

Typosquatting vs slopsquatting

TyposquattingSlopsquatting
Attacker needsA popular package with a typo-prone nameA name AI models hallucinate
Who "types" the bad nameA developerAn AI assistant or coding agent
What gives it awayAn odd spelling in the diffOften nothing; the name looks plausible
Why it repeatsHuman errorModels repeat the same invented names

The data: Spracklen et al., USENIX Security 2025

The main empirical study is "We Have a Package for You! A Comprehensive Analysis of Package Hallucinations by Code Generating LLMs" by Joseph Spracklen, Raveen Wijewickrama, A H M Nazmus Sakib, Anindya Maiti, Bimal Viswanath and Murtuza Jadliwala (USENIX Security 2025).

  • 16 models, commercial and open-source
  • 576,000 generated Python and JavaScript code samples
  • 2.23 million package references, of which 440,445 (19.7%) were hallucinated
  • 205,474 unique hallucinated names
  • 15.8% of Python package references hallucinated, 21.3% of JavaScript
  • about 5.2% on average for commercial models, 21.7% for open-source models

The denominator matters. These are hallucinated package references divided by all package references the researchers extracted, under their prompts and models. It doesn't mean 15.8% of AI-written Python files import a fake package.

Why repeatability matters

If every hallucination were a fresh random name, registering them would be a lottery. The paper's repeat test (the same prompts re-run 10 times) found otherwise: 43% of hallucinated names came back in all 10 runs, and 58% came back more than once (Socket's summary reports the same split). An attacker can run popular prompts, collect the names that keep coming back, and register those.

Which models hallucinated most

Model or groupMetricRate
GPT-4 TurboPython package references, lowest in the study3.59%
Commercial modelsAverage, from the abstract5.2%
CodeLlama 34BPython package references21.15%
Open-source modelsAverage, from the abstract21.7%

The lineup is the one available for the 2024/2025 study (GPT-4 Turbo, CodeLlama, DeepSeek-Coder, WizardCoder, Mistral and others), not today's frontier models. Treat it as a published baseline, not a live leaderboard.

Why Python is exposed

PyPI names are flat. PyPI project names are global under PEP 541; there is no organisation scope like npm's @huggingface/cli reserving a prefix for one publisher. An unregistered hallucinated name is available to anyone, subject to PyPI policy.

Install runs code. A source distribution's build step runs code at pip install time, and a .pth file in a package can run code every time Python starts. The package doesn't need to be imported to do damage.

AI work happens in Python. LLM, data and agent libraries (langchain, llama-index, transformers and others) change module layouts between releases, which gives models plenty of plausible-but-wrong names and paths to suggest.

Three kinds of wrong import

The package doesn't exist. Both names below were absent from PyPI when Skylos looked them up on 10 Oct 2026:

from cryptoutils import secure_hash
from flask_secured import require

The package exists, the path is stale. The model remembers an older layout:

from langchain.chat_models import ChatAnthropic
# Pre-0.1 location. Integrations moved to partner packages, e.g.:
#     from langchain_anthropic import ChatAnthropic
# Whether the old path still imports depends on your installed versions.

The import name and the distribution name differ. import yaml comes from PyYAML, import cv2 from opencv-python, import sklearn from scikit-learn. If your dependency files declare neither, the import fails at runtime however obvious it looks, and someone "fixing" it by guessing a name can install the wrong package.

Catch it before install, and before merge

Install-time tools run too late or look for something else:

  • pip-audit (PyPA) checks packages against known-vulnerability advisories. A freshly registered hallucinated package has none.
  • Lockfiles (uv.lock, poetry.lock, hash-pinned requirements) pin what you already installed. If someone ran pip install cryptoutils to make an import work, the lockfile now records that decision.
  • Trusted Publishing (PyPI docs) protects how packages you already trust get published. It says nothing about whether cryptoutils should be on your list at all.

Two checks do catch it.

Before the install runs, if an AI agent is running it: skylos agent install-hooks (Claude Code; --codex for Codex, --cursor for Cursor) adds a hook that runs before pip, uv, poetry, npm, pnpm, yarn, bun and go installs and denies names that don't exist or are one-edit look-alikes of popular packages, as in the huggingface-cli output above. It fails open: if Skylos can't run, the agent continues and is told the install wasn't checked. How the hooks work.

Before merge, for imports already in the code:

pip install skylos
skylos . --select SKY-D222,SKY-D223 --strict

On a test fixture with the two imports above and dependencies = ["requests==2.32.3"], it printed (in --format concise) and exited 1:

app/client.py:3  SKY-D222  Hallucinated dependency 'cryptoutils'. Package does not exist on PyPI.
app/client.py:4  SKY-D222  Hallucinated dependency 'flask_secured'. Package does not exist on PyPI.
app/client.py:2  SKY-D223  Undeclared import 'yaml' (provided by: pyyaml). Add to requirements.txt/pyproject.toml/setup.py.

Select both rules. SKY-D222 needs proof that none of your declared dependencies ships a module with that name; with unpinned or range dependencies, Skylos reported the same made-up imports as SKY-D223 "Unverified import ... No PyPI project has this name". And once an attacker registers a hallucinated name, PyPI says it exists and SKY-D222 stops firing; SKY-D223 still fires while the package is missing from your dependency files. Neither rule checks a stale submodule path like langchain.chat_models. More detail, including npm: Detect hallucinated packages in AI-generated code.

A workflow you can drop in

name: skylos scan
on: [pull_request]

permissions:
  contents: read

jobs:
  scan:
    name: Block hallucinated packages
    runs-on: ubuntu-latest
    timeout-minutes: 10
    steps:
      - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
        with:
          persist-credentials: false
      - uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
        with:
          python-version: '3.12'
      - run: python -I -m pip install "skylos==5.1.1"
      - run: skylos . --select SKY-D222,SKY-D223 --strict

--strict makes any selected finding fail the job. --gate alone does not: in our test it passed with three critical SKY-D222 findings unless max_ai_defects = 0 was set under [tool.skylos.gate].

Pair it with a lockfile, so that any pip install someone runs to "fix" a failing import also goes through code review.

What an existence check cannot tell you

Both checks above ask one question: does this name exist on the registry? That stops a hallucinated name while nobody has registered it. It says nothing once somebody has, and registering it is the whole attack.

So when a tool tells you an import is "undeclared" and the package exists, do not add it to your dependency files on that alone. Open its page on PyPI first and look at three things an uploader cannot fake:

  • When it was first published. A project that appeared days or weeks ago has no track record.
  • How many releases it has. One or two releases on a young project is the usual shape of a placeholder.
  • Who publishes it. Check the account, and whether the name matches what the documentation of the library you wanted tells you to install. fitz is the well-known example: PyMuPDF is imported as fitz, but the package to install is PyMuPDF.

Links, descriptions and author names on the page are written by the uploader, so they are not evidence on their own. The install hook's release cooldown (48 hours by default) holds a brand-new version, but a name registered a month ago is past it.

Bottom line

  • Models hallucinate package names: 19.7% of package references in Spracklen et al.'s study, 15.8% for Python (paper).
  • Many hallucinations repeat (43% in all 10 runs), which is what makes registering them worthwhile.
  • It has worked in practice: Lasso's empty huggingface-cli placeholder drew more than 30,000 authentic downloads in three months.
  • PyPI's flat namespace leaves unregistered hallucinated names available to anyone.
  • Vulnerability scanners and lockfiles don't catch a nonexistent or newly registered name. A pre-install check and an import check against your declared dependencies catch the nonexistent ones.
  • A name that has been registered passes every existence check. Before you declare a package you have not used before, check when it was first published, how many releases it has and who publishes it.

(Disclosure: we build Skylos. The Spracklen, Lasso and Socket findings cited above are independent third-party research.)

Sources