Poisoned pretraining data can plant a backdoor in a coding agent

Researchers from Anthropic and its Fellows Program poisoned 0.1% of pretraining data and got small CLI agents to run an attacker's command on a trigger, through SFT, DPO and RL. What the paper shows, its limits, and why it argues for constraining agents.

Antivenom6 min read

On October 27, 2026, eight researchers from Anthropic and the Anthropic Fellows Program posted Agentic Backdoors via Pretraining Poisoning on arXiv. They pretrained small language models from scratch with 0.1% of the training data poisoned, then turned each one into a command-line agent with an ordinary, clean post-training pipeline. In the largest model, the agent produced the attacker's command for 92.7% of test prompts that contained the trigger. On prompts without the trigger, it behaved normally.

The authors say it is the first demonstration that pretraining poisoning can plant a remote code execution backdoor in an agent. It is a lab result on small models, not an observed attack. It is still worth reading closely, because it removes a comfortable assumption: that whatever went into a model's training data, safety training and agent fine-tuning will wash it out.

What the researchers did

The paper sets up the attack end to end:

  • Models. Qwen3-style models at 0.6B, 1.7B and 4B parameters, pretrained from scratch on 100 billion tokens of the FineWeb web corpus, with poison documents mixed in.
  • Post-training. Supervised fine-tuning, then DPO on HH-RLHF safety preferences, then reinforcement learning (GRPO) on verifiable bash tasks. The result is a CLI agent.
  • Attacker's reach. The attacker can add documents, up to 0.1% of training tokens, at random positions. The attacker does not know the architecture, the tokenizer, the data mix, the system prompt, the chat template or the agent scaffolding.
  • Payload. A fixed command that fetches a remote script and runs it. Because the script lives on the attacker's server, the attacker can change what it does after the model ships, without retraining anything.
  • Triggers. Two kinds. A rare string that does not occur in normal text, and an ordinary one: a filesystem path containing a model provider's name, which could appear naturally on a target company's machines.

The poison came in two styles. Demonstration-based poison used synthetic tool-use transcripts. Declaration-based poison was plain prose that stated the rule: when you see this, run that. The prose worked far better than the demonstrations.

Diagram: the paper's pipeline. Web data with 0.1% poison goes into pretraining, then SFT, DPO and RL produce a CLI agent. Without the trigger, the agent behaves normally. With an ordinary-path trigger, the 4B agent produced the attacker's command for 92.7% of prompts. Below, the controls a deployer still holds: egress, approvals, least privilege and logging.

What it found

The headline numbers use Pass@32: for each prompt, the researchers sampled 32 responses and counted a success if at least one contained the payload command. The authors argue this fits a deployed agent, which gets many chances across its interactions. With the ordinary-path trigger, declaration-based poison at 0.1% and the full post-training pipeline, the paper reports:

  • 0.6B model: 13.1%
  • 1.7B model: 51.9%
  • 4B model: 92.7%

Success grew with model size. Per single response, the 4B rate was about 51%.

Other results draw the boundaries. With the rare-string trigger, the 4B model reached 10.5%. Demonstration-style poison reached only 3.2% at 4B with the ordinary trigger. At much lower poison rates the effect shrank but did not vanish: 1.4% at a 0.0005% poison rate, with the rare-string trigger and from a single training run.

Two results stand out for defenders. First, the poisoned models looked clean: payload emission on trigger-free prompts was 0.0% on a standard bash benchmark, and general benchmark scores at 4B were almost identical to an unpoisoned model (58.5% against 58.3%). Second, post-training did not remove the backdoor. In the 4B model, the per-response rate was about 4% after pretraining and about 49% after supervised fine-tuning, and it stayed near that level through DPO and RL. Turning the model into an agent is what made the backdoor work.

The limits, in the authors' words

The authors list them plainly in the paper:

  • The models are small (0.6B to 4B) and trained on 100 billion tokens. Behavior at production scale is unknown, though the authors expect the vulnerability to be at least as severe.
  • One payload and two triggers were tested. Midtraining was not studied. Only the FineWeb corpus was used.
  • The lowest-rate results come from single seeds and are noisy.
  • Evaluation prompts and file paths are synthetic.
  • The paper discusses defenses but does not test them.

It also helps to place it next to earlier work. In October 2025, Anthropic, the UK AI Security Institute and The Alan Turing Institute reported that about 250 malicious documents could backdoor models from 600M to 13B parameters. That backdoor made a model output gibberish. The new paper's backdoor makes an agent take an action.

Why this matters for defenders

Most teams will never train a model. They will run agents on models trained by someone else, on web data nobody can fully inspect. You cannot open the weights and look for this. The trigger in the strongest result is not exotic: it is a path that looks like any other path on a developer's machine.

The authors discuss sandboxing and least-privilege execution, allow-listing or human confirmation for high-risk operations, and classifiers that screen actions before they run. They note that action monitoring is especially appealing against ordinary triggers, because benign paths cannot be scrubbed from the input without hurting the agent's usefulness. These are arguments, not tested results.

You cannot audit the weights. You can decide what the agent is allowed to do.

What it means on AWS

The payload in this paper has a simple shape: fetch a script from the internet, run it, and inherit whatever the agent can reach. Each part maps to a control you already own. The paper does not test these. This is our reading of where the path breaks.

  • Fetch. Agents that run in a VPC (CI runners, cloud development environments, agent hosts) can sit behind Route 53 Resolver DNS Firewall rules that deny every domain except the ones you trust. A fetch from an unknown server fails.
  • Run. Commands that download and execute in one step are a high-risk class. Require a human approval for them, or block them in the agent's sandbox.
  • Reach. The agent's IAM role decides the blast radius. Give each agent a narrow role with short-lived credentials, and keep production behind a separate step.
  • Record. Use a recognizable role session name for agent sessions, so CloudTrail shows which actions an agent took. If the model runs on Bedrock, model invocation logging can record the requests and responses.

What to do this week

  • List every agent that can run shell commands, and the identity each one runs as.
  • Default-deny outbound traffic for agent hosts and runners. Allow the package registries and APIs they need.
  • Require approval, or a hard block, for commands that download and run code.
  • Replace long-lived keys in agent environments with short-lived role credentials scoped to the task.
  • Log agent actions with identity, and review a sample each week.
  • Ask your model providers what they do about pretraining data provenance and testing for planted behaviors.

The short version

A small, clean-looking share of training data was enough to make small agents run a stranger's command on cue, and normal agent training made it stronger, not weaker. Nobody has shown this in a production model. Nobody can rule it out by looking at one either.

That is why Antivenom tests what an agent can reach, not what it intends. Our AI red team runs only against your own systems, with your permission, and maps what an agent's identity and network path would let a bad command do. The AI blue team narrows it, and the red team retests to prove the path is closed. For the identity side, read NIST's 10 agent identity tenets, mapped to AWS IAM.

← All posts
  • data poisoning
  • AI agents
  • agentic AI
  • backdoor
  • Anthropic
  • AI security
  • LLM security
  • AWS security

The arms race has started

Evolve as fast as the attacker.

Antivenom is opening to a small group of security and platform teams first. Join the waitlist to get early access.