Developers now ask an assistant for code, accept its suggestion to install a package, and let an agent run commands in their terminal. Each of those steps is a supply-chain decision, and the assistant makes some of them faster than anyone reviews them. Three pieces of research and incidents from 2025 show where the gaps are.
Packages that do not exist yet
Researchers presenting at USENIX Security 2025 tested 16 code-generating models across 576,000 Python and JavaScript samples. Of the packages the models recommended, 19.7% did not exist, and the study counted 205,474 unique made-up names. The hallucinations were also repeatable: when the same prompt ran ten times, 43% of the invented names came back every time.
That repeatability is what makes it dangerous. An attacker can ask the same kinds of questions, collect the names the models invent, and register them on npm or PyPI with malicious code inside. The industry has started calling this slopsquatting. Commercial models hallucinated far less often than open-source ones on average, but none of the models tested was at zero.
Malware that drives your AI tools
On 26 August 2025, attackers used a stolen npm token to publish malicious versions of Nx, a popular JavaScript build system. Snyk reported that the bad releases were live for roughly five hours. A post-install script looked for Claude Code, Gemini CLI and Amazon Q on the developer’s machine. If it found one, it ran the tool with flags that skip permission prompts, such as --dangerously-skip-permissions and --yolo, and asked it to search the file system for wallets, tokens and keys. The stolen data was pushed to public GitHub repositories named s1ngularity-repository, and researchers counted more than a thousand valid GitHub tokens in the leak.
The malware needed no flaw in the AI tools themselves. It used agents that already had access to the developer’s home directory and ran them in their least restricted mode.
Connectors that change under you
Model Context Protocol (MCP) servers let assistants call tools such as email, ticketing systems or databases. In September 2025, Koi Security found an npm package called postmark-mcp that copied the code of Postmark’s legitimate MCP server and used the same name. Fifteen versions behaved normally. Version 1.0.16 added one line that blind-copied every email sent through it to an outside address. Koi estimated around 1,500 downloads a week. Anyone whose setup pulled the update automatically was leaking invoices, password resets and internal mail with nothing visibly wrong.
This ties back to prompt injection. An agent’s tools are part of its attack surface, and a connector is third-party code running with your agent’s permissions.
What to lock down
- Check every package an assistant suggests before installing it: that it exists, how old it is, who maintains it and how many people download it. A package created last week with a plausible name is a warning sign.
- Use lockfiles and pinned versions, and install in CI with
npm ci. Consider turning off install scripts by default withnpm config set ignore-scripts trueand allowing them only for packages that need them. - Put a dependency scanner or package firewall in front of your registry so newly published or flagged packages are blocked until reviewed.
- Never run coding agents in permission-skipping modes on a machine that holds production credentials. Use a container or development VM that holds only the secrets that project needs.
- Treat MCP servers like any other dependency. Install them from the vendor’s official source, pin versions, review changes before upgrading, and give each server the narrowest token that works.
- Keep long-lived tokens off developer laptops. Short-lived credentials from your cloud provider or a secrets manager limit what any stolen file is worth.
Sources
- USENIX Security 2025: We Have a Package for You! A Comprehensive Analysis of Package Hallucinations by Code Generating LLMs
- Snyk: Weaponizing AI coding agents for malware in the Nx malicious package
- The Hacker News: First malicious MCP server found stealing emails
- The Register: Postmark MCP server code hijacked