Universal and Transferable Adversarial Attacks on Aligned Language Models

Andy Zou, Zifan Wang, Nicholas Carlini, Milad Nasr, J. Zico Kolter +1 more
7/27/2023
cs.CLcs.AIcs.CR

No official code found. Best implementation: llm-attacks/llm-attacks (4,738 stars, MIT, last commit 2024-08-02). 1 more below.

Abstract

Because "out-of-the-box" large language models are capable of generating a great deal of objectionable content, recent work has focused on aligning these models in an attempt to prevent undesirable generation. While there has been some success at circumventing these measures -- so-called "jailbreaks" against LLMs -- these attacks have required significant human ingenuity and are brittle in practice. In this paper, we propose a simple and effective attack method that causes aligned language models to generate objectionable behaviors. Specifically, our approach finds a suffix that, when attached to a wide range of queries for an LLM to produce objectionable content, aims to maximize the probability that the model produces an affirmative response (rather than refusing to answer). However, instead of relying on manual engineering, our approach automatically produces these adversarial suffixes by a combination of greedy and gradient-based search techniques, and also improves over past automatic prompt generation methods. Surprisingly, we find that the adversarial prompts generated by our approach are quite transferable, including to black-box, publicly released LLMs. Specifically, we train an adversarial attack suffix on multiple prompts (i.e., queries asking for many different types of objectionable content), as well as multiple models (in our case, Vicuna-7B and 13B). When doing so, the resulting attack suffix is able to induce objectionable content in the public interfaces to ChatGPT, Bard, and Claude, as well as open source LLMs such as LLaMA-2-Chat, Pythia, Falcon, and others. In total, this work significantly advances the state-of-the-art in adversarial attacks against aligned language models, raising important questions about how such systems can be prevented from producing objectionable information. Code is available at github.com/llm-attacks/llm-attacks.

View on arXivView PDF

Code Implementations(2)

MIT

Universal and Transferable Attacks on Aligned Language Models

4,738630Shell, PythonJul 27, 20232 years agoMIT
BrianPulfer/gcgCommunity60%

Minimal custom re-implementation of GCG, proposed in Universal and Transferable Adversarial Attacks on Aligned Language Models.

30Jupyter NotebookApr 24, 20251 years ago

Similar Papers

Cite this paper

@article{zou2023universal,
  title  = {Universal and Transferable Adversarial Attacks on Aligned Language Models},
  author = {Andy Zou and Zifan Wang and Nicholas Carlini and Milad Nasr and J. Zico Kolter and Matt Fredrikson},
  year   = {2023},
  eprint = {2307.15043},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2307.15043v2}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2307.15043.svg)](https://codeofpaper.com/paper/2307.15043)

Discussion