ChatBug: A Common Vulnerability of Aligned LLMs Induced by Chat Templates
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
- 2023Fine-tuning Aligned Language Models Compromises Safety, Even When Users Do Not Intend To!5 Oct
- 2023Universal and Transferable Adversarial Attacks on Aligned Language Models27 Jul
Other references · 30
- 2022Training language models to follow instructions with human feedbackcited by 15,712
- 2023Llama 2: Open Foundation and Fine-Tuned Chat Modelscited by 12,865
- 2023Judging LLM-as-a-Judge with MT-Bench and Chatbot Arenacited by 8,393
- 2017Deep reinforcement learning from human preferencescited by 3,846
- 2021Finetuned Language Models Are Zero-Shot Learnerscited by 3,747
- 2022Training a Helpful and Harmless Assistant with Reinforcement Learning from Human Feedbackcited by 3,634
- 2023Jailbroken: How Does LLM Safety Training Fail?cited by 1,565
- 2016Google's Neural Machine Translation System: Bridging the Gap between Human and Machine Translationcited by 1,471
- 2023Jailbreaking Black Box Large Language Models in Twenty Queriescited by 1,326
- 2024Chatbot Arena: An Open Platform for Evaluating LLMs by Human Preferencecited by 1,151
- 2021Fantastically Ordered Prompts and Where to Find Them: Overcoming Few-Shot Prompt Order Sensitivitycited by 1,122
- 2016Adversarial Machine Learning at Scalecited by 934
18 more
- 2023Quantifying Language Models' Sensitivity to Spurious Features in Prompt Design or: How I learned to start worrying about prompt formattingcited by 778
- 2022Ignore Previous Prompt: Attack Techniques For Language Modelscited by 760
- 2024How Johnny Can Persuade LLMs to Jailbreak Them: Rethinking Persuasion to Challenge AI Safety by Humanizing LLMscited by 533
- 2023GPTFUZZER: Red Teaming Large Language Models with Auto-Generated Jailbreak Promptscited by 520
- 2023Jailbreaking ChatGPT via Prompt Engineering: An Empirical Studycited by 478
- 2024Jailbreaking Leading Safety-Aligned LLMs with Simple Adaptive Attackscited by 450
- 2023Catastrophic Jailbreak of Open-source LLMs via Exploiting Generationcited by 439
- 2023DeepInception: Hypnotize Large Language Model to Be Jailbreakercited by 337
- 2024SafeDecoding: Defending against Jailbreak Attacks via Safety-Aware Decodingcited by 233
- 2022Demystifying Prompts in Language Models via Perplexity Estimationcited by 215
- 2024ArtPrompt: ASCII Art-based Jailbreak Attacks against Aligned LLMscited by 197
- 2022Fine-tuning language models to find agreement among humans with diverse preferencescited by 189
- 2023Automatically Auditing Large Language Models via Discrete Optimizationcited by 187
- 2022A New Generation of Perspective API: Efficient Multilingual Character-level Transformerscited by 181
- 2019Build it Break it Fix it for Dialogue Safety: Robustness from Adversarial Human Attackcited by 176
- 2023MART: Improving LLM Safety with Multi-round Automatic Red-Teamingcited by 161
- 2024AdvPrompter: Fast Adaptive Adversarial Prompting for LLMscited by 146
- 2023Bypassing the Safety Training of Open-Source LLMs with Priming Attackscited by 48
Built on by
Citing papers per year: 2025: 19; 2026: 10.
29 papers.
Sort:
By area:
- 2025SafeChain: Safety of Language Models with Long Chain-of-Thought Reasoning Capabilitiescited by 133
- 2025LLMs Encode Harmfulness and Refusal Separatelycited by 75
- 2025ChatInject: Abusing Chat Templates for Prompt Injection in LLM Agentscited by 28
- 2025Jailbreaking Large Language Diffusion Models: Revealing Hidden Safety Flaws in Diffusion-Based Text Generationcited by 24
- 2025To Think or Not to Think: Exploring the Unthinking Vulnerability in Large Reasoning Modelscited by 22
- 2025Can One Domain Help Others? A Data-Centric Study on Multi-Domain Reasoning via Reinforcement Learningcited by 17
- 2025Dialogue Injection Attack: Jailbreaking LLMs through Context Manipulationcited by 13
- 2025One Model Transfer to All: On Robust Jailbreak Prompts Generation against LLMscited by 12
- 2025SoSBench: Benchmarking Safety Alignment on Six Scientific Domainscited by 11
- 2026Prompt Injection as Role Confusioncited by 11
- 2025IP Leakage Attacks Targeting LLM-Based Multi-Agent Systemscited by 8
- 2025Activation Steering for Masked Diffusion Language Modelscited by 7
17 more
- 2026What Matters For Safety Alignment?cited by 6
- 2026Automating Agent Hijacking via Structural Template Injectioncited by 6
- 2025Why Safeguarded Ships Run Aground? Aligned Large Language Models' Safety Mechanisms Tend to Be Anchored in The Template Regioncited by 5
- 2025TurboFuzzLLM: Turbocharging Mutation-based Fuzzing for Effectively Jailbreaking Large Language Models in Practicecited by 5
- 2025Efficiency vs. Alignment: Investigating Safety and Fairness Risks in Parameter-Efficient Fine-Tuning of LLMscited by 4
- 2026Investigating Social Bias Changes in Quantized Language Modelscited by 4
- 2025Misaligned Roles, Misplaced Images: Structural Input Perturbations Expose Multimodal Alignment Blind Spotscited by 3
- 2025User-Assistant Bias in LLMscited by 3
- 2025Teaching Models to Understand (but not Generate) High-risk Datacited by 2
- 2025MetaBreak: Jailbreaking Online LLM Services via Special Token Manipulationcited by 2
- 2025LLM in the Middle: A Systematic Review of Threats and Mitigations to Real-World LLM-based Systemscited by 1
- 2026Turn-Based Structural Triggers: Structure-Conditioned Backdoors in Multi-Turn LLMscited by 0
- 2026Inference-Time Backdoors via Chat Templates: From LLM Supply Chains to Agentic System Compromisecited by 0
- 2026TEMPLATEFUZZ: Fine-Grained Chat Template Fuzzing for Jailbreaking and Red Teaming LLMscited by 0
- 2026Evaluating using Mock Tool Calls to Quarantine Untrusted Prompt Inputscited by 0
- 2026Understanding the Role of Prompt Template in Knowledge Distillation for Safety Alignmentcited by 0
- 2026Same Bytes, Different Authority: Reserved-Token Representations in Chat-Template Prompt Injectioncited by 0
- 2026Same Bytes, Different Authority: Reserved-Token Representations in Chat-Template Prompt Injection28 Sep 2026
- 2026Understanding the Role of Prompt Template in Knowledge Distillation for Safety Alignment25 Sep 2026
- 2026Evaluating using Mock Tool Calls to Quarantine Untrusted Prompt Inputs28 May 2026
- 2026TEMPLATEFUZZ: Fine-Grained Chat Template Fuzzing for Jailbreaking and Red Teaming LLMs14 Apr 2026
- 2026Prompt Injection as Role Confusion22 Feb 2026
- 2026Automating Agent Hijacking via Structural Template Injection18 Feb 2026
- 2026Investigating Social Bias Changes in Quantized Language Models5 Feb 2026
- 2026Inference-Time Backdoors via Chat Templates: From LLM Supply Chains to Agentic System Compromise4 Feb 2026
- 2026Turn-Based Structural Triggers: Structure-Conditioned Backdoors in Multi-Turn LLMs20 Jan 2026
- 2026What Matters For Safety Alignment?7 Jan 2026
- 2025Activation Steering for Masked Diffusion Language Models30 Dec 2025
- 2025Efficiency vs. Alignment: Investigating Safety and Fairness Risks in Parameter-Efficient Fine-Tuning of LLMs1 Nov 2025
17 more
- 2025MetaBreak: Jailbreaking Online LLM Services via Special Token Manipulation11 Oct 2025
- 2025ChatInject: Abusing Chat Templates for Prompt Injection in LLM Agents26 Sep 2025
- 2025LLM in the Middle: A Systematic Review of Threats and Mitigations to Real-World LLM-based Systems12 Sep 2025
- 2025User-Assistant Bias in LLMs16 Aug 2025
- 2025Jailbreaking Large Language Diffusion Models: Revealing Hidden Safety Flaws in Diffusion-Based Text Generation25 Jul 2025
- 2025Can One Domain Help Others? A Data-Centric Study on Multi-Domain Reasoning via Reinforcement Learning23 Jul 2025
- 2025LLMs Encode Harmfulness and Refusal Separately16 Jul 2025
- 2025SoSBench: Benchmarking Safety Alignment on Six Scientific Domains27 May 2025
- 2025One Model Transfer to All: On Robust Jailbreak Prompts Generation against LLMs23 May 2025
- 2025IP Leakage Attacks Targeting LLM-Based Multi-Agent Systems18 May 2025
- 2025Teaching Models to Understand (but not Generate) High-risk Data5 May 2025
- 2025Misaligned Roles, Misplaced Images: Structural Input Perturbations Expose Multimodal Alignment Blind Spots1 Apr 2025
- 2025Dialogue Injection Attack: Jailbreaking LLMs through Context Manipulation11 Mar 2025
- 2025TurboFuzzLLM: Turbocharging Mutation-based Fuzzing for Effectively Jailbreaking Large Language Models in Practice21 Feb 2025
- 2025Why Safeguarded Ships Run Aground? Aligned Large Language Models' Safety Mechanisms Tend to Be Anchored in The Template Region19 Feb 2025
- 2025SafeChain: Safety of Language Models with Long Chain-of-Thought Reasoning Capabilities17 Feb 2025
- 2025To Think or Not to Think: Exploring the Unthinking Vulnerability in Large Reasoning Models16 Feb 2025
- 2025LLMs Encode Harmfulness and Refusal Separatelycited by 75
- 2025Dialogue Injection Attack: Jailbreaking LLMs through Context Manipulationcited by 13
- 2026Prompt Injection as Role Confusioncited by 11
- 2025TurboFuzzLLM: Turbocharging Mutation-based Fuzzing for Effectively Jailbreaking Large Language Models in Practicecited by 5
- 2025MetaBreak: Jailbreaking Online LLM Services via Special Token Manipulationcited by 2
- 2026Turn-Based Structural Triggers: Structure-Conditioned Backdoors in Multi-Turn LLMscited by 0
- 2026TEMPLATEFUZZ: Fine-Grained Chat Template Fuzzing for Jailbreaking and Red Teaming LLMscited by 0
- 2026TEMPLATEFUZZ: Fine-Grained Chat Template Fuzzing for Jailbreaking and Red Teaming LLMs14 Apr 2026
- 2026Prompt Injection as Role Confusion22 Feb 2026
- 2026Turn-Based Structural Triggers: Structure-Conditioned Backdoors in Multi-Turn LLMs20 Jan 2026
- 2025MetaBreak: Jailbreaking Online LLM Services via Special Token Manipulation11 Oct 2025
- 2025LLMs Encode Harmfulness and Refusal Separately16 Jul 2025
- 2025Dialogue Injection Attack: Jailbreaking LLMs through Context Manipulation11 Mar 2025
- 2025TurboFuzzLLM: Turbocharging Mutation-based Fuzzing for Effectively Jailbreaking Large Language Models in Practice21 Feb 2025
- 2025ChatInject: Abusing Chat Templates for Prompt Injection in LLM Agentscited by 28
- 2025IP Leakage Attacks Targeting LLM-Based Multi-Agent Systemscited by 8
- 2026Automating Agent Hijacking via Structural Template Injectioncited by 6
- 2026Inference-Time Backdoors via Chat Templates: From LLM Supply Chains to Agentic System Compromisecited by 0
- 2026Same Bytes, Different Authority: Reserved-Token Representations in Chat-Template Prompt Injectioncited by 0
- 2026Same Bytes, Different Authority: Reserved-Token Representations in Chat-Template Prompt Injection28 Sep 2026
- 2026Automating Agent Hijacking via Structural Template Injection18 Feb 2026
- 2026Inference-Time Backdoors via Chat Templates: From LLM Supply Chains to Agentic System Compromise4 Feb 2026
- 2025ChatInject: Abusing Chat Templates for Prompt Injection in LLM Agents26 Sep 2025
- 2025IP Leakage Attacks Targeting LLM-Based Multi-Agent Systems18 May 2025
- 2025One Model Transfer to All: On Robust Jailbreak Prompts Generation against LLMscited by 12
- 2025SoSBench: Benchmarking Safety Alignment on Six Scientific Domainscited by 11
- 2026What Matters For Safety Alignment?cited by 6
- 2025Why Safeguarded Ships Run Aground? Aligned Large Language Models' Safety Mechanisms Tend to Be Anchored in The Template Regioncited by 5
- 2026Understanding the Role of Prompt Template in Knowledge Distillation for Safety Alignmentcited by 0
- 2026Understanding the Role of Prompt Template in Knowledge Distillation for Safety Alignment25 Sep 2026
- 2026What Matters For Safety Alignment?7 Jan 2026
- 2025SoSBench: Benchmarking Safety Alignment on Six Scientific Domains27 May 2025
- 2025One Model Transfer to All: On Robust Jailbreak Prompts Generation against LLMs23 May 2025
- 2025Why Safeguarded Ships Run Aground? Aligned Large Language Models' Safety Mechanisms Tend to Be Anchored in The Template Region19 Feb 2025
- 2025SafeChain: Safety of Language Models with Long Chain-of-Thought Reasoning Capabilitiescited by 133
- 2025Jailbreaking Large Language Diffusion Models: Revealing Hidden Safety Flaws in Diffusion-Based Text Generationcited by 24
- 2025To Think or Not to Think: Exploring the Unthinking Vulnerability in Large Reasoning Modelscited by 22
- 2025Can One Domain Help Others? A Data-Centric Study on Multi-Domain Reasoning via Reinforcement Learningcited by 17
- 2025Jailbreaking Large Language Diffusion Models: Revealing Hidden Safety Flaws in Diffusion-Based Text Generation25 Jul 2025
- 2025Can One Domain Help Others? A Data-Centric Study on Multi-Domain Reasoning via Reinforcement Learning23 Jul 2025
- 2025SafeChain: Safety of Language Models with Long Chain-of-Thought Reasoning Capabilities17 Feb 2025
- 2025To Think or Not to Think: Exploring the Unthinking Vulnerability in Large Reasoning Models16 Feb 2025
- 2025Activation Steering for Masked Diffusion Language Modelscited by 7
- 2025Activation Steering for Masked Diffusion Language Models30 Dec 2025
- 2025Efficiency vs. Alignment: Investigating Safety and Fairness Risks in Parameter-Efficient Fine-Tuning of LLMscited by 4
- 2026Investigating Social Bias Changes in Quantized Language Modelscited by 4
- 2025User-Assistant Bias in LLMscited by 3
- 2025Teaching Models to Understand (but not Generate) High-risk Datacited by 2
- 2025LLM in the Middle: A Systematic Review of Threats and Mitigations to Real-World LLM-based Systemscited by 1
- 2026Evaluating using Mock Tool Calls to Quarantine Untrusted Prompt Inputscited by 0
- 2026Evaluating using Mock Tool Calls to Quarantine Untrusted Prompt Inputs28 May 2026
- 2026Investigating Social Bias Changes in Quantized Language Models5 Feb 2026
- 2025Efficiency vs. Alignment: Investigating Safety and Fairness Risks in Parameter-Efficient Fine-Tuning of LLMs1 Nov 2025
- 2025LLM in the Middle: A Systematic Review of Threats and Mitigations to Real-World LLM-based Systems12 Sep 2025
- 2025User-Assistant Bias in LLMs16 Aug 2025
- 2025Teaching Models to Understand (but not Generate) High-risk Data5 May 2025
Similar, not cited
Close in wording, no citation either way
- 2024The Dark Side of Function Calling: Pathways to Jailbreaking Large Language Models
- 2024Probing the Safety Response Boundary of Large Language Models via Unsafe Decoding Path Generation
- 2025Speak Easy: Eliciting Harmful Jailbreaks from LLMs with Simple Interactions
- 2023GPT-4 Is Too Smart To Be Safe: Stealthy Chat with LLMs via Cipher
- 2024Emulated Disalignment: Safety Alignment for Large Language Models May Backfire!
- 2026From Prompt Injection to Web Exploitation: Revisiting Classic Vulnerabilities in LLM-Integrated Applications
- 2025Playing the Fool: Jailbreaking LLMs and Multimodal LLMs with Out-of-Distribution Strategy
- 2024Enhancing Prompt Injection Attacks to LLMs via Poisoning Alignment