Table of Contents
Fetching ...

Defensive Prompt Patch: A Robust and Interpretable Defense of LLMs against Jailbreak Attacks

Chen Xiong, Xiangyu Qi, Pin-Yu Chen, Tsung-Yi Ho

TL;DR

Defensive Prompt Patch (DPP) introduces a suffix-based defense against jailbreak attacks on LLMs, optimized with a Hierarchical Genetic Algorithm to maximize refusal of harmful inputs while preserving benign utility, without re-training the model. Across LLama-2-7B-Chat and Mistral-7B-Instruct-v0.2, DPP achieves markedly lower attack success rates and competitive or superior utility compared with existing defenses, including under adaptive and unseen attacks. The approach yields transparent, human-readable prompts and demonstrates generalization across multiple models (including Vicuna and Llama-3) and attack families, highlighting practical impact for deploying safer LLM services. Limitations include computational cost of DPP training and potential susceptibility when open-weight models allow removal of prompts; future work targets efficiency, cross-model robustness, and broader safety guarantees.

Abstract

Safety, security, and compliance are essential requirements when aligning large language models (LLMs). However, many seemingly aligned LLMs are soon shown to be susceptible to jailbreak attacks. These attacks aim to circumvent the models' safety guardrails and security mechanisms by introducing jailbreak prompts into malicious queries. In response to these challenges, this paper introduces Defensive Prompt Patch (DPP), a novel prompt-based defense mechanism specifically designed to protect LLMs against such sophisticated jailbreak strategies. Unlike previous approaches, which have often compromised the utility of the model for the sake of safety, DPP is designed to achieve a minimal Attack Success Rate (ASR) while preserving the high utility of LLMs. Our method uses strategically designed interpretable suffix prompts that effectively thwart a wide range of standard and adaptive jailbreak techniques. Empirical results conducted on LLAMA-2-7B-Chat and Mistral-7B-Instruct-v0.2 models demonstrate the robustness and adaptability of DPP, showing significant reductions in ASR with negligible impact on utility. Our approach not only outperforms existing defense strategies in balancing safety and functionality, but also provides a scalable and interpretable solution applicable to various LLM platforms.

Defensive Prompt Patch: A Robust and Interpretable Defense of LLMs against Jailbreak Attacks

TL;DR

Defensive Prompt Patch (DPP) introduces a suffix-based defense against jailbreak attacks on LLMs, optimized with a Hierarchical Genetic Algorithm to maximize refusal of harmful inputs while preserving benign utility, without re-training the model. Across LLama-2-7B-Chat and Mistral-7B-Instruct-v0.2, DPP achieves markedly lower attack success rates and competitive or superior utility compared with existing defenses, including under adaptive and unseen attacks. The approach yields transparent, human-readable prompts and demonstrates generalization across multiple models (including Vicuna and Llama-3) and attack families, highlighting practical impact for deploying safer LLM services. Limitations include computational cost of DPP training and potential susceptibility when open-weight models allow removal of prompts; future work targets efficiency, cross-model robustness, and broader safety guarantees.

Abstract

Safety, security, and compliance are essential requirements when aligning large language models (LLMs). However, many seemingly aligned LLMs are soon shown to be susceptible to jailbreak attacks. These attacks aim to circumvent the models' safety guardrails and security mechanisms by introducing jailbreak prompts into malicious queries. In response to these challenges, this paper introduces Defensive Prompt Patch (DPP), a novel prompt-based defense mechanism specifically designed to protect LLMs against such sophisticated jailbreak strategies. Unlike previous approaches, which have often compromised the utility of the model for the sake of safety, DPP is designed to achieve a minimal Attack Success Rate (ASR) while preserving the high utility of LLMs. Our method uses strategically designed interpretable suffix prompts that effectively thwart a wide range of standard and adaptive jailbreak techniques. Empirical results conducted on LLAMA-2-7B-Chat and Mistral-7B-Instruct-v0.2 models demonstrate the robustness and adaptability of DPP, showing significant reductions in ASR with negligible impact on utility. Our approach not only outperforms existing defense strategies in balancing safety and functionality, but also provides a scalable and interpretable solution applicable to various LLM platforms.
Paper Structure (50 sections, 12 equations, 5 figures, 45 tables, 12 algorithms)

This paper contains 50 sections, 12 equations, 5 figures, 45 tables, 12 algorithms.

Figures (5)

  • Figure 1: Overview of Defensive Prompt Patch. (a) showcases an example of jailbreak attacks. (b) is the DPP training phase in which the algorithm takes in the refusal and helpful datasets and a prototype of the defense prompt. Then, the algorithm forms the defense prompt population by revising the prototype using LLM. For each of the defense prompts in the population, the algorithm will evaluate the defense and utility scores as detailed in Sec. \ref{['methodology']}. The algorithm keeps editing the defense prompts with low scores using the Hierarchical Genetic Search algorithm. (c) shows the deployment of DPP in the LLM inference phase, by adding the best DPP in (b) (indicated in green patch) to every input query. (d) shows the trade-off graphs between the win-rate (utility) alpaca_eval and attack success rate (ASR) in both Llama-2-7B-Chat and Mistral-7B-Instruct-v0.2 for different defenses.
  • Figure 2: Trade-off plot between Win-Rate and ASR on Llama-2-7B-Chat model
  • Figure 3: Trade-off plot between Win-Rate and ASR on Mistral-7B-Instruct-v0.2 model
  • Figure 4: Trade-off plot between Win-Rate and Adaptive ASR on Llama-2-7B-Chat model
  • Figure 5: Trade-off plot between Win-Rate and Adaptive ASR on Mistral-7B-Instruct-v0.2 model