arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2406.12935cs.CRcs.AIcs.LG
收藏

ChatBug:由聊天模板引发的对齐 LLM 的一个通用漏洞

ChatBug: A Common Vulnerability of Aligned LLMs Induced by Chat Templates

University of Washington(华盛顿大学)

Fengqing Jiang, Zhangchen Xu, Luyao Niu, Bill Yuchen Lin, Radha Poovendran

AI总结:

本文揭示聊天模板可被恶意用户利用以绕过对齐 LLM 的安全防护,提出 ChatBug 漏洞及两种攻击,并验证对抗训练的缓解效果与性能代价。

摘要:

大型语言模型(LLM)被期望遵循用户指令并参与对话。增强 LLM 指令遵循能力的技术通常会使用按照预定义聊天模板结构化的数据对其进行微调。尽管聊天模板已被证明能有效优化 LLM 性能,但它们对 LLM 安全对齐的影响仍较少被理解,而这对于大规模安全部署 LLM 至关重要。在本文中,我们研究聊天模板如何影响 LLM 的安全对齐。我们识别出一个由聊天模板引入的通用漏洞,并将其命名为 ChatBug。我们识别 ChatBug 的关键洞见是:聊天模板提供了一种 LLM 必须遵循、但用户不必遵循的刚性格式。因此,恶意用户在提示 LLM 时未必会遵循聊天模板。相反,恶意用户可以利用其对聊天模板的了解,相应地精心构造提示,以绕过 LLM 的安全对齐。我们开发了两种攻击来利用 ChatBug 漏洞。我们证明,恶意用户可以利用八个最先进(SOTA)LLM 的 ChatBug 漏洞,并有效诱导这些模型给出非预期响应。此外,我们表明现有越狱攻击可以利用 ChatBug 来提高其攻击成功率。我们研究了针对 ChatBug 的潜在对策。结果表明,尽管对抗训练能够有效缓解 ChatBug 漏洞,但受害模型会出现显著的性能下降。这些结果凸显了安全对齐与有用性之间的权衡。开发新的指令调优方法以平衡这一权衡,是未来研究中一个开放且关键的方向。

英文摘要:

Large language models (LLMs) are expected to follow instructions from users and engage in conversations. Techniques to enhance LLMs' instruction-following capabilities typically fine-tune them using data structured according to a predefined chat template. Although chat templates are shown to be effective in optimizing LLM performance, their impact on safety alignment of LLMs has been less understood, which is crucial for deploying LLMs safely at scale. In this paper, we investigate how chat templates affect safety alignment of LLMs. We identify a common vulnerability, named ChatBug, that is introduced by chat templates. Our key insight to identify ChatBug is that the chat templates provide a rigid format that need to be followed by LLMs, but not by users. Hence, a malicious user may not necessarily follow the chat template when prompting LLMs. Instead, malicious users could leverage their knowledge of the chat template and accordingly craft their prompts to bypass safety alignments of LLMs. We develop two attacks to exploit the ChatBug vulnerability. We demonstrate that a malicious user can exploit the ChatBug vulnerability of eight state-of-the-art (SOTA) LLMs and effectively elicit unintended responses from these models. Moreover, we show that ChatBug can be exploited by existing jailbreak attacks to enhance their attack success rates. We investigate potential countermeasures to ChatBug. Our results show that while adversarial training effectively mitigates the ChatBug vulnerability, the victim model incurs significant performance degradation. These results highlight the trade-off between safety alignment and helpfulness. Developing new methods for instruction tuning to balance this trade-off is an open and critical direction for future research

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

↑