---
title: "Jailbreaks (LLM) — 越狱"
source: "https://systems-analysis.info/int/Jailbreaks_(LLM)_%E2%80%94_%E8%B6%8A%E7%8B%B1"
wiki: "systems-analysis.info/int"
article: "Jailbreaks_(LLM)_—_越狱"
language: "zh"
categories:
  - "Category:Chinese"
  - "Category:Large language models"
  - "Category:Machine learning"
revision_id: 3310
wiki_created_at: 2026-09-06T23:18:47Z
wiki_modified_at: 2026-09-06T23:18:47Z
downloaded_at: 2026-09-07T22:56:16Z
---

# Jailbreaks (LLM) — 越狱

**越狱**（英文：**Jailbreak**，字面意思是“逃离监狱”）在大型语言模型（LLM）的背景下，是一种旨在绕过内置安全机制和限制，以获取被禁止或潜在有害响应的对抗性攻击<sup>[\[1\]](https://systems-analysis.info/int/Jailbreaks_(LLM)_%E2%80%94_%E8%B6%8A%E7%8B%B1#cite_note-lillog_intro-1)</sup>。越狱是指“通过设计对抗性提示词，诱导模型生成违反使用政策和社会规范的有害响应”<sup>[\[2\]](https://systems-analysis.info/int/Jailbreaks_(LLM)_%E2%80%94_%E8%B6%8A%E7%8B%B1#cite_note-yi_2024_survey-2)</sup>。

越狱攻击所利用的根本漏洞在于 LLM 的一个架构特性：模型无法按类型区分指令和数据，因为系统提示词和用户输入都采用相同的格式——自然语言文本字符串<sup>[\[3\]](https://systems-analysis.info/int/Jailbreaks_(LLM)_%E2%80%94_%E8%B6%8A%E7%8B%B1#cite_note-prompting_guide_vuln-3)</sup>。

## 起源与发展历史

### 早期阶段：提示词注入 (2022)

首次记录到的提示词注入漏洞发现于 2022 年 5 月，当时 **Preamble** 公司的研究人员发现 ChatGPT 易受此类攻击。2022 年 9 月，**Riley Goodside** 独立在 Twitter 上发布了首个公开的 GPT-3 漏洞演示，其中一个著名例子是命令模型忽略之前的指令<sup>[\[4\]](https://systems-analysis.info/int/Jailbreaks_(LLM)_%E2%80%94_%E8%B6%8A%E7%8B%B1#cite_note-ncc_group_history-4)</sup>。

### DAN 时代 (2022–2023)

2022 年中，出现了首批 **“Do Anything Now”** (**DAN**) 提示词，这些提示词是用于角色扮演的指令。其关键创新在于利用角色扮演，通过创建一个不受规则约束的“替代人格”来绕过安全限制<sup>[\[5\]](https://systems-analysis.info/int/Jailbreaks_(LLM)_%E2%80%94_%E8%B6%8A%E7%8B%B1#cite_note-dan_evolution_arxiv-5)</sup>。DAN 的演变催生了带有代币系统（惩罚/奖励机制）和角色维持机制的复杂场景<sup>[\[6\]](https://systems-analysis.info/int/Jailbreaks_(LLM)_%E2%80%94_%E8%B6%8A%E7%8B%B1#cite_note-dan_github-6)</sup>。

### 方法多样化 (2023–2024)

自 2023 年起，针对越狱攻击的综合性学术研究开始兴起。2024 年出现了**多模态攻击**，包括将恶意指令隐藏在图像、音频文件中，以及通过 ASCII 艺术进行视觉提示词注入<sup>[\[7\]](https://systems-analysis.info/int/Jailbreaks_(LLM)_%E2%80%94_%E8%B6%8A%E7%8B%B1#cite_note-hiddenlayer_multimodal-7)</sup>。

### 现代阶段 (2024–2025)

攻击技术持续变得复杂。2024 年 11 月，发现了一种名为**“Time Bandit”**的技术，该技术通过将问题表述为来自历史时期（1800-1900年代），利用 ChatGPT-4o 的时间混淆漏洞<sup>[\[8\]](https://systems-analysis.info/int/Jailbreaks_(LLM)_%E2%80%94_%E8%B6%8A%E7%8B%B1#cite_note-bleeping_computer_time_bandit-8)</sup>。

## 技术方法与分类

攻击可以根据对模型的访问权限进行分类：

- **黑盒攻击**：无法访问模型的内部组件（参数、梯度）。
- **白盒攻击**：可以完全访问模型的参数和梯度<sup>[\[2\]](https://systems-analysis.info/int/Jailbreaks_(LLM)_%E2%80%94_%E8%B6%8A%E7%8B%B1#cite_note-yi_2024_survey-2)</sup>。

### JailbreakRadar 分类法

*JailbreakRadar*（Chu et al., 2024）的分类法划分了六个主要的攻击类别：

1.  **直接攻击：**直接的恶意提示词。
2.  **间接攻击：**多步骤的操纵策略。
3.  **上下文攻击：**利用对话历史记录。
4.  **角色扮演攻击：**模仿角色的技术（例如 DAN）。
5.  **编码攻击：**用于隐藏恶意指令的混淆方法。
6.  **模板攻击：**结构化的对抗性框架<sup>[\[9\]](https://systems-analysis.info/int/Jailbreaks_(LLM)_%E2%80%94_%E8%B6%8A%E7%8B%B1#cite_note-chu_2024_radar-9)</sup>。

### 技术机制

- **对抗性后缀生成 (GCG)：** 由 Zou et al. (2023) 提出的一种方法，可自动生成对抗性后缀（一系列 token），当将其添加到提示词中时，有很高的概率引发恶意响应。该方法使用梯度优化，并展示了高成功率（在 GPT-4 上高达 84%）和模型间的可迁移性<sup>[\[10\]](https://systems-analysis.info/int/Jailbreaks_(LLM)_%E2%80%94_%E8%B6%8A%E7%8B%B1#cite_note-zou_2023_gcg-10)</sup>。
- **多样本越狱：** Anthropic (2024) 的研究表明，攻击的有效性遵循幂律：随着提示词中恶意样本数量的增加，不期望的响应百分比也随之增加<sup>[\[11\]](https://systems-analysis.info/int/Jailbreaks_(LLM)_%E2%80%94_%E8%B6%8A%E7%8B%B1#cite_note-anthropic_many_shot-11)</sup>。

## 防御机制

- **宪法分类器 (Anthropic)：** 基于一套宪法原则过滤输入/输出数据。在受控评估中，该方法将越狱成功率从 86% 降低到 4.4%<sup>[\[12\]](https://systems-analysis.info/int/Jailbreaks_(LLM)_%E2%80%94_%E8%B6%8A%E7%8B%B1#cite_note-mit_tech_review_const_ai-12)</sup>。
- **基于人类反馈的强化学习 (RLHF)：** OpenAI 采用的三阶段训练方法，包括监督微调、奖励模型训练和策略优化，已显示出显著减少有毒内容生成的效果。
- **对抗性训练：** 在越狱攻击样本上训练模型，以提高其鲁棒性。该方法在降低攻击成功率方面的有效性估计为 60-80%<sup>[\[1\]](https://systems-analysis.info/int/Jailbreaks_(LLM)_%E2%80%94_%E8%B6%8A%E7%8B%B1#cite_note-lillog_intro-1)</sup>。
- **多层防御：** 推荐的策略，包括输入数据验证、模型级保护、输出数据监控以及持续的实时监控。

针对大型语言模型的越狱攻击是人工智能安全领域的一个根本性问题，展示了模型能力与模型对齐之间的持续张力。攻击格局不断复杂化，从简单的提示词注入演变为复杂的多模态和自动化攻击。研究表明，目前没有任何一种防御机制能够完全抵御所有的越狱企图。在这一领域取得成功需要对安全研究的持续投入、负责任的披露实践以及研究人员、行业和监管机构的共同努力。

## 外部链接

- <a href="https://www.promptingguide.ai/risks/jailbreaking" class="external text" rel="nofollow">提示词指南：越狱</a>
- <a href="https://github.com/llm-attacks/llm-attacks" class="external text" rel="nofollow">GitHub 上 GCG 攻击的实现仓库</a>

## 参考文献

- Bai, Y. et al. (2022). *Constitutional AI: Harmlessness from AI Feedback*. <a href="https://arxiv.org/abs/2212.08073" class="external text" rel="nofollow">arXiv:2212.08073</a>.
- Zou, A. et al. (2023). *Universal and Transferable Adversarial Attacks on Aligned Language Models*. <a href="https://arxiv.org/abs/2307.15043" class="external text" rel="nofollow">arXiv:2307.15043</a>.
- Shen, X. et al. (2023). *“Do Anything Now”: Characterizing and Evaluating In-The-Wild Jailbreak Prompts on Large Language Models*. <a href="https://arxiv.org/abs/2308.03825" class="external text" rel="nofollow">arXiv:2308.03825</a>.
- Chao, P. et al. (2024). *JailbreakBench: An Open Robustness Benchmark for Jailbreaking Large Language Models*. <a href="https://arxiv.org/abs/2404.01318" class="external text" rel="nofollow">arXiv:2404.01318</a>.
- Liao, Z.; Sun, H. (2024). *AmpleGCG: Learning a Universal and Transferable Generative Model of Adversarial Suffixes for Jailbreaking Both Open and Closed LLMs*. <a href="https://openreview.net/forum?id=UfqzXg95I5" class="external text" rel="nofollow">OpenReview UfqzXg95I5</a>.
- Yi, S. et al. (2024). *Jailbreak Attacks and Defenses Against Large Language Models: A Survey*. <a href="https://arxiv.org/abs/2407.04295" class="external text" rel="nofollow">arXiv:2407.04295</a>.
- Chu, J. et al. (2025). *JailbreakRadar: Comprehensive Assessment of Jailbreak Attacks Against LLMs*. <a href="https://arxiv.org/abs/2402.05668" class="external text" rel="nofollow">arXiv:2402.05668</a>.
- Liu, A. et al. (2025). *PiCo: Jailbreaking Multimodal Large Language Models via Pictorial Code Contextualization*. <a href="https://arxiv.org/abs/2504.01444" class="external text" rel="nofollow">arXiv:2504.01444</a>.
- Ghosal, D. et al. (2025). *Immune: Improving Safety Against Jailbreaks in Multi-modal LLMs via Inference-Time Filtering*. *CVPR 2025*. <a href="https://openaccess.thecvf.com/content/CVPR2025/papers/Ghosal_Immune_Improving_Safety_Against_Jailbreaks_in_Multi-modal_LLMs_via_Inference-Time_CVPR_2025_paper.pdf" class="external text" rel="nofollow">PDF</a>.
- Yan, Q. et al. (2025). *Hidden in Plain Sight: Probing Implicit Reasoning in Multimodal Language Models*. <a href="https://arxiv.org/abs/2506.00258" class="external text" rel="nofollow">arXiv:2506.00258</a>.
- Liu, Y. et al. (2025). *RePD: Defending Jailbreak Attack through a Retrieval-Based Detector*. *Findings of NAACL 2025*. <a href="https://aclanthology.org/2025.findings-naacl.16.pdf" class="external text" rel="nofollow">ACL Anthology</a>.

## 注释

1.  <span id="cite_note-lillog_intro-1">↑ <sup>[1.0](https://systems-analysis.info/int/Jailbreaks_(LLM)_%E2%80%94_%E8%B6%8A%E7%8B%B1#cite_ref-lillog_intro_1-0)</sup> <sup>[1.1](https://systems-analysis.info/int/Jailbreaks_(LLM)_%E2%80%94_%E8%B6%8A%E7%8B%B1#cite_ref-lillog_intro_1-1)</sup> “越狱简史”。*Lil'Log*。<a href="https://lilianweng.github.io/posts/2023-03-15-prompt-engineering/" class="external autonumber" rel="nofollow">[1]</a></span>
2.  <span id="cite_note-yi_2024_survey-2">↑ <sup>[2.0](https://systems-analysis.info/int/Jailbreaks_(LLM)_%E2%80%94_%E8%B6%8A%E7%8B%B1#cite_ref-yi_2024_survey_2-0)</sup> <sup>[2.1](https://systems-analysis.info/int/Jailbreaks_(LLM)_%E2%80%94_%E8%B6%8A%E7%8B%B1#cite_ref-yi_2024_survey_2-1)</sup> Yi, J., et al. “Jailbreak Attacks and Defenses Against Large Language Models: A Comprehensive Survey”。*arXiv:2405.09443*。<a href="https://arxiv.org/abs/2405.09443" class="external autonumber" rel="nofollow">[2]</a></span>
3.  <span id="cite_note-prompting_guide_vuln-3">[↑](https://systems-analysis.info/int/Jailbreaks_(LLM)_%E2%80%94_%E8%B6%8A%E7%8B%B1#cite_ref-prompting_guide_vuln_3-0) “Jailbreaking LLMs”。*Prompting Guide*。<a href="https://www.promptingguide.ai/risks/jailbreaking" class="external autonumber" rel="nofollow">[3]</a></span>
4.  <span id="cite_note-ncc_group_history-4">[↑](https://systems-analysis.info/int/Jailbreaks_(LLM)_%E2%80%94_%E8%B6%8A%E7%8B%B1#cite_ref-ncc_group_history_4-0) “探索提示词注入攻击”。*NCC Group*。<a href="https://research.nccgroup.com/2022/12/05/exploring-prompt-injection-attacks/" class="external autonumber" rel="nofollow">[4]</a></span>
5.  <span id="cite_note-dan_evolution_arxiv-5">[↑](https://systems-analysis.info/int/Jailbreaks_(LLM)_%E2%80%94_%E8%B6%8A%E7%8B%B1#cite_ref-dan_evolution_arxiv_5-0) “Do Anything Now: Characterizing and Evaluating In-The-Wild Jailbreak Prompts on Large Language Models”。*arXiv:2308.03825*。<a href="https://arxiv.org/abs/2308.03825" class="external autonumber" rel="nofollow">[5]</a></span>
6.  <span id="cite_note-dan_github-6">[↑](https://systems-analysis.info/int/Jailbreaks_(LLM)_%E2%80%94_%E8%B6%8A%E7%8B%B1#cite_ref-dan_github_6-0) “0xk1h0/ChatGPT_DAN”。*GitHub*。<a href="https://github.com/0xk1h0/ChatGPT_DAN" class="external autonumber" rel="nofollow">[6]</a></span>
7.  <span id="cite_note-hiddenlayer_multimodal-7">[↑](https://systems-analysis.info/int/Jailbreaks_(LLM)_%E2%80%94_%E8%B6%8A%E7%8B%B1#cite_ref-hiddenlayer_multimodal_7-0) “Hiding in Plain Sight: Multimodal Jailbreaking of Large Language Models”。*HiddenLayer*。<a href="https://hiddenlayer.com/research/multimodal-jailbreaking-of-large-language-models/" class="external autonumber" rel="nofollow">[7]</a></span>
8.  <span id="cite_note-bleeping_computer_time_bandit-8">[↑](https://systems-analysis.info/int/Jailbreaks_(LLM)_%E2%80%94_%E8%B6%8A%E7%8B%B1#cite_ref-bleeping_computer_time_bandit_8-0) “ChatGPT "Time-travel" jailbreak lets you bypass its safety guards”。*BleepingComputer*。<a href="https://www.bleepingcomputer.com/news/security/chatgpt-time-travel-jailbreak-lets-you-bypass-its-safety-guards/" class="external autonumber" rel="nofollow">[8]</a></span>
9.  <span id="cite_note-chu_2024_radar-9">[↑](https://systems-analysis.info/int/Jailbreaks_(LLM)_%E2%80%94_%E8%B6%8A%E7%8B%B1#cite_ref-chu_2024_radar_9-0) Chu, Z., et al. “JailbreakRadar: A Comprehensive Benchmark for Jailbreak Attack and Defense”。*arXiv:2402.12642*。<a href="https://arxiv.org/abs/2402.12642" class="external autonumber" rel="nofollow">[9]</a></span>
10. <span id="cite_note-zou_2023_gcg-10">[↑](https://systems-analysis.info/int/Jailbreaks_(LLM)_%E2%80%94_%E8%B6%8A%E7%8B%B1#cite_ref-zou_2023_gcg_10-0) Zou, A., et al. “Universal and Transferable Adversarial Attacks on Aligned Language Models”。*arXiv:2307.15043*。<a href="https://arxiv.org/abs/2307.15043" class="external autonumber" rel="nofollow">[10]</a></span>
11. <span id="cite_note-anthropic_many_shot-11">[↑](https://systems-analysis.info/int/Jailbreaks_(LLM)_%E2%80%94_%E8%B6%8A%E7%8B%B1#cite_ref-anthropic_many_shot_11-0) “Many-shot Jailbreaking”。*Anthropic*。<a href="https://www.anthropic.com/research/many-shot-jailbreaking" class="external autonumber" rel="nofollow">[11]</a></span>
12. <span id="cite_note-mit_tech_review_const_ai-12">[↑](https://systems-analysis.info/int/Jailbreaks_(LLM)_%E2%80%94_%E8%B6%8A%E7%8B%B1#cite_ref-mit_tech_review_const_ai_12-0) “How we're using 'constitutional AI' to make our models safer”。*MIT Technology Review*。<a href="https://www.technologyreview.com/2023/05/09/1072782/how-were-using-constitutional-ai-to-make-our-models-safer/" class="external autonumber" rel="nofollow">[12]</a></span>
