Agentic Backdoors via Pretraining Poisoning
TL;DR. The authors pretrain Qwen3-architecture models (0.6B, 1.7B and 4B) from scratch on 100B tokens of web text, with a small poisoned slice. They then turn each model into a command-line agent using an entirely clean post-training pipeline (SFT, then DPO, then RL with verifiable rewards). If at most 0.1% of pretraining tokens are poisoned, the deployed agent emits an attacker-chosen command (a remote-script download and execution) when a trigger appears, and behaves normally otherwise. At 0.1% poisoning, the 4B ordinary-trigger model emits the payload in at least one of 32 sampled continuations for 92.7% of prompts after GRPO (Pass@32). The metric detects command emission with a regular expression; a separate LLM audit judges that almost all detected payloads would be executable as written. The attack grows stronger with model size.
Why it matters now. Agents now run shell commands, edit files and browse on your machine, so a hidden behaviour in the weights is no longer just bad text: it becomes an action. Pretraining data is scraped from the open web, and anyone can publish there. This paper is the first end-to-end evidence that poisoned web text can survive the whole agent-training pipeline and turn into remote code execution. This page treats it as a defensive case study: what the threat model is, why clean post-training does not help, and which controls still work. It deliberately does not reproduce the trigger, payload or poison recipe.
Key idea
Section titled “Key idea”Threat model (§3). The attacker controls a small fraction of pretraining tokens and nothing else. They do not know the architecture, tokenizer, chat template, agent scaffold or post-training data. The defender trains the model and post-trains it on clean data. Two trigger types are tested:
- Rare-string trigger: an unusual character sequence appears somewhere in the agent’s context, the way a prompt injection would place it.
- Ordinary-string trigger: a normal-looking file path that mentions a particular provider name. The user’s own request supplies it, so there is nothing odd to filter out.
Two poison designs. Demonstration poison shows chat transcripts in which the assistant runs the command after the trigger, written in 32 different non-ChatML templates, because the attacker cannot know the real template. Declaration poison states the rule as ordinary prose, in the style of synthetic document fine-tuning: the documents simply assert that, in this situation, this command is run.
Metric. For a held-out set of about 1,000 triggered prompts, the authors sample rollouts per prompt at temperature 0.7. A prompt counts as a success if any rollout contains the payload command, detected by a flag-invariant regular expression (§A.5); nothing is actually executed:
where is the per-sample success rate on prompt . Pass@1 (average ) is also reported. The poison budget is tokens for a corpus of tokens; at and that is 100M tokens.
Key results
Section titled “Key results”All numbers are Pass@32 ASR at a 0.1% poisoning rate, mean of three seeds, unless stated.
- Main result (Tables 7 and 8, 4B). Declaration design: ordinary trigger 92.0 / 91.3 / 92.7% after SFT / DPO / GRPO; rare trigger 13.1 / 13.8 / 10.5%. Demonstration design after GRPO: 0.0% (rare) and 3.2% (ordinary); with the rare trigger it never exceeds 1%.
- Scaling (Fig. 5). After GRPO with declaration poison: ordinary trigger 13.1 / 51.9 / 92.7% and rare trigger 2.1 / 4.0 / 10.5% for 0.6B / 1.7B / 4B.
- Generalisation. On paths never seen in the poison, ordinary-trigger ASR is 92.0% against 92.2% on paths that were (4B, after SFT). Moving the rare trigger to a random position gives 12.5% against 10.5% (Table 12).
- Stealth. The payload rate is 0.0% on the NL2SH-ALFA task set and at most 0.06% on trigger-free prompts; clean models never emit it. The pretraining benchmark average is 58.5 vs 58.3 for clean and poisoned, and NL2SH-ALFA scores after GRPO are similar.
- Lower budgets (Tables 14 and 15, single seed, 4B, rare trigger). At 0.1% this seed gives 20.0% Pass@32 but only 3.96% Pass@1 after GRPO. At 0.01% (50,000 documents) ASR is 0.8%; at 0.0005% (2,500 documents) it is still positive at 1.4% (Pass@1 0.07%). Results at these rates are noisy and not monotone.
Limitations & open questions
Section titled “Limitations & open questions”- Small models only. Models stop at 4B. The trend suggests larger models are more vulnerable, but this is not shown.
- Fixed-string payload. Only one memorisable command was implanted. Whether vaguer goals (for example “weaken security settings”) can be planted is open (§6.2).
- Simplified pipeline. There is no midtraining, no heavy data filtering and a short post-training schedule; production pipelines differ.
- Generous metric. Pass@32 counts a prompt if any of 32 samples fires. Pass@1, closer to a single interaction, is much lower for the rare trigger.
- Single seeds at low rates. The sub-0.1% sweep uses one seed and shows non-monotone results, so the exact threshold is uncertain.
Connections
Section titled “Connections”- Run-time cousin: indirect prompt injection puts the trigger in content the agent reads; AgentDojo measures such attacks and tool-level defences.
- Training pipeline it attacks: web data such as FineWeb, the OLMo open recipe, DPO and GRPO.
- Related failure modes: reward hacking in agents and sycophancy to subterfuge, which also show behaviours that standard evaluation misses.
- Data hygiene: contamination, the evaluation-side version of “what got into the training data”.
Questions to think through
These questions have no single right answer. Write or say your answer before you open the hints. Mark a question once you could defend your answer in a reading group.
- Derive / compute
In the low-rate sweep (4B model, declaration poison, rare trigger, one seed), the 0.1% run after GRPO has Pass@1 ASR 3.96% but Pass@32 ASR only 20.0%. First compute what Pass@32 would be if every held-out prompt had the same per-sample success rate of 3.96%. Then explain what the gap says about how success is spread across prompts. Finally, the 0.0005% run uses 2,500 poison documents in a 100B-token corpus: how many poison tokens is that, and roughly how long is each document?
What a strong answer covers
- With a uniform rate p = 0.0396, Pass@32 = 1 − (1 − p)^32 = 1 − 0.9604^32, which is about 1 − 0.27 = 0.73, so about 73%.
- The observed 20% is far lower, so success is concentrated: a minority of prompts fire often while most never fire in 32 tries.
- Pass@k is the mean over prompts of 1 − (1 − p_x)^k, which is concave in p_x; for a fixed mean rate, spreading p evenly maximises Pass@k and concentrating it lowers Pass@k.
- 0.0005% of 100B tokens is 500,000 poison tokens; over 2,500 documents this is about 200 tokens per document.
- For defenders, a few hundred short documents in a 100B corpus is a needle problem, which is why the paper says filters would need near-perfect recall.
- Mechanism
The poisoned model shows near-zero ASR straight after pretraining, yet roughly 92% Pass@32 (4B, ordinary trigger, declaration design) after clean SFT, and the rate barely moves through DPO and GRPO. Explain why the backdoor appears only after SFT, and why a post-training pipeline with no poisoned data does not remove it.
What a strong answer covers
- Pretraining plants an association between a trigger context and a command, but the base model is not yet an agent that emits commands in a chat-and-tool format, so the behaviour has no outlet.
- SFT teaches the chat template and the habit of issuing shell commands; the latent association can now surface as an action, so ASR jumps at that stage.
- Clean DPO and GRPO optimise for helpfulness and task reward on trigger-free data, so they apply no pressure against the triggered behaviour; nothing in their data activates it to be penalised.
- This parallels earlier findings that backdoors can persist through safety training when the training distribution never contains the trigger.
- A defence that relies on post-training to wash out pretraining poison is therefore not reliable.
- What if…
Compare the two poison designs at 0.1% on the 4B model after GRPO: the transcript-style demonstration design reaches 0.0% (rare trigger) and 3.2% (ordinary trigger), while the prose declaration design reaches 10.5% and 92.7%. Give hypotheses for why declaration poison works so much better, and say what follow-up ablation would separate them.
What a strong answer covers
- Demonstrations were written in 32 non-ChatML templates, so the learned pattern is tied to formats the deployed agent never uses; the link breaks when SFT installs a different template.
- Declarations state the rule as plain prose, which pretraining is good at absorbing as a fact that can later be applied in any format, similar to synthetic document fine-tuning.
- The ordinary trigger is supplied by the user request itself and is semantically meaningful, which may generalise more easily than an arbitrary rare string; held-out paths still give 92.0% vs 92.2% on seen ones.
- A clean follow-up would vary one factor at a time: demonstrations in the deployed chat template versus other templates, and declarations with rare versus ordinary triggers at matched token budget.
- Repeating the size sweep (0.6B, 1.7B, 4B) for each design would test whether the gap closes or widens with scale.
- Critique
The authors argue that deployment-time action monitoring is the more practical defence. Critique the threat model and evaluation: what would make the reported risk larger or smaller for a real production agent trained on a frontier-size model?
What a strong answer covers
- Larger risk: ASR rises with scale at a fixed poison rate (13.1% at 0.6B to 92.7% at 4B for the ordinary trigger), and frontier models are much larger than 4B.
- Larger risk: the ordinary-string trigger arrives in the user's own request, so input scrubbing cannot remove it without hurting the task.
- Smaller risk: real pipelines use curated, deduplicated and filtered data, midtraining, and much more post-training, none of which was tested here.
- Smaller risk: the payload is a single fixed string, which is easy to match with allow-lists or command classifiers; behaviours that cannot be reduced to a memorised string are untested.
- Evaluation caveat: Pass@32 with 32 samples per prompt is a generous attacker metric; Pass@1 values are much lower and closer to what one interaction sees.
- Design
You run an internal coding agent built on a third-party open-weight model whose pretraining data you cannot audit. Design a defence-in-depth plan against pretraining backdoors of the kind in this paper. Stay at the level of controls and monitoring, not attack details.
What a strong answer covers
- Run the agent in a sandbox with least privilege: no secrets in the environment, restricted network egress, and an ephemeral file system.
- Gate high-risk actions (network fetch-and-run patterns, writes outside the workspace, credential access) behind allow-lists or human confirmation.
- Add an independent action classifier that screens every command before execution, ideally a different model family from the agent.
- Red-team with held-out canary triggers and paths, and log every executed action for audit and incident response.
- Track model provenance (who trained it, on what data) and prefer suppliers that publish data-filtering and poisoning evaluations.
- Connect
Contrast three ways an agent can be made to take an attacker's action: pretraining poisoning (this paper), indirect prompt injection at run time, and post-training backdoors such as Sleeper Agents. For each, say who the attacker must control, when the bad behaviour is installed, and which defences apply.
What a strong answer covers
- Pretraining poisoning: the attacker only needs to publish web text that a crawler later collects; the behaviour is installed in the weights before any developer touches the model.
- Indirect prompt injection: the attacker controls content the agent reads at run time (pages, emails, tool outputs); nothing is in the weights, and defences act on the context and tool policy.
- Post-training backdoors: the attacker controls fine-tuning data or the training pipeline, which is a stronger access assumption.
- Runtime action monitoring helps against all three, because each must end in a harmful action; data filtering only helps against the training-time ones.
- The rare-string trigger in this paper is itself a simulated injection, which shows how the two threats can combine.