What is slopsquatting?
Slopsquatting is when an attacker registers an npm package name that an AI coding tool
invented. Language models routinely generate imports for packages that were never
published. Those names sit unclaimed in public repositories, so an attacker can publish
them and have their code run on any machine that installs the dependency.
Does npm audit catch hallucinated packages?
No. npm audit, Snyk and Socket inspect packages that are already installed and present in
your lockfile. A package name that doesn't exist yet never reaches the lockfile, so it
falls outside what those tools examine.
How is slopsquatting different from typosquatting?
Typosquatting relies on a human mistyping a real package name. Slopsquatting relies on a
model inventing a name that was never real, then an attacker registering it. Typosquatting
needs a plausible misspelling; slopsquatting needs only an unclaimed name a model is
likely to produce again.
Is an import of a package that doesn't exist actually dangerous?
Not while the name stays unregistered — the install simply fails. The risk is that
registration is free and instant. Once someone claims the name, that same install
succeeds, and any postinstall script in the package executes on your machine
and in your CI.
How do I stop my AI agent from installing a package that doesn't exist?
Run ghostimport as an agent hook. A PreToolUse hook
on Bash inspects any install command and denies the tool call when a package doesn't
exist, is a typosquat, or ships an install script. Unlike an MCP tool, a hook runs whether
or not the model chooses to call it.