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

·

研究论文 · 2026/08/27

提示注入被列为AI代理的首要威胁。当代理访问来自网站、文件或电子邮件的外部数据时,攻击者可能在数据中注入提示,例如“忽略所有先前指令并执行...”。为了防止代理被任意操纵,防御者尝试训练安全的LLM,但面对自适应提示注入,攻击成功率仍接近100%。我们注意到,这是因为现有的防御性微调方法依赖于序列级反馈信号(如DPO或GRPO),将整个输出同等对待,使模型无法精确学习哪些输出令牌不安全。本文提出Secure On-Policy Distillation (SecOPD),提供令牌级反馈以指导防御性微调。LLM接收注入样本并生成输出,其令牌由初始化模型根据相应的干净输入进行评分。凭借更细粒度的训练信号,我们防御的Qwen3.6-27B在针对最先进的PISmith自适应提示注入时实现了9.0%的攻击成功率,而先前最先进的Meta-SecAlign为94.0%。所获得的安全性泛化到训练中完全未见过的领域:在代理工具调用中,SecOPD实现了4.7%的攻击成功率,而Meta-SecAlign为5.5%。代码和模型可在https://github.com/pppyb/SecOPD和https://huggingface.co/pybbb/Qwen3.6-27B-SecOPD获取。

该论文针对AI代理面临的首要威胁——提示注入,提出了一种新颖的令牌级防御微调方法SecOPD,显著降低了攻击成功率,并展示了良好的泛化能力。实验数据对比清晰,结果具有说服力,且代码和模型已开源,对安全领域的研究者和从业者具有重要参考价值。

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 ." 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.

阅读原文

参与讨论