Security 8 min read Markdown

Slopsquatting: How AI-Hallucinated Package Names Become a Composer Supply Chain Attack

Code assistants sometimes recommend packages that do not exist. Attackers register those names and wait. Here is how slopsquatting works, why PHP and Composer projects are exposed, and the checks that stop a hallucinated dependency reaching production.

Matt King
Matt King
November 3, 2026
Last updated: November 3, 2026
Slopsquatting: How AI-Hallucinated Package Names Become a Composer Supply Chain Attack

Ask a coding assistant how to do something in Laravel and it will often suggest a package: composer require some-vendor/laravel-something. Usually the package is real. Sometimes it is not. The model has produced a plausible-sounding name that has never existed on Packagist.

That gap is the attack. If a name gets hallucinated often enough, someone can register it, publish code under it, and wait for developers, or their AI agents, to install it. The term slopsquatting (from AI "slop" plus typosquatting) was coined in 2025 by Seth Larson, the Python Software Foundation's security developer-in-residence, and it applies to every package registry, Packagist included.

How often do models invent packages?

A 2024 academic study, We Have a Package for You! (Spracklen et al.), generated 576,000 code samples in Python and JavaScript with 16 code-generating models and checked every package they referenced. About 19.7% of the recommended packages did not exist, adding up to more than 205,000 unique invented names. Open-source models hallucinated far more often than the commercial ones the researchers tested, but none were immune.

The finding that matters most for attackers: hallucinations are repeatable. When the researchers re-ran the same prompts ten times, 43% of the invented names came back every time. An attacker does not need to guess; they can ask the models the same questions developers ask, collect the names that keep appearing, and register them.

The study did not test PHP, but nothing about Packagist makes it safer. Naming in PHP is especially easy for a model to "complete": vendor/laravel- plus a feature name looks right whether or not it exists.

Why it is dangerous in a PHP project

Installing a Composer package is not a passive download. Code from a dependency can run:

  • On every request, through autoload.files entries, which Composer includes as soon as vendor/autoload.php loads.
  • When Laravel boots, through package discovery: a malicious package can register a service provider that runs on every request and every Artisan command.
  • During composer install, if it is a Composer plugin and your allow-plugins setting lets it run. (Composer does not run scripts defined by dependencies, only the root package's, but plugins are code.)

From there it can read .env, exfiltrate your APP_KEY and database credentials, or plant a backdoor. We have covered real examples in malicious Laravel packages on Packagist and PHP supply chain attacks.

Agents make it worse

A human copying composer require from a chat window might notice the package has twelve downloads. An autonomous coding agent with shell access often just runs the command, sees it succeed, and moves on. Agents also retry: if a package is missing, some will search for a similarly named one. Every new dependency an agent adds should go through the same review as a human's.

How to defend against slopsquatting

1. Check a package before you require it. Open its Packagist page. Red flags: created in the last few weeks, a handful of installs, no linked repository or a repository with no history, a vendor name that imitates a well-known one (laravell/, spatie-labs/). If a model recommends a package, confirm it is the one the framework docs or a maintainer you trust point to.

2. Review dependency changes like code. Make composer.json and composer.lock part of every pull request review. A new top-level package name is a decision, not a side effect. Many teams require a second reviewer for any new dependency.

3. Keep allow-plugins explicit. Composer 2.2+ asks before running a plugin. Keep an explicit allowlist in composer.json under config.allow-plugins, and do not answer "yes" to every prompt in CI or let an agent do it.

4. Constrain what agents can do. Give AI agents a rule (in your CLAUDE.md, AGENTS.md or equivalent) that they must not add dependencies without asking, and run them without network access to package registries where you can.

5. Audit continuously. composer audit catches packages with known advisories, which a freshly registered malicious package will not have yet, so it is necessary but not sufficient. Pair it with the checks above. Our guide to composer audit covers running it in CI.

6. Mirror or allowlist for production builds. Larger teams can build from a private Packagist mirror or a Satis repository that only contains approved packages, so a hallucinated name simply fails to resolve.

If you already installed something suspicious

Remove it, then assume the worst for anything it could reach: rotate APP_KEY (see rotating a leaked APP_KEY), database passwords, API keys and any secrets in .env, and check for new files, cron entries and service providers. Then run a free StackShield scan to check your live app for the external symptoms of a compromise, such as exposed .env files, debug mode or unexpected endpoints.

Free security check

Is your Laravel app exposed right now?

34% of Laravel apps we scan have at least one critical issue, and most teams do not find out until something breaks. The free scan checks your live app in 60 seconds. Then StackShield re-runs every check after each deploy, so a fix you ship today does not quietly regress next week.

18% have debug mode on
72% missing security headers
12% have exposed .env
Scan My App Free No signup for the scan. Continuous monitoring on a 14-day trial, no card.

Frequently Asked Questions

What is slopsquatting?

Slopsquatting is a supply chain attack where someone registers a package name that AI coding tools invent ("hallucinate") when suggesting dependencies. Developers or agents who install the suggested package get the attacker's code.

How is slopsquatting different from typosquatting?

Typosquatting relies on humans mistyping a real package name. Slopsquatting relies on AI models confidently recommending a name that never existed, and repeating the same invented name across many users.

Does slopsquatting affect Composer and Packagist?

Yes. Anyone can register a vendor/package name on Packagist, and package code runs inside your app once installed, through autoloaded files, service providers or allowed Composer plugins.

How do I protect a PHP project from slopsquatting?

Check every new package on Packagist before requiring it (age, downloads, linked repository, maintainers), review composer.json and composer.lock changes in pull requests, keep allow-plugins explicit, and do not let AI agents run composer require without review.

Stay Updated on Laravel Security

Get actionable security tips, vulnerability alerts, and best practices for Laravel apps.