Safety, Security & Responsible AI·Question 14 of 70Basic

What is slopsquatting, and how do you stop a coding agent from installing a package that does not exist?

Type it the way you would explain it to an interviewer. A few sentences is enough; you can't break anything.

Model answer: the part to lead with

Slopsquatting is a supply-chain attack built on package hallucination. A code model confidently imports or installs a dependency that does not exist, and an attacker registers that name on PyPI or npm with a malicious payload. It is typosquatting without the typo: no human misspelt anything, the model invented the name.

Full worked answer

Slopsquatting is a supply-chain attack built on package hallucination. A code model confidently imports or installs a dependency that does not exist, and an attacker registers that name on PyPI or npm with a malicious payload. It is typosquatting without the typo: no human misspelt anything, the model invented the name.

Two properties make it practical rather than theoretical. First, studies of generated code have found that a meaningful share of suggested packages do not exist, and that many invented names recur across runs and prompts, so an attacker can harvest likely names by prompting models and pre-register them. Second, install is execution: setup.py, build hooks and npm postinstall scripts run at install time, so an agent with shell access is compromised before any code review happens. A human might pause at an unfamiliar package. An agent running pip install in a loop will not.

Defences, in order of leverage:

  • No direct path to the public registry. The agent installs through an internal mirror or proxy that serves an approved set. A new dependency becomes a request, not a command.
  • Existence and reputation checks before install. Package age, download history, maintainer history and a linked source repository. Block anything published in the last few weeks by default, because squatted names are new.
  • Lockfiles and hashes. npm ci, pip install --require-hashes, and lockfile changes flagged in review. Disable install scripts where the ecosystem allows it.
  • Install inside the sandbox. No credentials, egress only to the mirror, so a malicious install script has nothing to steal and nowhere to send it.
  • Review the dependency diff. Any agent-authored change that adds a dependency needs a human to approve that line specifically.

Lower temperature and an instruction to "only use well-known packages" reduce the rate but do not close the hole. The control has to sit between the model's decision and the package manager, because that is the one point the attacker cannot talk their way past.

What a good answer covers

  • Slopsquatting is a supply-chain attack built on package hallucination
  • A code model confidently imports or installs a dependency that does not exist, and an attacker registers…
  • It is typosquatting without the typo: no human misspelt anything, the model invented the name
  • Two properties make it practical rather than theoretical
  • First, studies of generated code have found that a meaningful share of suggested packages do not exist,…

Key terms: Lockfiles and hashes · Install inside the sandbox · Review the dependency diff

Interviewer follow-ups to expect

  1. How would you find out, after the fact, whether an agent-authored change pulled in a squatted package?

  2. The same hallucination problem applies to container images and API endpoints: which parts of the package defence carry over?

Worked answer from AI-Engineer-Interview-Questions by Om (MIT), reformatted for LLM Prep · answer text last updated 6 November 2026 · scoring and review schedule by LLM Prep