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

1The Chinese University of Hong Kong, 2Princeton University, 3IBM Research

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.

We summarized some recent advances in Jailbreak Attack and Jailbreak Defense in the below table:

GCG

  • Paper: Universal and Transferable Adversarial Attacks on Aligned Language Models
  • Overview: GCG focuses on optimizing adversarial suffixes given inputs. This method employs gradient-based optimizations to tailor the suffixes in a way that induces LLMs to generate harmful outputs for each individual malicious user query. GCG attack outputs the tailored suffixes and append with the each harmful query to form the new jailbreak prompt. Such jailbreak prompts exploit model vulnerabilities, making them a potent tool for generating misaligned responses from even well-aligned models.

AutoDAN

  • Paper: AutoDAN: Generating Stealthy Jailbreak Prompts on Aligned Large Language Models
  • Overview: AutoDAN introduces a dynamic adversarial training framework that continuously adapts to model responses.It utilizes the Genetic Algorithm (GA) and Hierarchical Genetic Algorithm (HGA) to optimize iterative upon a prototype jailbreak prompt and produce high quality jailbreak prompt. Unlike GCG attack, AutoDAN produces interpretable jailbreak prompts.

PAIR

  • Paper: Jailbreaking Black Box Large Language Models in Twenty Queries
  • Overview: PAIR uses an attacker LLM to iteratively generate and refine jailbreak prompts with black-box access to a target LLM. This method demonstrates high efficiency to generate a semantic jailbreak. They bypass the need for extensive human involvement by automating the generation of prompt-level jailbreaks, blending creativity with algorithmic precision.

TAP

Base64

  • Paper: Jailbroken: How Does LLM Safety Training Fail?
  • Overview: This form of attack transform the original malicious user query into the Base64 format representation. It is shown in the work that such a transformation will lead the LLM to produce positive responses for such harmful request.

ICA

  • Paper: Jailbreak and Guard Aligned Language Models with Only Few In-Context Demonstrations
  • Overview: ICA leverages In-Context Learning to manipulate the alignment of LLMs by adding harmful demonstrations within the input prompt. This approach effectively subverts LLMs with strategically crafted examples that coax the model into generating harmful content. ICA demonstrates a unique utilization of in-context examples to significantly alter model behavior without requiring modifications to the model's parameters, showcasing a novel method of influencing LLM safety through minimal yet targeted inputs.

Catastrophic

  • Paper: Catastrophic Jailbreak of Open-source LLMs via Exploiting Generation
  • Overview: This method disrupts LLMs' alignment by tweaking generation configurations, such as decoding hyper-parameters and sampling methods. By altering these configurations, attackers can trigger misaligned responses in safety-tuned models, highlighting a critical vulnerability in current safety evaluation processes. This technique, can be categorized as "Decoding-Based Attack", in which achieving high Attack Success Rate at a fraction of the computational cost.

RPO

Goal Prioritization

Default system Prompt

Self-Reminder

Methodlogy Overview of DPP

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. 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) and attack success rate (ASR) in both LLAMA-2-7B-Chat and Mistral-7B-Instruct-v0.2 models for different defenses.

Demo:

We present a few jailbreak examples of the performance of our trained DPPs under both LLAMA-2-7B-Chat and MISTRAL-7B-Instruct-v0.2 models. Note that some of the response contents contain harmful information.

Examples of DPP performance under different jailbreak attacks (LLAMA-2-7B-Chat);

No Defense LLAMA-2-7B-Chat
LLAMA-2-7B-Chat with DPP

Examples of DPP performance under different jailbreak attacks (MISTRAL-7B-Instruct-v0.2);

No Defense MISTRAL-7B-Instruct-v0.2
MISTRAL-7B-Instruct-v0.2 with DPP

Ethics and Disclosure

  • In the development and presentation of our research paper, which investigates methods for jailbreaking large language models (LLMs) through the use of our proposed Defensive Prompt Patch (DPP), we are committed to adhering to the highest ethical standards. Our research aims to explore the robustness and resilience of LLMs to advanced prompting strategies, thereby contributing to the broader understanding of their vulnerabilities and enhancing their security frameworks.

    Ethical Considerations:

    • Security Research Purpose: The techniques and examples provided in this paper, including the jailbreak prompts demonstrated in the Demo section, are intended solely for academic and security research purposes. Our goal is to assist in the identification and subsequent mitigation of vulnerabilities within LLMs.
    • No Malicious Intent: The jailbreak prompts and methods discussed are not designed or intended for malicious use. They are developed to provide insights into potential security weaknesses, which can be crucial for developers and researchers working on strengthening the defensive capabilities of these models.
    • Responsible Disclosure: Prior to the publication of our findings, we engaged in a responsible disclosure process with the developers of the targeted LLMs. This was to ensure that they were aware of potential vulnerabilities and had the opportunity to address them, thereby minimizing the risk of exploitation.

    Disclosure:

    • Transparency: We disclose that the jailbreak prompts and methods outlined in our paper are theoretical and experimental in nature. While we demonstrate their effectiveness in controlled environments, real-world applications could differ based on various factors including model configurations and updates.
    • Limitations on Use: While we provide detailed descriptions and demonstrations of jailbreaking techniques, we do not endorse or encourage their use outside of a controlled, ethical research environment. We strongly advise against the application of these techniques in any manner that could potentially harm individuals or compromise the integrity and security of any system.
    • Collaboration and Compliance: Our research has been conducted in collaboration with ethical security researchers and with compliance to all relevant legal and ethical guidelines. We emphasize the importance of ongoing collaboration between academia, industry, and security professionals to continue improving the security of LLMs.


BibTeX

@article{park2021nerfies,
  author    = {Park, Keunhong and Sinha, Utkarsh and Barron, Jonathan T. and Bouaziz, Sofien and Goldman, Dan B and Seitz, Steven M. and Martin-Brualla, Ricardo},
  title     = {Nerfies: Deformable Neural Radiance Fields},
  journal   = {ICCV},
  year      = {2021},
}