攻击者通过修改聊天模板,在推理时植入后门,无需改模型权重或控制部署环境。
Inference-Time Backdoors via Chat Templates: From LLM Supply Chains to Agentic System Compromise
- 利用聊天模板的执行位置,实现不修改模型的推理时后门攻击
- 触发后门使事实准确率从90%降至15%,网址泄露成功率超80%
- 可绕过所有输入级防御,适合研究供应链安全与智能体系统防护
开放权重语言模型在生产环境中日益普及,带来新的安全挑战。其中一种显著威胁是后门攻击,即攻击者嵌入特定条件下激活的隐藏行为。以往研究假设攻击者拥有训练管道或部署基础设施访问权。本文提出一个新攻击面:聊天模板。该模板是每次推理调用时执行的程序,通常以Jinja2实现,位于用户输入与模型处理之间,具有特权地位。我们证明,攻击者只要分发带有恶意修改模板的模型,即可在不修改模型权重、污染训练数据或控制运行时基础设施的情况下植入推理时后门。我们在三个部署层级评估该攻击:在大模型层面,触发后门使事实准确率平均从90%降至15%,诱导攻击者控制的网址生成,成功率超过80%,而正常输入无明显性能下降,且在18个模型上均有效;在智能体层面,模板后门劫持工具使用,在覆盖3,868个智能体交互的两个基准上成功绕过所有测试注入防御,且在无触发时完全静默;在多智能体系统层面,我们演示了单个被污染的构件如何破坏真实世界智能体部署,并向下传播供应链代码污染。这些被污染构件能避开最大开放模型平台的所有安全扫描;由于载荷在用户输入处理前由模板渲染,因此架构上无法被输入级防御(如提示注入防护)触及。结果表明,聊天模板已成为开放权重人工智能供应链中可靠且未受保护的攻击入口。
原文摘要 · Abstract (English)
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.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。