mlsanityData to 7 Oct 2026

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

arXiv 2406.12935 ↗First posted 17 Jun 2024cs.CR cs.AI cs.LGcited by 29

On the map: LLM alignment / RLHF / preference optimisation → Safety alignment and jailbreak attacks

also in 1 more
Abstract (arXiv)

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

Key facts. Cited by 29 papers in the map (data through 7 Oct 2026). Placed in Safety alignment and jailbreak attacks, one of 10 directions in LLM alignment / RLHF / preference optimisation. Builds on 32 of its 46 references that are in the map. First posted on arXiv 17 Jun 2024.

Builds on

32 of 46 references.

Closest ancestors · 2

Same direction, newest first

  1. 2023Fine-tuning Aligned Language Models Compromises Safety, Even When Users Do Not Intend To!5 Oct
  2. 2023Universal and Transferable Adversarial Attacks on Aligned Language Models27 Jul

Other references · 30

  1. 2022Training language models to follow instructions with human feedbackcited by 15,712
  2. 2023Llama 2: Open Foundation and Fine-Tuned Chat Modelscited by 12,865
  3. 2023Judging LLM-as-a-Judge with MT-Bench and Chatbot Arenacited by 8,393
  4. 2017Deep reinforcement learning from human preferencescited by 3,846
  5. 2021Finetuned Language Models Are Zero-Shot Learnerscited by 3,747
  6. 2022Training a Helpful and Harmless Assistant with Reinforcement Learning from Human Feedbackcited by 3,634
  7. 2023Jailbroken: How Does LLM Safety Training Fail?cited by 1,565
  8. 2016Google's Neural Machine Translation System: Bridging the Gap between Human and Machine Translationcited by 1,471
  9. 2023Jailbreaking Black Box Large Language Models in Twenty Queriescited by 1,326
  10. 2024Chatbot Arena: An Open Platform for Evaluating LLMs by Human Preferencecited by 1,151
  11. 2021Fantastically Ordered Prompts and Where to Find Them: Overcoming Few-Shot Prompt Order Sensitivitycited by 1,122
  12. 2016Adversarial Machine Learning at Scalecited by 934
18 more
  1. 2023Quantifying Language Models' Sensitivity to Spurious Features in Prompt Design or: How I learned to start worrying about prompt formattingcited by 778
  2. 2022Ignore Previous Prompt: Attack Techniques For Language Modelscited by 760
  3. 2024How Johnny Can Persuade LLMs to Jailbreak Them: Rethinking Persuasion to Challenge AI Safety by Humanizing LLMscited by 533
  4. 2023GPTFUZZER: Red Teaming Large Language Models with Auto-Generated Jailbreak Promptscited by 520
  5. 2023Jailbreaking ChatGPT via Prompt Engineering: An Empirical Studycited by 478
  6. 2024Jailbreaking Leading Safety-Aligned LLMs with Simple Adaptive Attackscited by 450
  7. 2023Catastrophic Jailbreak of Open-source LLMs via Exploiting Generationcited by 439
  8. 2023DeepInception: Hypnotize Large Language Model to Be Jailbreakercited by 337
  9. 2024SafeDecoding: Defending against Jailbreak Attacks via Safety-Aware Decodingcited by 233
  10. 2022Demystifying Prompts in Language Models via Perplexity Estimationcited by 215
  11. 2024ArtPrompt: ASCII Art-based Jailbreak Attacks against Aligned LLMscited by 197
  12. 2022Fine-tuning language models to find agreement among humans with diverse preferencescited by 189
  13. 2023Automatically Auditing Large Language Models via Discrete Optimizationcited by 187
  14. 2022A New Generation of Perspective API: Efficient Multilingual Character-level Transformerscited by 181
  15. 2019Build it Break it Fix it for Dialogue Safety: Robustness from Adversarial Human Attackcited by 176
  16. 2023MART: Improving LLM Safety with Multi-round Automatic Red-Teamingcited by 161
  17. 2024AdvPrompter: Fast Adaptive Adversarial Prompting for LLMscited by 146
  18. 2023Bypassing the Safety Training of Open-Source LLMs with Priming Attackscited by 48

Built on by

Cited by year (2026 to 7 Oct)

Citing papers per year: 2025: 19; 2026: 10.

29 papers.

Sort:

By area:

  1. 2025SafeChain: Safety of Language Models with Long Chain-of-Thought Reasoning Capabilitiescited by 133
  2. 2025LLMs Encode Harmfulness and Refusal Separatelycited by 75
  3. 2025ChatInject: Abusing Chat Templates for Prompt Injection in LLM Agentscited by 28
  4. 2025Jailbreaking Large Language Diffusion Models: Revealing Hidden Safety Flaws in Diffusion-Based Text Generationcited by 24
  5. 2025To Think or Not to Think: Exploring the Unthinking Vulnerability in Large Reasoning Modelscited by 22
  6. 2025Can One Domain Help Others? A Data-Centric Study on Multi-Domain Reasoning via Reinforcement Learningcited by 17
  7. 2025Dialogue Injection Attack: Jailbreaking LLMs through Context Manipulationcited by 13
  8. 2025One Model Transfer to All: On Robust Jailbreak Prompts Generation against LLMscited by 12
  9. 2025SoSBench: Benchmarking Safety Alignment on Six Scientific Domainscited by 11
  10. 2026Prompt Injection as Role Confusioncited by 11
  11. 2025IP Leakage Attacks Targeting LLM-Based Multi-Agent Systemscited by 8
  12. 2025Activation Steering for Masked Diffusion Language Modelscited by 7
17 more
  1. 2026What Matters For Safety Alignment?cited by 6
  2. 2026Automating Agent Hijacking via Structural Template Injectioncited by 6
  3. 2025Why Safeguarded Ships Run Aground? Aligned Large Language Models' Safety Mechanisms Tend to Be Anchored in The Template Regioncited by 5
  4. 2025TurboFuzzLLM: Turbocharging Mutation-based Fuzzing for Effectively Jailbreaking Large Language Models in Practicecited by 5
  5. 2025Efficiency vs. Alignment: Investigating Safety and Fairness Risks in Parameter-Efficient Fine-Tuning of LLMscited by 4
  6. 2026Investigating Social Bias Changes in Quantized Language Modelscited by 4
  7. 2025Misaligned Roles, Misplaced Images: Structural Input Perturbations Expose Multimodal Alignment Blind Spotscited by 3
  8. 2025User-Assistant Bias in LLMscited by 3
  9. 2025Teaching Models to Understand (but not Generate) High-risk Datacited by 2
  10. 2025MetaBreak: Jailbreaking Online LLM Services via Special Token Manipulationcited by 2
  11. 2025LLM in the Middle: A Systematic Review of Threats and Mitigations to Real-World LLM-based Systemscited by 1
  12. 2026Turn-Based Structural Triggers: Structure-Conditioned Backdoors in Multi-Turn LLMscited by 0
  13. 2026Inference-Time Backdoors via Chat Templates: From LLM Supply Chains to Agentic System Compromisecited by 0
  14. 2026TEMPLATEFUZZ: Fine-Grained Chat Template Fuzzing for Jailbreaking and Red Teaming LLMscited by 0
  15. 2026Evaluating using Mock Tool Calls to Quarantine Untrusted Prompt Inputscited by 0
  16. 2026Understanding the Role of Prompt Template in Knowledge Distillation for Safety Alignmentcited by 0
  17. 2026Same Bytes, Different Authority: Reserved-Token Representations in Chat-Template Prompt Injectioncited by 0

Similar, not cited

Close in wording, no citation either way

  1. 2024The Dark Side of Function Calling: Pathways to Jailbreaking Large Language Models
  2. 2024Probing the Safety Response Boundary of Large Language Models via Unsafe Decoding Path Generation
  3. 2025Speak Easy: Eliciting Harmful Jailbreaks from LLMs with Simple Interactions
  4. 2023GPT-4 Is Too Smart To Be Safe: Stealthy Chat with LLMs via Cipher
  5. 2024Emulated Disalignment: Safety Alignment for Large Language Models May Backfire!
  6. 2026From Prompt Injection to Web Exploitation: Revisiting Classic Vulnerabilities in LLM-Integrated Applications
  7. 2025Playing the Fool: Jailbreaking LLMs and Multimodal LLMs with Out-of-Distribution Strategy
  8. 2024Enhancing Prompt Injection Attacks to LLMs via Poisoning Alignment