LIAR: Leveraging Alignment (Best-of-N) to Jailbreak LLMs in Seconds

James Beetham, Souradip Chakraborty, Mengdi Wang, Furong Huang, Amrit Singh Bedi, Mubarak Shah · OpenReview

Abstract

Traditional jailbreaks have successfully exposed vulnerabilities in LLMs, primarily relying on discrete combinatorial optimization, while more recent methods focus on training LLMs to generate adversarial prompts. However, both approaches are computationally expensive and slow, often requiring significant resources to generate a single successful attack. We hypothesize that the inefficiency of these methods arises from an inadequate characterization of the jailbreak problem itself. To address this gap, we approach the jailbreak problem as an alignment problem, leading us to propose LIAR (Leveraging Inference time Alignment to jailbReak), a fast and efficient best-of-N approach tailored for jailbreak attacks. LIAR offers several key advantages: it eliminates the need for additional training, operates in a fully black-box setting, significantly reduces computational overhead, and produces more human-readable adversarial prompts while maintaining competitive attack success rates. Our results demonstrate that a best-of-N approach is a simple yet highly effective strategy for evaluating the robustness of aligned LLMs, achieving attack success rates (ASR) comparable to state-of-the-art methods while offering a 10x improvement in perplexity and a significant speedup in Time-to-Attack, reducing execution time from tens of hours to seconds. Additionally, We also provide sub-optimality guarantees for the proposed LIAR. Our work highlights the potential of efficient, alignment-based jailbreak strategies for assessing and stress-testing AI safety measures.

Introduction

Safety alignment techniques, such as Reinforcement Learning from Human Feedback (RLHF), are the primary defense mechanism used to prevent Large Language Models (LLMs) from generating harmful or unethical content. Despite these safeguards, "jailbreak" attacks—carefully engineered prompts designed to bypass safety filters—remain a significant threat.

Existing jailbreaking methodologies, such as Greedy Coordinate Gradient (GCG) or AutoDAN, typically treat the problem as a discrete combinatorial optimization task. While effective, these methods are computationally intensive, often requiring hours of optimization or specialized training to produce a single successful prompt. Furthermore, they frequently generate "gibberish" suffixes—strings of nonsensical tokens that exhibit high perplexity and are easily detected by automated defenses. This research introduces LIAR (Leveraging Inference-time Alignment to jailbReak), which reframes jailbreaking as an inference-time alignment problem, enabling successful attacks in seconds rather than hours.

Methodology: Jailbreaking as Inference-Time Alignment

The LIAR framework and its performance comparison against state-of-the-art (SoTA) methods in terms of Attack Success Rate and Total Time.

The core innovation of LIAR is the conceptualization of jailbreaking as inference-time misalignment. Instead of performing complex, gradient-based optimization, LIAR utilizes a "Best-of-N" sampling strategy. The process involves three primary steps:

  1. Sampling: A small, off-the-shelf "adversarial prompter" (such as GPT-2) generates $N$ candidate adversarial suffixes for a given harmful query $x$.
  2. Selection: These $N$ candidates are evaluated against the target LLM.
  3. Execution: The system selects the suffix that yields the highest "unsafe reward," effectively finding the sample that most successfully triggers a misaligned response from the target model.

This approach is entirely black-box and training-free. By leveraging the same mathematical principles used to align models for safety—but applying them toward misalignment—LIAR achieves high efficiency. Notably, even a tiny model like GPT-2 (124M parameters) serves as an effective adversarial prompter, outperforming much larger models in speed.

Experimental Results

The researchers evaluated LIAR against several prominent benchmarks, including AdvBench, JailBreakBench, and Do-Not-Answer, testing against models such as LLaMA-2, LLaMA-3, Vicuna, and Mistral-7b.

Speed and Success Rate

As illustrated in the performance metrics, LIAR dramatically reduces the "Time-to-Attack." While state-of-the-art (SoTA) methods may require approximately 22 hours to generate successful prompts, LIAR achieves comparable results in seconds. For instance, at 1000 attempts (@1000), LIAR reaches a near 100% Attack Success Rate (ASR) in roughly 80 seconds. At lower attempt counts, such as @10, the attack is virtually instantaneous (~1 second).

Stealth and Naturalness

Unlike previous optimization-based attacks that produce high-perplexity gibberish, LIAR samples from a pre-trained language model. This ensures that the resulting adversarial prompts are fluent and natural. LIAR achieves a 10x reduction in perplexity compared to GCG, with scores as low as 2.0. This makes LIAR-generated attacks significantly harder to detect using traditional perplexity-based filters.

The "Safety Net" Metric

The study introduces a theoretical metric, $\Delta_{sn}(x)$, to quantify a model's resistance to jailbreaking. A larger "safety net" indicates higher robustness. Experiments revealed that models like LLaMA-2 possess a significantly larger safety net compared to more vulnerable models like Falcon-7b, providing a new way to benchmark AI safety.

Conclusion

LIAR demonstrates that jailbreaking aligned LLMs does not require massive computational resources or complex optimization. By framing the problem as one of inference-time alignment, the Best-of-N strategy provides a simple, fast, and highly effective method for stress-testing AI safety measures. The success of LIAR suggests that future alignment research must move beyond simple filters and focus on robust internal safety mechanisms capable of withstanding high-probability misaligned samples that appear natural to human readers.

Summary updated

BibTeX
@misc{beetham2024liar,
  author = {James Beetham and Souradip Chakraborty and Mengdi Wang and Furong Huang and Amrit Singh Bedi and Mubarak Shah},
  title = {{LIAR: Leveraging Alignment (Best-of-N) to Jailbreak LLMs in Seconds}},
  year = {2024},
  eprint = {2412.05232},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2412.05232},
}
Figure