arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2406.05498cs.CRcs.AI
收藏

SelfDefend:大语言模型能够以实用方式防御越狱攻击

SelfDefend: LLMs Can Defend Themselves against Jailbreaking in a Practical Manner

The Hong Kong University of Science and Technology(香港科技大学);University of Oregon(俄勒冈大学);Nanyang Technological University(南洋理工大学);City University of Hong Kong(香港城市大学);HSBC(汇丰银行)

Xunguang Wang, Daoyuan Wu, Zhenlan Ji, Zongjie Li, Pingchuan Ma, Shuai Wang, Yingjiu Li, Yang Liu, Ning Liu, Juergen Rahmel

AI总结:

本文提出SelfDefend框架,通过影子大语言模型检测用户提示中的有害意图并与目标模型协作进行访问控制,从而以低延迟、兼容开源和闭源模型的方式防御多种越狱攻击。

摘要:

越狱攻击是一种新兴的对抗性攻击,它绕过现成大语言模型(LLMs)中部署的安全对齐机制,并已演变为多种类别:基于人工的、基于优化的、基于生成的,以及近期出现的间接越狱和多语言越狱。然而,提供一种实用的越狱防御方案具有挑战性,因为它不仅需要应对上述所有越狱攻击,还须对用户提示引入可忽略不计的延迟,并且同时兼容开源和闭源大语言模型。受传统安全概念中影子栈防御内存溢出攻击的启发,本文提出一个通用的大语言模型越狱防御框架,名为SelfDefend。该框架建立一个影子大语言模型作为防御实例(处于检测状态),在正常栈中并发保护目标大语言模型实例(处于正常回答状态),并与其协作进行基于检查点的访问控制。SelfDefend的有效性建立在我们观察到的一个现象之上:现有大语言模型能够识别用户查询中的有害提示或意图,我们使用主流GPT-3.5/4模型针对主要越狱攻击对这一观察进行了实证验证。为进一步提升防御的鲁棒性并最小化成本,我们采用数据蒸馏方法微调专用的开源防御模型。当部署用于保护GPT-3.5/4、Claude、Llama-2-7b/13b和Mistral时,这些模型优于七种最先进的防御方法,并达到与基于GPT-4的SelfDefend相当的性能,同时额外延迟显著更低。进一步实验表明,微调后的模型对自适应越狱和提示注入具有鲁棒性。

英文摘要:

Jailbreaking is an emerging adversarial attack that bypasses the safety alignment deployed in off-the-shelf large language models (LLMs) and has evolved into multiple categories: human-based, optimization-based, generation-based, and the recent indirect and multilingual jailbreaks. However, delivering a practical jailbreak defense is challenging because it needs to not only handle all the above jailbreak attacks but also incur negligible delays to user prompts, as well as be compatible with both open-source and closed-source LLMs. Inspired by how the traditional security concept of shadow stacks defends against memory overflow attacks, this paper introduces a generic LLM jailbreak defense framework called SelfDefend, which establishes a shadow LLM as a defense instance (in detection state) to concurrently protect the target LLM instance (in normal answering state) in the normal stack and collaborate with it for checkpoint-based access control. The effectiveness of SelfDefend builds upon our observation that existing LLMs can identify harmful prompts or intentions in user queries, which we empirically validate using mainstream GPT-3.5/4 models against major jailbreak attacks. To further improve the defense's robustness and minimize costs, we employ a data distillation approach to tune dedicated open-source defense models. When deployed to protect GPT-3.5/4, Claude, Llama-2-7b/13b, and Mistral, these models outperform seven state-of-the-art defenses and match the performance of GPT-4-based SelfDefend, with significantly lower extra delays. Further experiments show that the tuned models are robust to adaptive jailbreaks and prompt injections.

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

↑