DiffusionAttacker: Diffusion-Driven Prompt Manipulation for LLM Jailbreak

Hao Wang, Hao Li, Junda Zhu, Xinyuan Wang, Chengwei Pan, Minlie Huang, Lei Sha

TL;DR

This paper introduces DiffusionAttacker, a novel method for jailbreaking Large Language Models (LLMs) by reformulating prompt rewriting as a conditional text generation task using diffusion models. It achieves state-of-the-art attack success rates and prompt diversity by leveraging a diffusion-based generator and a novel attack loss, making LLM jailbreaking more effective and efficient.

What Problem Does This Paper Address?

Large Language Models (LLMs) are increasingly powerful but also susceptible to "jailbreaking," where carefully crafted prompts can elicit harmful or undesirable content, bypassing their safety alignments. Existing jailbreak methods, like appending adversarial suffixes or using prompt templates, often lack diversity, are computationally expensive, and can be predictable. This paper addresses the need for more diverse, efficient, and effective jailbreaking techniques that can better probe LLM vulnerabilities.

Methods

The core of DiffusionAttacker is a sequence-to-sequence (seq2seq) text diffusion model adapted for prompt rewriting. Unlike previous methods that use autoregressive LLMs, this seq2seq diffusion model allows for more flexible modification of tokens during the generation process. The method employs a novel "attack loss" derived from the LLM's internal representations to guide the diffusion model's denoising process. This loss aims to make the rewritten prompt appear "harmless" to an internal classifier, thereby tricking the LLM into producing harmful output. To enable end-to-end gradient-based optimization, the Gumbel-Softmax trick is used for sampling, eliminating the need for computationally expensive iterative token search. The authors also introduce a semantic similarity loss to ensure the rewritten prompt retains the meaning of the original.

Datasets

  • For classifier training: The paper uses a dataset from Zheng et al. (2024).
  • For DiffuSeq pre-training: The PAWS paraphrase dataset and the Wikipedia dataset are used.
  • For harmful prompt data: Advbench (Zou et al., 2023) and Harmbench (Mazeika et al., 2024) are utilized, providing a total of 900 harmful instructions.

Key Insights and Ideas

  • Diffusion Models for Jailbreaking: Applying diffusion models, traditionally used for image generation, to text-based LLM jailbreaking is a novel approach that offers greater flexibility in prompt manipulation.
  • Internal Representation as a Target: Using the LLM's internal hidden states to train a classifier and then optimizing the prompt to fool this classifier is an effective way to bypass safety mechanisms.
  • Gumbel-Softmax for Differentiable Sampling: This technique is crucial for enabling gradient-based optimization in the discrete text space, significantly improving efficiency.
  • Complementing Black-Box Attacks: While DiffusionAttacker requires access to internal states, it can be used to generate more effective prompts that then enhance the performance of existing black-box attack strategies.

Key Results

DiffusionAttacker consistently outperforms baseline methods across various LLMs (including Llama3, Mistral, Vicuna, Qwen2.5, and Alpaca) in terms of:

  • Attack Success Rate (ASR): Achieves significantly higher ASR (e.g., 0.94 ASRprefix and 0.92 ASRgpt on Qwen2.5).
  • Prompt Diversity: Demonstrates superior diversity as measured by Self-BLEU.
  • Fluency: Achieves lower perplexity (PPL) on several models, indicating more fluent prompts.
  • Efficiency: The use of Gumbel-Softmax and DPM-Solver++ leads to significantly faster generation times compared to other optimization-based methods.
  • Robustness: The method shows effectiveness even against preprocessing defenses like paraphrasing, back-translation, self-reminder, and intent analysis.

Limitations and Future Work

  • Computational Cost: While more efficient than iterative search, the method still takes longer to generate prompts compared to direct generation methods due to gradient updates.
  • Model-Specific Pre-training: The DiffuSeq model needs to be pre-trained with a vocabulary similar to the target LLM for effective Gumbel-Softmax sampling.
  • Future Work: The authors aim to improve efficiency, reduce the need for model-specific pre-training, and enhance practicality and scalability.

Summary updated

BibTeX
@inproceedings{wang2025diffusionattacker,
  author = {Hao Wang and Hao Li and Junda Zhu and Xinyuan Wang and Chengwei Pan and Minlie Huang and Lei Sha},
  title = {{DiffusionAttacker: Diffusion-Driven Prompt Manipulation for LLM Jailbreak}},
  booktitle = {Conference on Empirical Methods in Natural Language Processing},
  year = {2025},
}
Figure