RL-JACK: Reinforcement Learning-powered Black-box Jailbreaking Attack against LLMs

Xuan Chen, Yuzhou Nie, Lu Yan, Yunshu Mao, Wenbo Guo, Xiangyu ZhangarXiv 2024 · DOI

Introduction

Large Language Models (LLMs) are increasingly deployed in sensitive environments, necessitating robust "safety alignment" to prevent the generation of harmful or unethical content. However, the emergence of "jailbreaking"—the use of adversarial prompts to bypass these safety filters—poses a significant challenge. Current automated jailbreaking techniques typically rely on in-context learning or stochastic genetic algorithms. While effective to an extent, these methods often lack the strategic depth required to breach heavily guarded models or suffer from inefficiencies due to random search patterns.

This paper introduces RL-JACK, a novel black-box jailbreaking framework that leverages Deep Reinforcement Learning (DRL) to systematically discover adversarial prompts. By framing jailbreaking as a sequential decision-making problem, RL-JACK achieves superior effectiveness and efficiency compared to existing state-of-the-art (SOTA) methods.

The RL-JACK Framework

The core of RL-JACK is a reinforcement learning agent trained using Proximal Policy Optimization (PPO). Unlike token-level attacks that face an astronomical search space, RL-JACK operates on a high-level action space facilitated by a helper LLM.

Overview of the RL-JACK framework, illustrating the interaction between the RL agent, helper LLM, and the target model.

Methodology

The framework consists of several key components designed to optimize the search for jailbreaking prompts:

  1. LLM-Facilitated Action Space: The RL agent selects from 10 high-level strategies rather than individual tokens. These strategies include seven context-based actions (e.g., role-playing, scientific mimicry) and three direct modification actions (e.g., rephrasing). A helper LLM (Vicuna-13b) translates these strategic choices into specific prompt variations.
  2. Dense Reward Function: To overcome the "sparse reward" problem common in binary success/failure metrics, RL-JACK employs a continuous reward signal. It calculates the cosine similarity between the target LLM's response and a reference answer provided by an unaligned (unfiltered) model. This allows the agent to learn from "near-misses" and refine its strategy incrementally.
  3. State Continuity via Crossover: To ensure stable learning, the authors implement a crossover operation that blends the previous prompt with the newly generated one. This maintains semantic continuity, preventing the agent from making erratic jumps in the prompt space that could disrupt the optimization process.

Experimental Evaluation

RL-JACK was evaluated against five SOTA baselines, including PAIR, AutoDAN, and GPTFUZZER, across six prominent LLMs. Testing was conducted using AdvBench and a more rigorous subset called Max50, which contains the 50 most difficult questions to jailbreak as determined by a high-performance toxicity classifier.

A primary insight of this research is the superiority of deterministic search over stochastic methods in the context of jailbreaking. Genetic algorithms often explore the prompt space randomly, which is inefficient for finding the rare, complex prompts needed to bypass advanced safety filters. In contrast, RL-JACK's DRL agent learns the underlying "topography" of the search space, enabling a more direct and systematic path to the goal.

Conceptual illustration of deterministic search strategies employed by RL-JACK.

Results and Discussion

RL-JACK demonstrated significant improvements in Attack Success Rate (ASR) and efficiency:

  • Effectiveness: It consistently outperformed baselines, notably achieving a high ASR on Llama2-70b-chat, a model known for its robust safety alignment.
  • Efficiency: The method required fewer iterations to find successful prompts, making its per-query generation time competitive with or better than simpler genetic approaches.
  • Resiliency and Transferability: Prompts generated by RL-JACK appear more natural, successfully bypassing Perplexity filters and decoding-time defenses like RAIN. Furthermore, policies trained on smaller models (e.g., Llama-2-7b) showed strong transferability to larger, more complex models.

Conclusion

RL-JACK represents a significant step forward in adversarial testing for LLMs. By abstracting the attack to high-level strategies and utilizing dense rewards, it provides a powerful tool for researchers to identify and patch vulnerabilities. Future work will explore extending this framework to multi-modal models and incorporating even more sophisticated adversarial strategies.

Summary updated

BibTeX
@misc{chen2024rl,
  author = {Xuan Chen and Yuzhou Nie and Lu Yan and Yunshu Mao and Wenbo Guo and Xiangyu Zhang},
  title = {{RL-JACK: Reinforcement Learning-powered Black-box Jailbreaking Attack against LLMs}},
  year = {2024},
  eprint = {2406.08725},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2406.08725},
}
Figure