BadTemplate: A Training-Free Backdoor Attack via Chat Template Against Large Language Models
Zihan Wang, Hongwei Li, Rui Zhang, Wenbo Jiang, Guowen Xu

TL;DR
This paper introduces BadTemplate, a training-free backdoor attack method that manipulates chat templates in large language models to inject malicious instructions, achieving high success rates and exposing security vulnerabilities.
Contribution
The paper presents a novel, training-free backdoor attack leveraging chat template customizability to embed malicious prompts in LLMs, outperforming traditional methods in effectiveness and ease of deployment.
Findings
Achieves up to 100% attack success rate across multiple datasets and models.
Outperforms traditional prompt-based backdoors in effectiveness.
Detection methods are largely ineffective against BadTemplate.
Abstract
Chat template is a common technique used in the training and inference stages of Large Language Models (LLMs). It can transform input and output data into role-based and templated expressions to enhance the performance of LLMs. However, this also creates a breeding ground for novel attack surfaces. In this paper, we first reveal that the customizability of chat templates allows an attacker who controls the template to inject arbitrary strings into the system prompt without the user's notice. Building on this, we propose a training-free backdoor attack, termed BadTemplate. Specifically, BadTemplate inserts carefully crafted malicious instructions into the high-priority system prompt, thereby causing the target LLM to exhibit persistent backdoor behaviors. BadTemplate outperforms traditional backdoor attacks by embedding malicious instructions directly into the system prompt, eliminating…
Peer Reviews
No public reviews on file for this paper yet. If you reviewed it on a platform where reviews are public (OpenReview, ICLR, NeurIPS, ICML), you can paste yours below so the community can read it here.
Videos
No videos yet. Explain this paper in a talk, walkthrough, or lecture? Add one.
Taxonomy
TopicsAdversarial Robustness in Machine Learning · Topic Modeling · Hate Speech and Cyberbullying Detection
