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.
Don't existing dependency scanners catch this?
Most dependency scanners inspect packages once they are installed or listed in your lockfile.
A package name that has never been published has no code and no advisory to inspect, and
never reaches the lockfile. ghostimport checks the name itself, before the install.
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.