A Comprehensive Study of Jailbreak Attack versus Defense for Large Language Models

Zihao Xu, Yi Liu, Gelei Deng, Yuekang Li, Stjepan Picek

Presented at ACL 2024, this study provides the first systematic "stress test" of the current Large Language Model (LLM) security landscape. By evaluating nine jailbreak attack techniques against seven defense mechanisms across three major models—Llama-2, Vicuna, and GPT-3.5 Turbo—the researchers reveal a sobering reality: most current defenses are easily bypassed by simple template-based attacks. Furthermore, the inclusion of specific structural tokens can be the primary determinant of whether a model remains secure or becomes compromised.

The Evaluation Gap in LLM Security

As LLMs are integrated into critical infrastructure, from search engines to code assistants, "jailbreaking"—the art of crafting prompts to bypass safety filters—has evolved from a niche hobby into a significant security concern. While numerous papers propose individual attacks or defenses, they often exist in silos. An attack might be tested against an unprotected model, or a defense might be evaluated against a single attack type. This research addresses this evaluation gap by determining how well current defenses hold up against a diverse battery of modern attacks and understanding the trade-offs these defenses impose on model utility.

Systematic Evaluation Framework

The researchers developed a structured framework to categorize and automate the testing of the security landscape. The methodology involves four key stages: baseline selection of techniques, benchmark construction, automated result labeling using a fine-tuned RoBERTa model (92% accuracy), and final evaluation against specific attack and defense metrics.

The systematic workflow for evaluating LLM jailbreak attacks and defenses, covering baseline selection, benchmark construction, result labeling, and evaluation metrics.

Attack and Defense Taxonomies

The study categorizes the landscape into several distinct strategic areas:

  • Attack Categories:
    • Generative: Attacks that evolve dynamically, such as GPTFuzz and PAIR.
  • Template-Based: Utilizing pre-defined "personas" or encoding tricks (e.g., "DAN" style prompts).
  • Training Gaps: Exploiting fundamental weaknesses in model alignment, such as GCG.
  • Defense Categories:
    • Self-Processing: The model is tasked with checking its own output for safety.
  • Additional Helper: Utilizing an auxiliary model to "police" the primary model (e.g., Bergeron).
  • Input Permutation: Modifying input by dropping tokens or swapping words to disrupt malicious patterns (e.g., Smooth-LLM).

Key Insights: Templates vs. Gradients

One of the most significant findings is that "white-box" attacks like GCG, which require access to internal model gradients, often underperform compared to "universal" template-based attacks. Simple, well-crafted human-readable templates proved remarkably resilient and effective across different models.

Attack Performance and Efficiency

On GPT-3.5 Turbo and Vicuna, the GPTFuzz and "78 templates" methods achieved a staggering 100% Attack Success Rate (ASR). As shown in the performance analysis, template-based attacks are not only more successful but also significantly more efficient, requiring fewer queries to compromise a model compared to complex generative methods.

Comparison of Attack Success Rate (ASR) and Efficiency across different models and attack techniques. Template-based and fuzzing attacks show high success rates with varying efficiency.

Structural Vulnerabilities and Trade-offs

  • The [/INST] Security Switch: In Llama-2, the presence of the special token [/INST] (denoting the end of an instruction) acts as a critical variable. Its inclusion can render certain attacks ineffective, while its omission can cause success rates to skyrocket. This suggests jailbreaking often targets a model's structural expectations rather than just semantic content.
  • The "Paranoia" Trade-off: Most defenses suffer from a "Benign Success Rate" (BSR) problem. By being overly aggressive in blocking potential jailbreaks, they frequently refuse to answer harmless, everyday questions, significantly degrading the user experience.
  • Model Resilience: Llama-2 emerged as the most difficult model to compromise. Conversely, Vicuna—despite being a fine-tuned version of Llama—was easier to jailbreak, suggesting that fine-tuning for instruction-following might inadvertently "unlearn" safety guardrails.

Conclusion

The study highlights that the Bergeron method (using an auxiliary model) is currently the most effective defense, maintaining a high Benign Success Rate (98.51%) while keeping successful jailbreaks low. However, this comes at the cost of increased latency and computational expense. Future work must focus on developing lightweight defenses and exploring how other structural markers influence model vulnerability across larger scales.

Summary updated

BibTeX
@inproceedings{xu2024comprehensive,
  author = {Zihao Xu and Yi Liu and Gelei Deng and Yuekang Li and Stjepan Picek},
  title = {{A Comprehensive Study of Jailbreak Attack versus Defense for Large Language Models}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2024},
  doi = {10.18653/v1/2024.findings-acl.443},
}
Figure