AttnGCG: Enhancing Jailbreaking Attacks on LLMs with Attention Manipulation

Zijun Wang, Haoqin Tu, Jieru Mei, Bingchen Zhao, Yisen Wang +1 more
10/11/2024
cs.CL

Official code: UCSC-VLAA/AttnGCG-attack (27 stars, MIT, last commit 2025-06-17).

Abstract

This paper studies the vulnerabilities of transformer-based Large Language Models (LLMs) to jailbreaking attacks, focusing specifically on the optimization-based Greedy Coordinate Gradient (GCG) strategy. We first observe a positive correlation between the effectiveness of attacks and the internal behaviors of the models. For instance, attacks tend to be less effective when models pay more attention to system prompts designed to ensure LLM safety alignment. Building on this discovery, we introduce an enhanced method that manipulates models' attention scores to facilitate LLM jailbreaking, which we term AttnGCG. Empirically, AttnGCG shows consistent improvements in attack efficacy across diverse LLMs, achieving an average increase of ~7% in the Llama-2 series and ~10% in the Gemma series. Our strategy also demonstrates robust attack transferability against both unseen harmful goals and black-box LLMs like GPT-3.5 and GPT-4. Moreover, we note our attention-score visualization is more interpretable, allowing us to gain better insights into how our targeted attention manipulation facilitates more effective jailbreaking. We release the code at https://github.com/UCSC-VLAA/AttnGCG-attack.

View on arXivView PDF

Code Implementations(1)

MIT

[TMLR 2025] Official implementation of AttnGCG: Enhancing Jailbreaking Attacks on LLMs with Attention Manipulation

277Shell, PythonOct 7, 20241 years agoMIT
attackattentiongcgjailbreakllm+1 more

Similar Papers

Cite this paper

@article{wang2024attngcg,
  title  = {AttnGCG: Enhancing Jailbreaking Attacks on LLMs with Attention Manipulation},
  author = {Zijun Wang and Haoqin Tu and Jieru Mei and Bingchen Zhao and Yisen Wang and Cihang Xie},
  year   = {2024},
  eprint = {2410.09040},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2410.09040v1}
}

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/2410.09040.svg)](https://codeofpaper.com/paper/2410.09040)

Discussion