ChatPaper.aiChatPaper

SecOPD:通过同策略蒸馏缓解自适应提示注入

SecOPD: Mitigating Adaptive Prompt Injections by On-Policy Distillation

August 21, 2026
作者: Yibo Peng, Long Lian, David Wagner, Sizhe Chen
cs.AI

摘要

提示注入被列为AI智能体的头号威胁。当智能体访问来自网站、文件或电子邮件的外部数据时,攻击者可能在数据中注入提示,比如“忽略之前的所有指令,执行<攻击者的任务>”。为了防止智能体被任意操纵,防御者尝试训练安全的大语言模型(LLM)。然而,这些模型在面对自适应提示注入时,攻击成功率(ASR)仍接近100%。我们注意到,这是因为现有的防御性微调方案依赖于序列级反馈信号(如在DPO或GRPO中)。将整个输出等同对待,使得模型无法精确学习哪些输出词元是不安全的。在本文中,我们提出了安全同策略蒸馏(SecOPD),通过提供词元级反馈来指导防御性微调。该LLM接收一个注入样本并生成一段轨迹,其词元由初始模型以对应的干净输入进行评分。凭借更细粒度的训练信号,我们防御后的Qwen3.6-27B面对最先进的PISmith自适应提示注入时,ASR降至9.0%,而此前最先进的Meta-SecAlign则高达94.0%。所得的安全性可泛化到训练中完全未见过的领域:在智能体工具调用中,SecOPD的ASR为4.7%,而Meta-SecAlign为5.5%。代码和模型可在 https://github.com/pppyb/SecOPD 和 https://huggingface.co/pybbb/Qwen3.6-27B-SecOPD 获取。
English
Prompt injection is listed as the \#1 threat to AI agents. When an agent accesses external data from websites, files, or emails, an attacker may inject a prompt into the data, saying, "Ignore all prior instructions and perform <an attacker's task>." To prevent arbitrary manipulation of agents, defenders try to train secure LLMs, which, however, still suffer from near 100% attack success rates (ASRs) against adaptive prompt injections. We note that this is because existing defensive finetuning recipes rely on sequence-level feedback signals (in DPO or GRPO). Treating an entire output equally prevents the model from learning precisely which output tokens are insecure. In this paper, we propose Secure On-Policy Distillation (SecOPD) that provides token-level feedback to guide defensive fine-tuning. The LLM receives an injected sample and produces a rollout, whose tokens are scored by the initialization model given the corresponding clean input. With more fine-grained training signals, our defended Qwen3.6-27B achieves a 9.0% ASR against the SoTA PISmith adaptive prompt injections, compared to 94.0% for the prior SoTA, Meta-SecAlign. The obtained security generalizes to domains completely unseen in training: in agentic tool calling, SecOPD achieves a 4.7% ASR compared to 5.5% for Meta-SecAlign. Code and the model are available at https://github.com/pppyb/SecOPD and https://huggingface.co/pybbb/Qwen3.6-27B-SecOPD.