AI Coding Assistants & Slopsquatting
AI coding assistants now write a large share of new code. Some only suggest the next line. Others are agents that read the whole repository, edit many files, install packages and run commands in a terminal. They make developers faster, and they create a new class of supply-chain and workstation risk.
You will learn: the security problems that AI-generated code introduces, how attackers exploit hallucinated package names (slopsquatting), how a repository or rules file can hijack a coding agent, and a practical policy for using these tools safely. Allow about 30 minutes. You should know basic secure code review and LLM supply chain attacks.
Problem 1: insecure suggestions
A coding model learns from public code, and public code contains plenty of bugs. When asked to write a database query, it may concatenate strings. When asked for file uploads, it may skip type checks. It writes what is common, not what is safe.
Studies have measured this. A 2021 study of an early code assistant ("Asleep at the Keyboard?") generated programs for scenarios related to common weakness types and found roughly 40% of them vulnerable. Models have improved since then, but the pattern holds: AI-generated code needs the same review and testing as human code, and developers tend to trust confident, neatly formatted code more than they should.
Common issues to look for:
- SQL, command or template injection from string building
- Missing authorisation checks on new endpoints
- Hard-coded secrets and placeholder credentials left in
- Weak cryptography (MD5 for passwords, fixed IVs,
randominstead ofsecrets) - Disabled TLS verification "to make it work"
- Outdated library versions and deprecated APIs
Problem 2: hallucinated packages and slopsquatting
Ask a model how to do something unusual, and it may recommend a package that does not exist. The name sounds right (flask-jwt-securelogin, pandas-validator-pro), but nobody ever published it.
That creates an opportunity. If models hallucinate the same names repeatedly, an attacker can register those names on PyPI or npm with malicious code inside. The next developer who copies the assistant's pip install command installs malware. This is called slopsquatting, a term coined by Python Software Foundation security developer Seth Larson, by analogy with typosquatting.
A 2024 study ("We Have a Package for You!") tested 16 code-generating models on hundreds of thousands of code samples. Around one in five recommended packages did not exist, open models hallucinated far more than commercial ones, and many hallucinated names came up again and again across runs, which is exactly what makes them worth registering.
Developer: "How do I validate IBANs in Python?"
Assistant: "Install iban-validator-plus: pip install iban-validator-plus"
Reality check before installing:
- Does the package exist? (search the registry, not the assistant)
- When was it first published? (a few days ago = red flag)
- How many downloads, maintainers? (one maintainer, no history = red flag)
- Does a well-known alternative exist?
Problem 3: the repository talks to the agent
Coding agents read files to understand the project. That includes untrusted files: a README in a dependency, an issue description, a code comment, a downloaded log. All of it can carry prompt injection.
Agents also read instruction files that projects use to configure them, such as rules files telling the assistant about coding style. In 2025, security researchers described a "rules file backdoor": instructions hidden in these files with invisible Unicode characters, steering the assistant to quietly insert malicious code into what it generated. A human reviewing the rules file in an editor saw nothing unusual.
Also in 2025, a malicious contribution got into a release of an official AI coding extension: it added a prompt instructing the agent to delete files and cloud resources. The vendor withdrew the version quickly. It was a reminder that the agent's own instructions and plug-ins are part of your supply chain.
When an agent can run terminal commands, these injections stop being "bad suggestions" and become code execution on the developer's machine, which usually holds source code, SSH keys, cloud credentials and production access.
Many coding agents offer modes that run commands without asking. Combined with prompt injection from any file the agent reads, that means anyone who can get text into your repository, dependencies or issue tracker can run commands as you. Keep approval on for commands, or run the agent inside a disposable container.
A practical policy for teams
Review AI code like any other code. Same pull-request review, same tests, same static analysis (SAST) and secret scanning in CI. The author being an AI is not a reason to skip anything, nor to review less.
Verify every new dependency. Check that it exists, who publishes it, how old it is and how widely it is used before adding it. Use lockfiles and, where you can, a private registry or allowlist that only serves vetted packages. Tools that score package reputation help.
Contain the agent. Run agents that execute commands in a container or devcontainer without your personal credentials. Give them only the tokens the task needs, with short lifetimes. Don't mount your home directory.
Keep command approval on. Allowlist harmless commands (run tests, lint) if prompts get tiresome, but require approval for anything that installs, deletes, pushes or calls the network.
Treat agent configuration as code. Rules files, MCP server lists and extension settings go through review. Scan them for hidden Unicode characters. Pin extension and MCP server versions.
Don't paste secrets. Keep .env files and credentials out of what the assistant can read, and use the tool's ignore settings for sensitive paths.
Two browser tools help with these checks: the Package Lookalike Checker flags typosquats and hallucination-style names, and the Hidden Instruction Scanner reveals invisible characters and hidden text in rules files and documents.
# Spot invisible characters in agent instruction files before trusting them
grep -nP '[\x{200B}-\x{200F}\x{202A}-\x{202E}\x{2060}-\x{2064}\x{FEFF}]' .cursorrules AGENTS.md CLAUDE.md 2>/dev/null \
&& echo "hidden characters found: review before use"
An assistant suggests `npm install react-secure-forms-kit`. The package exists and was published nine days ago by a brand-new account. What do you do?
Treat it as suspicious. A very new package from a new account matching a plausible hallucinated name is the slopsquatting pattern. Look for an established alternative, read the package source if you must evaluate it, and do not install it on a machine with credentials.Why is a coding agent that reads GitHub issues and can run shell commands a serious risk even if every developer on the team is trustworthy?
Anyone who can open an issue can write text the agent reads. A prompt injection there can make the agent run commands with the developer's access. The trust boundary includes everyone who can write content the agent will read.Key terms
- Coding agent — an AI assistant that can read a codebase, edit files and run commands, not just suggest code
- Package hallucination — an AI model recommending a software package that does not exist
- Slopsquatting — registering a package name that AI models tend to hallucinate, so developers who follow the suggestion install malicious code
- Rules file — a project file that gives an AI coding assistant standing instructions, such as style or conventions
- Devcontainer — a container-based development environment, useful for isolating a coding agent from the developer's real machine
Recap
AI coding assistants reproduce common insecure patterns, invent package names attackers can register, and read untrusted text that can steer them. Review AI-written code like any other, verify every new dependency, keep command approval on, run agents in containers without personal credentials, and review agent configuration files as code, including for hidden characters.
???refs
- Spracklen et al., We Have a Package for You! (2024) — the large study of package hallucinations in code-generating models
- Pearce et al., Asleep at the Keyboard? (2021) — an early measurement of vulnerable code from an AI assistant
- OWASP Top 10 for LLM Applications — supply chain and excessive agency risks that apply to coding agents
- OpenSSF: Security-Focused Guide for AI Code Assistant Instructions — guidance from the Open Source Security Foundation's best-practices group
- SLSA — a framework for software supply-chain integrity that covers dependencies AI suggests