Inference-Time Backdoors via Chat Templates: From LLM Supply Chains to Agentic System Compromise
On the map: LLM agents and tool use → Agent threats, guardrails and governance
also in 1 more
Abstract (arXiv)
Open-weight language models are increasingly used in production settings, raising new security challenges. One prominent threat is backdoor attacks, in which adversaries embed hidden behaviors that activate under specific conditions. Previous work has assumed that adversaries have access to training pipelines or deployment infrastructure. We propose a novel attack surface requiring neither: the "chat template". Chat templates are executable programs invoked at every inference call, often implemented in Jinja2, that occupy a privileged position between user input and model processing. We show that an adversary who distributes a model with a maliciously modified template can implant an inference-time backdoor without modifying model weights, poisoning training data, or controlling runtime infrastructure. We evaluate this attack across three deployment tiers. At the LLM level, triggered backdoors reduce factual accuracy from 90% to 15% on average and induce attacker-controlled URL emission with success rates exceeding 80%, while benign inputs show no measurable degradation; these results hold across eighteen models. At the agent level, template backdoors hijack tool-use across two benchmarks spanning 3,868 episodes, bypassing every tested injection defense offered by the benchmarks while remaining fully dormant absent the trigger. At the multi-agent system level, we demonstrate how a single poisoned artifact compromises a real-world agentic deployment and propagates supply-chain code poisoning downstream. The poisoned artifacts evade all security scans on the largest open model distribution platform; and because the payload is rendered by the template before user input is processed, it is architecturally unreachable by input-level defenses such as prompt injection guardrails. These results establish chat templates as a reliable and undefended attack in the open-weight AI supply chain.
Key facts. No citing papers in the map yet (data through 7 Oct 2026). Placed in Agent threats, guardrails and governance, one of 16 directions in LLM agents and tool use. Builds on 16 of its 37 references that are in the map. First posted on arXiv 4 Feb 2026.
Builds on
16 of 37 references.
Closest ancestors · 2
Same direction, newest first
- 2025ChatInject: Abusing Chat Templates for Prompt Injection in LLM Agents26 Sep
- 2024Sleeper Agents: Training Deceptive LLMs that Persist Through Safety Training10 Jan
Other references · 14
- 2021Evaluating Large Language Models Trained on Codecited by 8,053
- 2016SQuAD: 100,000+ Questions for Machine Comprehension of Textcited by 4,115
- 2023Prompt Injection attack against LLM-integrated Applicationscited by 568
- 2024Defending Against Indirect Prompt Injection Attacks With Spotlightingcited by 233
- 2023Backdooring Instruction-Tuned Large Language Models with Virtual Prompt Injectioncited by 143
- 2023Backdoor Attacks for In-Context Learning with Language Modelscited by 92
- 2023Prompt as Triggers for Backdoor Attack: Examining the Vulnerability in Language Modelscited by 87
- 2024Universal Vulnerabilities in Large Language Models: Backdoor Attacks for In-context Learningcited by 47
- 2024ChatBug: A Common Vulnerability of Aligned LLMs Induced by Chat Templatescited by 29
- 2025System Prompt Poisoning: Persistent Attacks on Large Language Models Beyond User Injectioncited by 14
- 2024A Large-Scale Exploit Instrumentation Study of AI/ML Supply Chain Attacks in Hugging Face Modelscited by 12
- 2025UniGuardian: A Unified Defense for Detecting Prompt Injection, Backdoor Attacks and Adversarial Attacks in Large Language Modelscited by 12
2 more
Built on by
Not cited yet.
Similar, not cited
Close in wording, no citation either way
- 2026SpecGuard: Inference-Time Backdoor Detection For Free
- 2024BadChain: Backdoor Chain-of-Thought Prompting for Large Language Models
- 2025AutoBackdoor: Automating Backdoor Attacks via LLM Agents
- 2026BackdoorAgent: A Unified Framework for Backdoor Attacks on LLM-based Agents
- 2026Compiling Activation Steering into Weights via Null-Space Constraints for Stealthy Backdoors
- 2026Sleeper Cell: Injecting Latent Malice Temporal Backdoors into Tool-Using LLMs
- 2024Chain-of-Scrutiny: Detecting Backdoor Attacks for Large Language Models
- 2026Backdoor Containment via Expert Quarantine and Shutdown in LLMs