GO TO A SECTION

↑ ↓ to navigate · Enter to openExplore all sections →
FDEInterviews logo
arXiv preprint

Universal and Transferable Adversarial Attacks on Aligned Language Models

The 2023 GCG paper optimized adversarial suffixes on open models and tested transfer to ChatGPT, Claude and PaLM-2, showing why refusal evaluations need automated attacks.

Breakdown by FDE Interviews · 11 min read · Updated

About the original · 2023
AUTHORS
Zou, Wang, Carlini, Nasr, Kolter, Fredrikson
FROM
Carnegie Mellon University, Center for AI Safety, Google DeepMind, Bosch Center for AI
PUBLISHED
Jul 2023 · arXiv preprint
IN THIS BREAKDOWN · 10 SECTIONS

You can read 17% of this breakdown.

01

The paper in one minute

By 2023, chat models were trained to refuse harmful requests, and jailbreaks were mostly hand-crafted role-play prompts that took effort and stopped working when patched. Automated attacks on language models had largely failed, because the input is discrete tokens rather than pixels.

This paper made automated attacks work. Greedy Coordinate Gradient (GCG) leaves the user's request unchanged and appends a suffix of 20 tokens. It searches for suffix tokens that make the model's most likely reply begin with an affirmative opening that restates the request; once a reply starts that way, the model tends to continue. Each step uses gradients with respect to the tokens to shortlist promising single-token swaps at every position, evaluates a batch of them exactly, and keeps the best.

Two choices made the result alarming. Optimizing one suffix against many requests at once made it universal: it worked on behaviors it was never optimized for. Optimizing against several open models at once (Vicuna-7B and 13B, plus Guanaco in one run) made it transfer to closed models that were never queried during the search. On 388 held-out behaviors, an ensemble of such suffixes (success if any one works) raised attack success on GPT-3.5 from 1.8% to 86.6%, on GPT-4 from 8.0% to 46.9%, and on Claude-1 from 0% to 47.9%. Claude-2 held at 2.1%.

The authors disclosed the results to the affected companies before publishing and expected the specific examples to stop working.

THE IDEA, VISUALLY
THE ATTACK, AT THE LEVEL OF MECHANISM (SECTION 2) harmful request aligned model refuses harmful request 20 tokens reply starts "Sure, here is" target: an affirmative opening; the model tends to keep going GREEDY COORDINATE GRADIENT, PER STEP token gradients top-256 per slot sample 512 swaps one token each score each exactly forward passes keep the best 500 steps WHY IT TRANSFERS (SECTION 2.3) One suffix, losses summed over 25 behaviors and over Vicuna-7B/13B (+ Guanaco): universal across requests, and it carried over to closed models never queried during search. Vicuna was trained on ChatGPT outputs, which the authors suspect explains the high GPT-3.5 numbers. Suffixes stop transferring if optimized too long (Figure 6) Disclosed to OpenAI, Google, Meta, Anthropic before release TRANSFER, 388 HELD-OUT BEHAVIORS (TABLE 2) GPT-3.5 1.8 86.6 GPT-4 8.0 46.9 Claude-1 0.0 47.9 Claude-2 0.0 2.1 PaLM-2* 0.0 66.0 request alone + ensemble of suffixes * PaLM-2 scored as best of 8 sampled replies WHITE BOX, ONE SUFFIX, 25 BEHAVIORS (TABLE 1) train held-out Vicuna-7B 100% 98% Llama-2-7B-Chat 88% 84% AutoPrompt, Llama-2 36% 35% Exact harmful strings, one model: 88% Vicuna-7B, 57% Llama-2 (PEZ and GBDA: 0%). Results describe 2023 model versions; they are not claims about today's models.
An optimizer appends tokens to a refused request until the model's reply starts affirmatively. Searched across several open models at once, the suffix transferred to closed ones it never queried.
Research notes: the problem, approach and results
86.6%

GPT-3.5 attack success on 388 held-out behaviors with an ensemble of transferred suffixes (1.8% for the request alone)

84%

held-out success of one suffix optimized on 25 behaviors against Llama-2-7B-Chat (AutoPrompt: 35%)

2.1%

best result against Claude-2, the most robust model tested

THE PROBLEM

Aligned chat models refuse harmful requests, and known jailbreaks were hand-written and brittle; automated search over discrete tokens had mostly failed.

THE IDEA

Greedy Coordinate Gradient (GCG): append 20 tokens to the request and optimize them so the model's reply starts with an affirmative prefix, using token gradients to propose swaps and exact forward passes to choose among them. Sum the objective over many requests and several open models to get one universal suffix.

THE RESULT

On white-box models, one suffix worked on 98% of held-out behaviors for Vicuna-7B and 84% for Llama-2-7B-Chat. Suffixes built on Vicuna and Guanaco transferred to GPT-3.5 (86.6% as an ensemble), GPT-4 (46.9%), Claude-1 (47.9%) and PaLM-2, but rarely to Claude-2 (2.1%).

02

Why it matters to an FDE

You won't run this attack. You will be asked whether a model is "safe enough" for a customer's deployment, and this paper explains why the answer can't rest on a model refusing a list of obviously bad questions.

Safety behavior fails under optimized inputs. The models in the paper refused plain requests almost every time. A search procedure, not human cleverness, found inputs that flipped them, including inputs built on a different model.

Evaluations must be automated and repeated. Hand-written jailbreak lists go stale. Security regression tests belong next to functional tests and should rerun when the model, the prompt template or a guardrail changes.

The defense can't live only in the model. The paper's question is whether post-hoc alignment of a model that can produce harmful content will ever hold against optimizers, as decades of adversarial examples in vision suggest it may not. For an application, that argues for limiting what the model can do and checking what it outputs.

THE FULL BREAKDOWN

Understand the mechanism. Try it on a real problem.

Unlock this breakdown and 157 more papers.

Premium opens every paper in full, plus every answer, concept, course and guide on the site. One payment for six months of access.

6 months · One payment · No auto-renewal

Get Premium · ₹2,000 / $25
  • ◇1 architecture diagram
  • </>1 runnable code experiment
  • ▦2 results tables
  • ?5 interview questions with answers
  1. 03Key takeaways

    The three ingredients, universality, transfer, the protocol caveats and three misreadings

    Free account
  2. 04How it works

    The objective, one GCG step, the universal multi-model loop, AdvBench and the protocol

    Premium
  3. 05The numbers that matter

    Tables 1 and 2 in full, the baselines, and where the text and tables disagree

    Premium
  4. 06Try it yourself

    Check the transfer claims against Table 2, price best-of-8 scoring, and size a regression suite

    Premium
  5. 07Where it breaks

    Dated models, judgment-based scoring, mixed protocols, white-box access and the slips

    Premium
  6. 08Using it on a deployment

    Turning the lesson into regression tests, protocol hygiene and controls outside the model

    Premium
  7. 09Interview angles

    Five questions this paper prepares you for, with answer hints

    Premium
Back to the paper library →