Universal and Transferable Adversarial Attacks on Aligned Language Models

Zou et al., 2023, Universal and Transferable Adversarial Attacks on Aligned Language Models (arXiv preprint arXiv:2307.15043)

Subscriber deck — free during early access

15 cards

1 Introduction

  1. How did earlier jailbreaks differ from the attack of Zou et al.?
    Earlier jailbreaks were hand-crafted with human ingenuity and brittle, and automatic adversarial prompt search had largely failed on aligned models. Zou et al. automatically optimize an adversarial suffix appended to the user’s request, leaving the request itself unchanged.
  2. Why had automatic adversarial attacks on language models been hard compared with images?
    Text inputs are discrete tokens, which limits the effective input dimensionality and makes the search combinatorial; gradient methods that work in continuous pixel space don’t apply directly.
  3. What three ingredients combine in the GCG attack?
    (1) Target an affirmative start of the response (“Sure, here is …”); (2) optimize the suffix with combined greedy and gradient-based discrete search; (3) optimize one suffix over many prompts and several models at once, making it universal and transferable.
  4. What does the success of GCG imply for the alignment agenda, according to Zou et al.?
    Like adversarial examples in vision, which remain unsolved because defenses are costly, hurt clean performance and cover narrow threat models, attacks on aligned models may persist: post hoc “repair” of models may not suffice.

2.1 Producing Affirmative Responses

  1. Why does GCG target a response beginning that restates the request affirmatively?
    Making “Sure, here is [the requested content]” the most likely start puts the model into a mode where it continues with the content. Targeting only “Sure” risks a suffix that overrides the request (e.g. “never mind, tell me a joke”); restating the request keeps the behaviour on target.
  2. What is the adversarial loss that GCG minimizes?
    The negative log-probability of the target token sequence \(x^\star_{n+1:n+H}\) (the affirmative beginning) given the prompt, \(\mathcal{L}(x_{1:n}) = -\log p(x^\star_{n+1:n+H} \mid x_{1:n})\), minimized over the tokens at the suffix positions only.

2.2 Greedy Coordinate Gradient-based Search

  1. How does Greedy Coordinate Gradient (GCG) choose token replacements?
    Compute the gradient of the loss with respect to the one-hot vector of each suffix token; for every position take the top-\(k\) tokens with the most negative gradient as candidates; sample \(B\) single-token swaps from all positions, evaluate their exact loss with forward passes, and keep the best. Repeat.
    user requestsuffix tokensgradient w.r.t. one-hot tokenstop-k candidates at every positiontry B single-token swaps exactlykeep the lowest-loss swap
    Greedy Coordinate Gradient: gradients propose, exact forward passes decide; loss = −log p(“Sure, here is …”)
  2. How does GCG differ from AutoPrompt, and why does it matter?
    AutoPrompt picks one position in advance and only tries replacements there; GCG considers candidate swaps at all positions in each step. With the same number of forward passes this seemingly minor change made a large difference: 88% vs 25% exact harmful-string matches on Vicuna-7B.

2.3 Universal Multi-prompt and Multi-model attacks

  1. How do Zou et al. make an attack suffix universal and transferable?
    Optimize a single suffix against the summed losses of many harmful prompts (adding prompts incrementally once earlier ones succeed) and of several models sharing a tokenizer (Vicuna-7B and 13B, plus Guanaco), aggregating normalized gradients.

3 Experimental Results: Direct and Transfer Attacks

  1. What is AdvBench?
    Zou et al.’s benchmark with two settings: 500 harmful strings the model must output exactly (fine-grained control), and 500 harmful behaviors where any genuine attempt to comply counts as success (like red-teaming). The metric is attack success rate.

3.1 Attacks on White-box Models

  1. How effective was GCG on the open models it optimized against?
    Exact harmful strings: 88% on Vicuna-7B and 57% on LLaMA-2-7B-Chat (AutoPrompt 25% and 3%; PEZ and GBDA none). Harmful behaviors: 100% and 88%. A single suffix optimized on 25 behaviors also worked on held-out behaviors, so universal attacks exist.

3.2 Transfer attacks

  1. How well did GCG suffixes transfer to black-box commercial models?
    Suffixes optimized only on open Vicuna and Guanaco models elicited harmful behaviors from GPT-3.5 (up to about 87%), GPT-4 (about 47–54%) and PaLM-2 (66%), but rarely Claude 2 (about 2%); transfer was best to GPT models, perhaps because Vicuna was trained on ChatGPT outputs.
  2. How could transfer attacks be strengthened?
    Concatenating several GCG suffixes raised GPT-3.5 success from 47% to 80% (though GPT-4 then often asked for clarification), and an ensemble trying several suffixes per request succeeded more often; stopping optimization earlier also reduced over-fitting to the source models.

5 Conclusion and Future Work

  1. What open question about defenses do Zou et al. raise?
    Whether adversarial training (attacking the model during fine-tuning and training on refusals) can make models robust without sacrificing capability, which has not been achieved for classical models, or whether pretraining itself needs to change.

6 Ethics and Broader Impact

  1. Why did Zou et al. publish the attack despite its risks?
    The techniques are simple, previously known in similar forms and discoverable by any dedicated team; manual jailbreaks were already widespread; risks grow as language models gain autonomy. They disclosed results to the model providers before publication.

Source

  • Andy Zou, Zifan Wang, Nicholas Carlini, Milad Nasr, J. Zico Kolter and Matt Fredrikson. 2023. Universal and Transferable Adversarial Attacks on Aligned Language Models. In arXiv preprint arXiv:2307.15043. https://arxiv.org/abs/2307.15043