Boosting Jailbreak Attack with Momentum

Yihao Zhang, Zeming Wei

TL;DR

Researchers have introduced Momentum Accelerated GCG (MAC), a novel jailbreak attack that significantly enhances the efficiency and success rate of bypassing Large Language Model (LLM) safety filters. By integrating a momentum term into the standard Greedy Coordinate Gradient (GCG) attack, MAC stabilizes the optimization process, achieving higher attack success rates in fewer steps and showing remarkable resilience against common defense mechanisms.

What Problem Does This Paper Address?

Despite extensive safety alignment, LLMs remain vulnerable to "jailbreak" attacks—adversarial prompts designed to elicit harmful or prohibited content. The current state-of-the-art white-box attack, Greedy Coordinate Gradient (GCG), works by optimizing a discrete adversarial suffix (e.g., a string of seemingly random characters) that, when appended to a malicious request, triggers a "Sure, here is..." response from the model.

However, GCG faces two major hurdles:

  1. Efficiency: The optimization process is incredibly slow, often requiring 500+ steps and tens of minutes to attack a single prompt.
  2. Instability: The discrete nature of token search makes the optimization path erratic, especially when trying to craft a "universal" suffix that works across multiple different harmful prompts.

Methods

The authors rethink the jailbreak attack through the lens of classical optimization. They propose MAC, which adapts the concept of momentum from Stochastic Gradient Descent (SGD) to the discrete token search space.

The Core Algorithm

In standard GCG, the attack calculates the gradient of the loss for each token in the suffix and picks new candidates based solely on the current step's gradient. MAC introduces a momentum term ($g$): $$g = \mu g + (1 - \mu) g_t$$ where $g_t$ is the current gradient and $\mu$ is the decay factor.

By maintaining this moving average of gradients, the attack:

  • Stabilizes the search: It reduces the "noise" of individual steps in the discrete token space.
  • Harnesses historical insights: It carries over heuristic information from previous iterations to guide the search toward more effective suffixes.

The authors provide specific algorithms for both individual prompt attacks (Algorithm 2) and multiple prompt attacks (Algorithm 3), where the goal is to find a single universal suffix that works for a whole batch of malicious requests.

An example of a successful jailbreak suffix generated by MAC.

Datasets

The study utilizes AdvBench, a standard benchmark containing hundreds of harmful request prompts (e.g., instructions for illegal acts).

For evaluation, the authors focused on two popular open-source aligned LLMs:

  • Vicuna-7b
  • Mistral-7b

Key Insights and Ideas

  • Momentum as a Stabilizer: The "aha moment" is that momentum, typically used for continuous weight updates in neural networks, is highly effective for discrete coordinate descent in prompt space. It prevents the optimizer from getting stuck in poor local minima caused by the high variance of discrete token gradients.
  • The $\mu=0.6$ Sweet Spot: Through empirical testing, the authors found that a momentum value of $\mu=0.6$ provides the best balance between stability and adaptation. Values too high make the attack sluggish, while values too low (closer to standard GCG) remain unstable.
  • Generalization is Key: Momentum is particularly powerful for universal attacks. By smoothing gradients across different prompts in a training set, MAC crafts suffixes that generalize much better to unseen prompts compared to vanilla GCG.

Key Results

MAC consistently outperforms the baseline GCG across multiple metrics:

  • Higher Success Rates: In multi-prompt scenarios on Vicuna-7b, MAC achieved a 48.6% Average Attack Success Rate (ASR) compared to GCG's 38.1% within just 20 steps. Its Maximum ASR reached 86.1%, a significant jump from GCG's 72.7%.
Comparison of MAC vs. GCG in multi-prompt jailbreak performance.
  • Improved Transferability: Suffixes generated by MAC on one model (e.g., Vicuna) were more effective at attacking a different "black-box" model (e.g., Mistral) than those generated by GCG.
Transferability performance of MAC suffixes across different victim models.
  • Resilience to Defenses: MAC proved much harder to stop. Against a Perplexity (PPL) filter defense, GCG's success rate plummeted to 28%, while MAC maintained a high 76% ASR.
Evaluation of MAC attacks against various LLM defense mechanisms.

Limitations and Future Work

  • Batch Size Constraints: The current multi-prompt implementation uses a batch size of 1 (processing one prompt at a time). The authors suggest that exploring larger batch sizes might further improve the efficiency-stability trade-off.
  • Optimization Diversity: While momentum was the focus, other advanced optimization techniques like Adam or RMSProp remain unexplored in this discrete prompt-tuning context.
  • Model Scale: The experiments were limited to 7B-parameter models. Testing MAC on larger models (e.g., 70B+) would be a logical next step to verify scalability.

Summary updated

BibTeX
@inproceedings{zhang2025boosting,
  author = {Yihao Zhang and Zeming Wei},
  title = {{Boosting Jailbreak Attack with Momentum}},
  booktitle = {IEEE International Conference on Acoustics, Speech and Signal Processing},
  year = {2025},
  url = {https://openreview.net/forum?id=TGXfpb1fXY},
}
Figure