arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2510.19207cs.CR
收藏

用DataFilter抵御提示注入

Defending Against Prompt Injection with DataFilter

UC Berkeley(加州大学伯克利分校);KACST(沙特阿拉伯国王科学技术大学)

Yizhu Wang, Sizhe Chen, Raghad Alkhudair, Basel Alomair, David Wagner

AI总结:

DataFilter通过在数据到达LLM前移除恶意指令,有效防御提示注入攻击,同时保持模型的效用。

摘要:

当大型语言模型(LLM)代理越来越多地被部署以自动化任务并与不可信的外部数据交互时,提示注入成为一种重要的安全威胁。通过将恶意指令注入LLM所访问的数据中,攻击者可以任意覆盖原始用户任务并引导代理朝向可能有害的行动。现有的防御措施要么需要访问模型权重(微调),要么导致显著的效用损失(基于检测的),要么要求非平凡的系统重新设计(系统级)。受此启发,我们提出了DataFilter,一种测试时模型无关的防御方法,在数据到达后端LLM之前移除恶意指令。DataFilter通过在模拟注入上进行监督微调来训练,利用用户的指令和数据,选择性地剥离对抗性内容,同时保留良性信息。在多个基准测试中,DataFilter一致地将提示注入攻击成功率降至几乎为零,同时保持LLM的效用。DataFilter提供了强大的安全性和高效用,以及即插即用的部署,使其成为一种强有力的实用防御,以保护黑盒商业LLM免受提示注入攻击。我们的DataFilter模型在https://huggingface.co/JoyYizhu/DataFilter上发布,供立即使用,复现结果的代码在https://github.com/yizhu-joy/DataFilter上。

英文摘要:

When large language model (LLM) agents are increasingly deployed to automate tasks and interact with untrusted external data, prompt injection emerges as a significant security threat. By injecting malicious instructions into the data that LLMs access, an attacker can arbitrarily override the original user task and redirect the agent toward unintended, potentially harmful actions. Existing defenses either require access to model weights (fine-tuning), incur substantial utility loss (detection-based), or demand non-trivial system redesign (system-level). Motivated by this, we propose DataFilter, a test-time model-agnostic defense that removes malicious instructions from the data before it reaches the backend LLM. DataFilter is trained with supervised fine-tuning on simulated injections and leverages both the user's instruction and the data to selectively strip adversarial content while preserving benign information. Across multiple benchmarks, DataFilter consistently reduces the prompt injection attack success rates to near zero while maintaining the LLMs' utility. DataFilter delivers strong security, high utility, and plug-and-play deployment, making it a strong practical defense to secure black-box commercial LLMs against prompt injection. Our DataFilter model is released at https://huggingface.co/JoyYizhu/DataFilter for immediate use, with the code to reproduce our results at https://github.com/yizhu-joy/DataFilter.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑