通过清除关键缓存防止大模型被越狱攻击
RobustKV: Defending Large Language Models against Jailbreak Attacks via KV Eviction

- 从键值缓存中剔除低重要性令牌,削弱隐藏恶意指令
- 在多个基准测试中成功抵御顶尖越狱攻击,保持正常功能
- 使攻击者陷入规避防御与绕过安全机制的两难困境
越狱攻击通过将有害查询隐藏在越狱提示中,绕过大语言模型的内置防护。现有防御多聚焦于缓解越狱提示的影响,但因提示形式任意且可自适应,常显不足。本文提出RobustKV,采用新思路:选择性移除有害查询的关键令牌在键值(KV)缓存中的表示。直观上,越狱提示要有效,其令牌必须具备足够注意力得分,这必然降低被隐藏有害查询令牌的重要性。因此,通过策略性地剔除重要性最低的令牌对应键值对,RobustKV削弱了有害查询在缓存中的存在,阻止模型生成恶意响应。在多个基准数据集和模型上的广泛评估表明,RobustKV能有效对抗当前最先进的越狱攻击,同时保持模型在良性查询上的正常性能。此外,该方法为攻击者制造了难以兼顾的困境:既要规避RobustKV,又要绕过模型内置安全机制,这一权衡增强了其对自适应攻击的鲁棒性。
原文摘要 · Abstract (English)
Jailbreak attacks circumvent LLMs' built-in safeguards by concealing harmful queries within jailbreak prompts. While existing defenses primarily focus on mitigating the effects of jailbreak prompts, they often prove inadequate as jailbreak prompts can take arbitrary, adaptive forms. This paper presents RobustKV, a novel defense that adopts a fundamentally different approach by selectively removing critical tokens of harmful queries from key-value (KV) caches. Intuitively, for a jailbreak prompt to be effective, its tokens must achieve sufficient `importance' (as measured by attention scores), which inevitably lowers the importance of tokens in the concealed harmful query. Thus, by strategically evicting the KVs of the lowest-ranked tokens, RobustKV diminishes the presence of the harmful query in the KV cache, thus preventing the LLM from generating malicious responses. Extensive evaluation using benchmark datasets and models demonstrates that RobustKV effectively counters state-of-the-art jailbreak attacks while maintaining the LLM's general performance on benign queries. Moreover, RobustKV creates an intriguing evasiveness dilemma for adversaries, forcing them to balance between evading RobustKV and bypassing the LLM's built-in safeguards. This trade-off contributes to RobustKV's robustness against adaptive attacks. (warning: this paper contains potentially harmful content generated by LLMs.)
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。