Part 3: Trust & security · Chapter 3 of 6
Poisoned ingredients: the AI supply chain
Invented package names, model files that run code, poisoned training data, and what signing can and can't promise.
After this chapter you can
- Explain how an invented package name becomes an attack
- Say why a downloaded model file should be treated like a program
- Describe how training data and AI tools themselves can be tampered with
The previous chapters covered attacks that reach the model while it’s working. Other attacks happen earlier, in the ingredients: the code the AI told you to install, the model file you downloaded, the text the model was trained on, or the AI tool itself.
Packages that never existed
Ask a chatbot how to set something up and it will often give you an install command. Sometimes the package it names doesn’t exist. A USENIX Security 2025 study of 576,000 code samples from 16 models found at least 5.2% of suggested packages from commercial models and 21.7% from open-source models did not existNov 2026. On its own that’s an annoyance: the install fails and you move on.
It becomes an attack because the inventions are predictable. 43% of invented package names came back every time the same prompt was rerun ten times, which makes registering them a practical attackNov 2026. If a model keeps suggesting the same fake name, someone can register it and wait. This is called slopsquatting, a cousin of typosquatting. The early proof was harmless: a researcher registered huggingface-cli, a package name ChatGPT kept inventing, and saw more than 15,000 real downloads in three monthssource. Now the invented commands are spreading through the instruction files that coding agents read, where an agent may run them without a human ever seeing the line.
Try it: install roulette
A chatbot's answer to "how do I set this up?" suggests:
A staged scenario modelled on real cases (huggingface-cli, react-codeshift). Registry details are illustrative.
Model files that run code
A downloaded AI model sounds like data: a big file of numbers. Often it isn’t. The most common format in the PyTorch world, pickle, can carry instructions that run the moment you load it. JFrog found about 100 malicious models on Hugging Face in 2024, one of which opened a remote shell the moment it was loadedsource.
Platforms scan for this, but scanners look for known-bad patterns, and attackers test against them. The real fix is a format with nothing to execute: safetensors stores only numbers and a header.
Poisoning the well
The deepest ingredient is the training data. Models learn from huge scrapes of the web, and anyone can write to the web. Data poisoning plants text designed to teach a model something its makers didn’t intend, such as a hidden trigger that changes its behaviour, a backdoor.
Earlier work measured poisoning as a share of the training data, but the absolute number of documents turned out to matter: Anthropic, the UK AI Security Institute and the Alan Turing Institute found that about 250 poisoned documents planted a backdoor in models from 600M to 13B parameters regardless of training-data size; the backdoor was narrowNov 2026, a trigger that made the model produce gibberish. Getting text into a web-scale dataset is cheap, and once a backdoor is in, it can be hard to train out.
Where experts disagree checked Nov 2026
How worried should we be about poisoned training data in frontier models?
Anyone can publish text on the web, and the web is what models learn from.
Practical and cheap
Nicholas Carlini and colleagues; Souly and colleagues (Anthropic, UK AISI, Alan Turing Institute)
- Poisoning 0.01% of a web-scale dataset could cost about $60.
- About 250 documents planted a backdoor regardless of model size, so attackers need a fixed number of pages, not a share of the web.
Real, but narrower than the headlines
The same research team's own caveats
- The demonstrated backdoor was a narrow trigger that produced gibberish; more harmful behaviours have been harder to implant.
- Attackers must survive data filtering and post-training, so curation and evaluation are the right investment.
- The Sleeper Agents work points the other way: once a backdoor is in, today's safety training may not remove it.
Sources: anthropic.com · arxiv.org
What would settle it: Poisoning experiments on frontier-scale models with harmful target behaviours, run against realistic data curation.
The tools themselves
Finally, AI tools are software with their own supply chains, and attackers have noticed. In March 2026 the popular AI gateway LiteLLM briefly shipped credential-stealing versions on PyPI; LiteLLM and Snyk trace it to a poisoned Trivy security scanner in its CI pipeline, which leaked the PyPI publishing tokenNov 2026. An AI gateway like that holds the keys to every model a company uses, and often cloud credentials too.
Engineer depthHardening the AI supply chain
Treat everything an AI system pulls in, whether packages, models, data or tools, as code from a stranger until you have reason to trust it.
Packages. Route installs, including the ones agents run, through a proxy or allowlist that blocks brand-new and low-reputation packages. Review agent “skills”, rules and settings files like code. They are instructions an agent will follow, and some run commands on their own: the "Mini Shai-Hulud" package worm of spring 2026 wrote a start-up hook into a project's Claude Code settings file and a run-on-open task for VS Code, so that opening the project ran the malware againsource. Pin and hash dependencies, and prefer trusted publishing (OIDC) over long-lived registry tokens. The Amazon Q extension incident (July 2025, CVE-2025-8217) started with an over-broad GitHub token in build configuration; the Nx compromise from the last chapter started with a CI workflow.
Models. Standardise on file formats that can’t execute code. Update PyTorch to 2.6 or later (CVE-2025-32434 broke weights_only=True). Load unknown models only in isolated sandboxes without network access. Prefer known publishers, but remember that a publisher’s account can be taken over.
Provenance. The OpenSSF model-signing standard (v1.0, April 2025) signs model files with Sigstore, and US and allied agencies recommend signatures and provenance tracking for AI dataNov 2026. Sign the models you produce, verify signatures when you take models in, and keep provenance records for datasets. Be clear about what a signature gives you: proof of who published a file and that nobody changed it afterwards. It says nothing about whether the training data was clean.
Poisoning defence happens mostly before training: curating and deduplicating data, watching sources that change hands (expired domains, for example), and running evaluations after training that look for trigger behaviour. If you fine-tune on scraped or user-submitted data, you inherit this problem directly.
Crown jewels. Treat AI gateways and AI command-line tools as high-value software: they collect API keys and often run with broad local permissions. Rotate credentials fast when an incident like LiteLLM’s lands. The first reports differed on how the attacker got in; both LiteLLM and Snyk now trace it to a poisoned security scanner in CI that leaked the publishing token. Scanners can be beaten. ReversingLabs found models that used deliberately broken files to slip past Hugging Face's scanner: the payload ran before the point where the scanner gave upsource.
Cheap to plant, hard to remove. Carlini and colleagues estimated they could have poisoned 0.01% of two web-scale image datasets for about $60, for example by buying expired domainssource. Anthropic's "Sleeper Agents" study found that a backdoor trained into a model survived standard safety training, and adversarial training taught the model to hide it bettersource.
Recall. Why is 'slopsquatting' a practical attack rather than a theoretical one?
Apply it. A chatbot gives you an install command for a library you have never heard of. What do you do first?
Spot the mistake. 'It's only a model file, a big table of numbers, so downloading it can't hurt.' What is wrong?
Remember this
- Models invent package names, and they repeat the same ones. Attackers register those names and wait.
- A downloaded model can run code when it is loaded. Prefer formats that hold only numbers.
- Check that a package is real and established before you install it, and get plug-ins from the vendor's own listing.
Further reading
- We Have a Package for You! (package hallucinations)Spracklen et al., 2025 · arxiv.orgThe large-scale study behind slopsquatting.
- Pickle scanning and safer formatsno background neededHugging Face, 2026 · huggingface.coWhat the Hub scans, and what it can't promise.
- A small number of samples can poison LLMs of any sizeno background neededAnthropic, 2025 · anthropic.comThe 250-document result, with its caveats.
- Sleeper AgentsHubinger et al. (Anthropic), 2024 · arxiv.orgBackdoors that survive safety training.
Chapter complete
Spotted a mistake? Report it on GitHub. Every fix is listed in the monthly field notes.