Abstract
Recently, Large Language Models (LLMs) have made significant advancements and are now widely used across various domains. Unfortunately, there has been a rising concern that LLMs can be misused to generate harmful or malicious content. Though a line of research has focused on aligning LLMs with human values and preventing them from producing inappropriate content, such alignments are usually vulnerable and can be bypassed by alignment-breaking attacks via adversarially optimized or handcrafted jailbreaking prompts. In this work, we introduce a Robustly Aligned LLM (RA-LLM) to defend against potential alignment-breaking attacks. RA-LLM can be directly constructed upon an existing aligned LLM with a robust alignment checking function, without requiring any expensive retraining or fine-tuning process of the original LLM. Furthermore, we also provide a theoretical analysis for RA-LLM to verify its effectiveness in defending against alignment-breaking attacks. Through real-world experiments on open-source large language models, we demonstrate that RA-LLM can successfully defend against both state-of-the-art adversarial prompts and popular handcrafted jailbreaking prompts by reducing their attack success rates from nearly 100% to around 10% or less.
Introduction
Despite extensive safety training, Large Language Models (LLMs) remain susceptible to "alignment-breaking" attacks. These attacks utilize carefully engineered "jailbreak" prompts—ranging from complex role-play scenarios to gradient-optimized character strings—to bypass safety filters and trick models into generating harmful content.
Existing defense strategies often rely on external safety models to scan every input and output. However, these external checkers are frequently slow, computationally expensive, and prone to false positives, blocking harmless text that happens to contain sensitive keywords. The challenge lies in creating a defense that is robust against sophisticated attacks without degrading the user experience for legitimate queries.
Methodology: Robust Alignment Checking
RA-LLM introduces a "wrapper" defense called Robust Alignment Checking (RAC). Instead of modifying the model's weights through retraining, RA-LLM modifies how the model processes a request by exploiting a fundamental difference between adversarial and benign prompts: adversarial fragility versus benign redundancy.
Adversarial prompts are often highly specific sequences of tokens designed to exploit a model's internal probability space. If even a few random tokens are removed, the "jailbreak" effect typically collapses, and the model's original safety alignment takes over. In contrast, benign requests are semantically redundant; even if a significant portion of the words are removed, the core intent remains clear and safe.
The RA-LLM Process
- Initial Generation: When a request is received, the model generates a standard response.
- Refusal Check: If the initial response is a refusal (e.g., "I'm sorry, I can't assist with that"), the request is blocked immediately.
- Monte Carlo Sampling: If the model provides an answer, RA-LLM creates $n$ versions of the original prompt, each with a percentage of its tokens randomly removed.
- Robust Alignment Check: If the model refuses to answer a significant portion of these "corrupted" prompts, RA-LLM concludes the original prompt was likely a jailbreak and blocks the response.
To maintain efficiency, RA-LLM employs Prefix Checking (generating only the first few tokens of the check responses) and an Early Exit mechanism to stop the check as soon as the failure threshold is met.
Experimental Evaluation
The researchers evaluated RA-LLM using high-stakes benchmarks, including AdvBench (malicious prompts), MS MARCO (real-world benign queries), and 150 handcrafted jailbreaks from jailbreakchat.com.
Key Results
- Attack Success Rate (ASR) Reduction: Against state-of-the-art attacks like GCG, RA-LLM reduced the success rate from nearly 100% to approximately 10%.
- Handcrafted Jailbreaks: For popular human-made jailbreaks, the ASR dropped from 98.4% to 12% on the Vicuna model.
- Minimal Impact on Benign Use: The Benign Answering Rate (BAR) remained high (above 90%), ensuring legitimate users were rarely affected.
- Low Overhead: Due to early exit and prefix checking, the computational tax was less than 20% additional inference time, making it significantly faster than multi-model defense pipelines.
Conclusion and Future Work
RA-LLM demonstrates that a model's existing alignment can be leveraged for self-defense without expensive retraining. While highly effective, the authors note a small "benign tax" where complex but safe prompts are occasionally refused. Future work will focus on tuning the dropping ratio for extreme prompt lengths and investigating adaptive attackers who may attempt to build redundancy into their jailbreak prompts.
Summary updated