# Slopsquatting

> The Slopsquatting is an attack where malicious packages are published under names that AI models tend to hallucinate.

## What is slopsquatting in AI-generated code?

The supply chain attack where attackers register packages with names that models often invent when generating code. A developer or agent that installs a suggested package without checking may install malware.

- Topic: Security & Ethics
- Type: cyberattack

## Example

Wrong:

```bash
npm install react-form-validator-pro
```

Right:

```bash
npm view react-form-validator-pro name repository.url time.created
# Check the repo, downloads and docs first, then install
npm install --save-exact react-hook-form
```

Looking up a suggested package before installing it catches names that do not exist or were registered recently by an attacker.

## Common mistakes

- Running an install command the AI wrote without checking the package exists.

## Key points

- Every package the AI adds exists in the official registry and is the intended, well-known project.
- New dependencies are pinned in the lock file and installed with `npm ci` in CI.
- The package name matches the official docs exactly, with no lookalike spelling.

## Interview questions

### Why do AI models invent package names?

Models generate likely-sounding names from patterns, so they sometimes suggest packages that do not exist. Attackers register those names.

### How is slopsquatting different from typosquatting?

Typosquatting relies on people mistyping a real name. Slopsquatting relies on AI models suggesting a name that was never real.

### How can I check if a package is legitimate?

Confirm it in the official docs, check the registry page for the source repository, maintainers, download counts and creation date.

## Related cards

- [Hallucination](https://wonderium.dev/ai/hallucination.md)
- [Lock file](https://wonderium.dev/processes/lock-file.md)
- [npm audit](https://wonderium.dev/processes/npm-audit.md)
- [`npm install <package>`](https://wonderium.dev/processes/npm-install.md)
- [Vibe Coding](https://wonderium.dev/ai/vibe-coding.md)

---

- Level: [Artificial Intelligence](https://wonderium.dev/ai.md)
- HTML version: https://wonderium.dev/ai/slopsquatting
- Last updated: 2026-11-25
