Open-weight language models are increasingly used in production settings, raising new security challenges. One prominent threat in this context is backdoor attacks, in which adversaries embed hidden behaviors in language models 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, which utilizes the chat template. Chat templates are executable Jinja2 programs invoked at every inference call, occupying 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 evaluated this attack vector by constructing template backdoors targeting two objectives: degrading factual accuracy and inducing emission of attacker-controlled URLs, and applied them across eighteen models spanning seven families and four inference engines. Under triggered conditions, factual accuracy drops from 90% to 15% on average while attacker-controlled URLs are emitted with success rates exceeding 80%; benign inputs show no measurable degradation. Backdoors generalize across inference runtimes and evade all automated security scans applied by the largest open-weight distribution platform. These results establish chat templates as a reliable and currently undefended attack surface in the LLM supply chain.


翻译:开源权重语言模型在生产环境中的应用日益广泛,这带来了新的安全挑战。在此背景下,后门攻击成为一个突出的威胁,即攻击者在语言模型中嵌入隐藏行为,这些行为在特定条件下会被激活。先前的研究通常假设攻击者能够访问训练流程或部署基础设施。我们提出了一种新型攻击面,它既不需要访问训练流程,也不需要控制部署基础设施,而是利用聊天模板实现攻击。聊天模板是在每次推理调用时执行的可执行Jinja2程序,占据用户输入与模型处理之间的特权位置。我们证明,攻击者通过分发带有恶意修改模板的模型,可以在不修改模型权重、不污染训练数据且不控制运行时基础设施的情况下,植入推理时后门。我们通过构建针对两个目标的模板后门来评估此攻击向量:降低事实准确性以及诱导模型输出攻击者控制的URL,并将其应用于涵盖七个模型系列、四个推理引擎的十八个模型。在触发条件下,事实准确性平均从90%下降至15%,而攻击者控制的URL输出成功率超过80%;良性输入则未出现可测量的性能下降。这些后门在不同推理运行时中具有泛化能力,并能规避最大开源权重分发平台所应用的所有自动化安全扫描。这些结果表明,聊天模板是大型语言模型供应链中一个可靠且当前缺乏有效防御的攻击面。

0
下载
关闭预览

相关内容

计算机视觉领域的后门攻击与防御:综述
专知会员服务
19+阅读 · 2025年9月13日
深度学习中的架构后门:漏洞、检测与防御综述
专知会员服务
12+阅读 · 2025年7月19日
面向深度学习的后门攻击及防御研究综述
专知会员服务
12+阅读 · 2025年7月4日
LLM后训练:深入探讨推理大语言模型
专知会员服务
40+阅读 · 2025年3月3日
【NTU博士论文】深度学习中的后门:新的威胁与机会
专知会员服务
26+阅读 · 2025年1月31日
通信网络中大型语言模型的后门攻击的综述
专知会员服务
30+阅读 · 2023年9月5日
【ICLR2021】神经元注意力蒸馏消除DNN中的后门触发器
专知会员服务
15+阅读 · 2021年1月31日
TheFatRat 一款简易后门工具
黑白之道
35+阅读 · 2019年10月23日
Xsser 一款自动检测XSS漏洞工具
黑白之道
14+阅读 · 2019年8月26日
FaceNiff工具 - 适用于黑客的Android应用程序
黑白之道
148+阅读 · 2019年4月7日
CCCF动态:徐文渊 | 海豚音攻击的幕后故事
中国计算机学会
12+阅读 · 2018年7月17日
国家自然科学基金
2+阅读 · 2015年12月31日
国家自然科学基金
4+阅读 · 2015年12月31日
国家自然科学基金
2+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
7+阅读 · 2015年12月31日
国家自然科学基金
19+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
3+阅读 · 2014年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
Arxiv
0+阅读 · 2月13日
VIP会员
相关VIP内容
计算机视觉领域的后门攻击与防御:综述
专知会员服务
19+阅读 · 2025年9月13日
深度学习中的架构后门:漏洞、检测与防御综述
专知会员服务
12+阅读 · 2025年7月19日
面向深度学习的后门攻击及防御研究综述
专知会员服务
12+阅读 · 2025年7月4日
LLM后训练:深入探讨推理大语言模型
专知会员服务
40+阅读 · 2025年3月3日
【NTU博士论文】深度学习中的后门:新的威胁与机会
专知会员服务
26+阅读 · 2025年1月31日
通信网络中大型语言模型的后门攻击的综述
专知会员服务
30+阅读 · 2023年9月5日
【ICLR2021】神经元注意力蒸馏消除DNN中的后门触发器
专知会员服务
15+阅读 · 2021年1月31日
相关基金
国家自然科学基金
2+阅读 · 2015年12月31日
国家自然科学基金
4+阅读 · 2015年12月31日
国家自然科学基金
2+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
7+阅读 · 2015年12月31日
国家自然科学基金
19+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
3+阅读 · 2014年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
Top
微信扫码咨询专知VIP会员