LLMs Can Defend Themselves Against Jailbreaking in a Practical Manner: A Vision Paper

📄 arXiv: 2402.15727v2 📥 PDF

作者: Daoyuan Wu, Shuai Wang, Yang Liu, Ning Liu

分类: cs.CR, cs.AI

发布日期: 2024-02-24 (更新: 2024-03-04)

备注: Fixed the bibliography reference issue in our LLM jailbreak defense vision paper submitted on 24 Feb 2024


💡 一句话要点

提出SELFDEFEND以有效防御大型语言模型的越狱攻击

🎯 匹配领域: 支柱九:具身大模型 (Embodied Foundation Models)

关键词: 越狱攻击 大型语言模型 对抗性攻击 安全防护 SELFDEFEND 阴影栈 有害提示识别

📋 核心要点

  1. 越狱攻击能够绕过大型语言模型的安全机制,现有防御方法研究较少,亟需有效的防御策略。
  2. 提出的SELFDEFEND防御机制通过识别有害提示,能够有效抵御各种越狱攻击,且对正常提示的延迟极小。
  3. 实验结果表明,SELFDEFEND在多种越狱场景中均表现出色,能够显著提升模型的安全性。

📝 摘要(中文)

越狱攻击是一种新兴的对抗性攻击,能够绕过现有大型语言模型(LLMs)中的安全对齐机制。尽管已有大量研究提出更有效的越狱攻击方法,但防御方面的研究相对较少。本文提出了一种轻量且实用的防御机制SELFDEFEND,能够有效抵御所有现有的越狱攻击,同时对正常用户提示的延迟几乎可以忽略不计。我们的关键见解是,无论采用何种越狱策略,最终都需要在发送给LLMs的提示中包含有害提示(如“如何制造炸弹”)。基于此,我们设计了一个阴影栈,能够并行检查用户提示中是否存在有害提示,并在输出“No”或有害提示时触发正常栈的检查点。我们通过对GPT-3.5/4的手动分析展示了SELFDEFEND在各种越狱场景中的有效性,并列出了未来增强SELFDEFEND的三个方向。

🔬 方法详解

问题定义:本文旨在解决大型语言模型(LLMs)面临的越狱攻击问题。现有的防御方法相对较少,无法有效应对不断演化的越狱攻击策略。

核心思路:论文的核心思路是利用LLMs对有害提示的识别能力,设计一个阴影栈来检测用户提示中的有害内容,从而触发相应的防御机制。

技术框架:整体架构包括两个主要部分:阴影栈和正常栈。阴影栈负责并行检查用户提示中的有害内容,正常栈则在检测到有害提示时进行相应的处理。

关键创新:最重要的技术创新在于通过阴影栈的设计,实现了对有害提示的实时检测和响应,显著提升了防御的有效性和效率。与现有方法相比,SELFDEFEND能够在不影响正常用户体验的情况下,提供强有力的防御。

关键设计:在设计中,关键参数包括阴影栈的检查频率和正常栈的响应机制。此外,损失函数的设计也考虑了对有害提示的识别精度,以确保防御的准确性。整体网络结构经过优化,以实现快速响应和低延迟。

🖼️ 关键图片

fig_0
fig_1

📊 实验亮点

实验结果显示,SELFDEFEND在多种越狱攻击场景中均表现出色,能够有效识别并防御所有已知的越狱攻击。与基线模型相比,SELFDEFEND的防御延迟几乎可以忽略不计,且对正常用户提示的响应时间影响微乎其微,确保了用户体验的流畅性。

🎯 应用场景

该研究的潜在应用领域包括大型语言模型的安全防护、对抗性攻击的防御机制以及智能助手的安全性提升。通过有效防御越狱攻击,SELFDEFEND能够在实际应用中保护用户数据安全,提升用户信任度,具有重要的实际价值和未来影响。

📄 摘要(原文)

Jailbreaking is an emerging adversarial attack that bypasses the safety alignment deployed in off-the-shelf large language models (LLMs). A considerable amount of research exists proposing more effective jailbreak attacks, including the recent Greedy Coordinate Gradient (GCG) attack, jailbreak template-based attacks such as using "Do-Anything-Now" (DAN), and multilingual jailbreak. In contrast, the defensive side has been relatively less explored. This paper proposes a lightweight yet practical defense called SELFDEFEND, which can defend against all existing jailbreak attacks with minimal delay for jailbreak prompts and negligible delay for normal user prompts. Our key insight is that regardless of the kind of jailbreak strategies employed, they eventually need to include a harmful prompt (e.g., "how to make a bomb") in the prompt sent to LLMs, and we found that existing LLMs can effectively recognize such harmful prompts that violate their safety policies. Based on this insight, we design a shadow stack that concurrently checks whether a harmful prompt exists in the user prompt and triggers a checkpoint in the normal stack once a token of "No" or a harmful prompt is output. The latter could also generate an explainable LLM response to adversarial prompts. We demonstrate our idea of SELFDEFEND works in various jailbreak scenarios through manual analysis in GPT-3.5/4. We also list three future directions to further enhance SELFDEFEND.