arXiv(opens in a new tab)Computer ScienceOct 2023Cited by 39 papers on PaperVantageClassic Paper

Manuscript Offprint

arXiv:2310.08419

Jailbreaking Black Box Large Language Models in Twenty Queries

Patrick Chao, Alexander Robey, Edgar Dobriban, Hamed Hassani, George Pappas, Eric Wong

Abstract

There is growing interest in ensuring that large language models (LLMs) align with human values. However, the alignment of such models is vulnerable to adversarial jailbreaks, which coax LLMs into overriding their safety guardrails. The identification of these vulnerabilities is therefore instrumental in understanding inherent weaknesses and preventing future misuse. To this end, we propose Prompt Automatic Iterative Refinement (PAIR), an algorithm that generates semantic jailbreaks with only black-box access to an LLM. PAIR—which is inspired by social engineering attacks—uses an attacker LLM to automatically generate jailbreaks for a separate targeted LLM without human intervention. In this way, the attacker LLM iteratively queries the target LLM to update and refine a candidate jailbreak. Empirically, PAIR often requires fewer than twenty queries to produce a jailbreak, which is orders of magnitude more efficient than existing algorithms. PAIR also achieves competitive jailbreaking success rates and transferability on open and closed-source LLMs, including GPT-3.5/4, Vicuna, and Gemini.

1 Introduction

Although still at its infancy, the field of study surrounding large language models (LLMs) has shown significant promise in advancing numerous fields, including code generation [1], business analytics [2], and medicine [3]. The strong performance of LLMs is largely due to the fact that they are trained on vast text corpora, which in turn facilitates the generation of realistic text that pertains to a diverse set of topics [4, 5]. However, one drawback of this approach is that these corpora often contain toxic or objectionable content, which, when propagated by an LLM trained on this data, has the propensity to cause harm [6]. For this reason, it has become common practice to implement various mechanisms that “align” the content generated by LLMs with human values [7, 8, 9, 10].

Figure

Figure 1: Prompt- vs. token-level jailbreaks. (Top) A token-level jailbreak generated by GCG [11]. (Bottom) A prompt-level jailbreak generated by PAIR.

Figure

Figure 2: PAIR schematic. PAIR pits an attacker and target LLM against one another; the attacker’s goal is to generate adversarial prompts that jailbreak the target model in as few queries as possible.

Despite these efforts, two classes of so-called jailbreaking attacks have recently been shown to bypass LLM alignment guardrails [12, 13, 14, 15], leading to concerns that LLMs may not yet be suited for wide-scale deployment in safety-critical domains. The first class of prompt-level jailbreaks comprises social-engineering-based, semantically meaningful prompts which elicit objectionable content from LLMs. While effective (see, e.g., [16, 17]), this technique requires creativity, manual dataset curation, and customized human feedback, leading to considerable human time and resource investments. The second class of token-level jailbreaks involves optimizing the set of tokens passed as input to a targeted LLM [18, 19]. While highly effective [11, 20], such attacks require hundreds of thousands of queries to the target model and are often uninterpretable to humans.

Before LLMs can be trusted in safety-critical domains, it is essential that the AI safety community design realistic stress tests that overcome the drawbacks of both prompt- and token-level jailbreaks. To this end, in this paper we aim to strike a balance between the labor-intensive and non-scalable prompt-level jailbreaks with the uninterpretable and query-inefficient token-level jailbreaks. Our approach—which we call Prompt Automatic Iterative Refinement (PAIR)—is designed to systematically and fully automate prompt-level jailbreaks without a human in the loop. At a high level, PAIR pits two black-box LLMs—which we call the attacker and the target—against one another, in that the attacker is instructed to discover candidate prompts which jailbreak the target (see Fig. 2). Our results indicate that PAIR efficiently discovers prompt-level jailbreaks within twenty queries, which represents a more than 250-fold improvement over existing attacks such as GCG [11]. Moreover, the attacks generated by PAIR display strong transferability to other LLMs, which is largely attributable to the human-interpretable nature of its attacks.

Contributions. We propose a new algorithm—which we term PAIR—for efficiently and effectively generating interpretable, prompt-level jailbreaks for black-box LLMs.

  • Efficiency. PAIR is parallelizable, runs on CPU or GPU, and uses orders of magnitudes fewer queries than existing jailbreaks. When attacking Vicuna-17B, on average PAIR finds successful jailbreaks in 34 (wall-clock) seconds using 366MB of CPU memory at a cost of less than $0.03.
  • Effectiveness. PAIR jailbreaks open- and closed-source LLMs; it achieves a jailbreak percentage of 50% for GPT-3.5/4, 88% for Vicuna-13B, and 73% for Gemini-Pro. To the best of our knowledge, PAIR is the first automated jailbreak that has been shown to jailbreak Gemini-Pro.
  • Interpretability. PAIR generates prompt-level semantic jailbreaks that are interpretable to humans and includes interpretable, chain-of-thought improvement assessments. We also find that PAIR jailbreaks are often more transferrable to other LLMs than jailbreaks generated by GCG.

References (52)

Cited by (39)