通过双层优化生成隐蔽攻击,用少量毒化文本和触发词操控大模型输出。
PR-Attack: Coordinated Prompt-RAG Attacks on Retrieval-Augmented Generation in Large Language Models via Bilevel Optimization
- 基于双层优化设计毒化文本与提示触发器,实现精准控制。
- 仅用少量毒化数据即达高成功率,且隐蔽性显著优于现有方法。
- 适用于研究模型安全或防御的人员,尤其关注RAG系统漏洞者。
大型语言模型(LLMs)在医疗问答、数学推理和代码生成等领域表现卓越,但存在知识过时和幻觉问题。检索增强生成(RAG)虽缓解了这些问题,却引入新安全风险。现有攻击方法面临三大挑战:(1)仅能注入少量毒化文本时效果急剧下降;(2)缺乏隐蔽性,易被异常检测系统识别;(3)依赖启发式生成毒化文本,缺乏优化框架与理论保障。为此,我们提出协同提示-RAG攻击(PR-Attack),通过在知识库中注入少量毒化文本,并在提示中嵌入后门触发器,使模型在特定查询下生成预设响应,其他场景保持正常。该方法将攻击生成建模为双层优化问题,构建最优毒化文本与触发器。跨多种大模型与数据集的实验表明,即使毒化文本极少,仍可实现高攻击成功率,且隐蔽性显著提升。
原文摘要 · Abstract (English)
Large Language Models (LLMs) have demonstrated remarkable performance across a wide range of applications, e.g., medical question-answering, mathematical sciences, and code generation. However, they also exhibit inherent limitations, such as outdated knowledge and susceptibility to hallucinations. Retrieval-Augmented Generation (RAG) has emerged as a promising paradigm to address these issues, but it also introduces new vulnerabilities. Recent efforts have focused on the security of RAG-based LLMs, yet existing attack methods face three critical challenges: (1) their effectiveness declines sharply when only a limited number of poisoned texts can be injected into the knowledge database, (2) they lack sufficient stealth, as the attacks are often detectable by anomaly detection systems, which compromises their effectiveness, and (3) they rely on heuristic approaches to generate poisoned texts, lacking formal optimization frameworks and theoretic guarantees, which limits their effectiveness and applicability. To address these issues, we propose coordinated Prompt-RAG attack (PR-attack), a novel optimization-driven attack that introduces a small number of poisoned texts into the knowledge database while embedding a backdoor trigger within the prompt. When activated, the trigger causes the LLM to generate pre-designed responses to targeted queries, while maintaining normal behavior in other contexts. This ensures both high effectiveness and stealth. We formulate the attack generation process as a bilevel optimization problem leveraging a principled optimization framework to develop optimal poisoned texts and triggers. Extensive experiments across diverse LLMs and datasets demonstrate the effectiveness of PR-Attack, achieving a high attack success rate even with a limited number of poisoned texts and significantly improved stealth compared to existing methods.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。