Abstract
Despite the advancements in training Large Language Models (LLMs) with alignment techniques to enhance the safety of generated content, these models remain susceptible to jailbreak, an adversarial attack method that exposes security vulnerabilities in LLMs. Notably, the Greedy Coordinate Gradient (GCG) method has demonstrated the ability to automatically generate adversarial suffixes that jailbreak state-of-the-art LLMs. However, the optimization process involved in GCG is highly time-consuming, rendering the jailbreaking pipeline inefficient. In this paper, we investigate the process of GCG and identify an issue of Indirect Effect, the key bottleneck of the GCG optimization. To this end, we propose the Model Attack Gradient Index GCG (MAGIC), that addresses the Indirect Effect by exploiting the gradient information of the suffix tokens, thereby accelerating the procedure by having less computation and fewer iterations. Our experiments on AdvBench show that MAGIC achieves up to a 1.5x speedup, while maintaining Attack Success Rates (ASR) on par or even higher than other baselines. Our MAGIC achieved an ASR of 74% on the Llama-2 and an ASR of 54% when conducting transfer attacks on GPT-3.5. Code is available at https://github.com/jiah-li/magic.
Introduction
Large Language Models (LLMs) are increasingly integrated into various applications, necessitating robust safety guardrails. Despite techniques like Reinforcement Learning from Human Feedback (RLHF), these models remain vulnerable to "jailbreaking"—adversarial prompts designed to bypass safety filters. The Greedy Coordinate Gradient (GCG) method is a prominent automated jailbreaking technique that searches for an adversarial suffix to append to harmful instructions. However, GCG's optimization process is computationally expensive and slow. This paper identifies the "Indirect Effect" as a primary bottleneck in GCG and introduces MAGIC (Model Attack Gradient Index GCG) to overcome this inefficiency.
The MAGIC Method
The core of MAGIC lies in optimizing the search for adversarial suffixes by leveraging gradient information more effectively. The authors identify that GCG often wastes computation on token coordinates that do not contribute significantly to reducing the adversarial loss—a phenomenon termed the "Indirect Effect."
MAGIC introduces two primary components to the optimization pipeline:
- Gradient-based Index Selection: Instead of a uniform search across the entire suffix, MAGIC analyzes the gradients of suffix tokens. It focuses updates on tokens with positive gradient values, which are more likely to lead to successful jailbreaks, while ignoring "dead weight" tokens with negative gradients.
- Adaptive Multi-Coordinate Update: While standard GCG typically updates one token at a time, MAGIC updates multiple tokens simultaneously. This parallelization allows the attack to converge much faster without sacrificing the quality of the generated adversarial suffix.
Experimental Results
The researchers evaluated MAGIC on the AdvBench dataset, focusing on harmful behaviors and transferability across models.
Efficiency and Success Rate
MAGIC demonstrates significant improvements in both speed and effectiveness. On Llama-2-7b-chat, MAGIC achieved a 1.5x speedup compared to vanilla GCG. Furthermore, the Attack Success Rate (ASR) on Llama-2 increased from 54% with vanilla GCG to 74% with MAGIC.
Transferability
Suffixes optimized using MAGIC on open-source models (like Vicuna) showed remarkable transferability to closed-source "black-box" models. MAGIC achieved a 54% ASR on GPT-3.5 and successfully triggered harmful responses in state-of-the-art models like GPT-4o and Claude-3, albeit with lower success rates (1-3%).
Conclusion and Future Work
MAGIC significantly lowers the computational barrier for jailbreaking LLMs by addressing the Indirect Effect in gradient-based optimization. While this highlights a critical security risk, it also provides a tool for safety researchers to more efficiently test and harden models. Future work includes expanding these techniques to multimodal models and developing more robust defenses against such gradient-based attacks.
Summary updated