Scalable Defense against In-the-wild Jailbreaking Attacks with Safety Context Retrieval

Taiye Chen, Zeming Wei, Ang Li, Yisen Wang
5/21/2025
cs.CRcs.AIcs.CL

No confident code implementation found for this paper.

Abstract

Large Language Models (LLMs) are known to be vulnerable to jailbreaking attacks, wherein adversaries exploit carefully engineered prompts to induce harmful or unethical responses. Such threats have raised critical concerns about the safety and reliability of LLMs in real-world deployment. While existing defense mechanisms partially mitigate such risks, subsequent advancements in adversarial techniques have enabled novel jailbreaking methods to circumvent these protections, exposing the limitations of static defense frameworks. In this work, we explore defending against evolving jailbreaking threats through the lens of context retrieval. First, we conduct a preliminary study demonstrating that even a minimal set of safety-aligned examples against a particular jailbreak can significantly enhance robustness against this attack pattern. Building on this insight, we further leverage the retrieval-augmented generation (RAG) techniques and propose Safety Context Retrieval (SCR), a scalable and robust safeguarding paradigm for LLMs against jailbreaking. Our comprehensive experiments demonstrate how SCR achieves superior defensive performance against both established and emerging jailbreaking tactics, contributing a new paradigm to LLM safety. Our code will be available upon publication.

View on arXivView PDF

Code Implementations

No confident code match yet

We couldn't find an author-owned or strongly-evidenced community implementation for this paper. Any repos shown below are weak matches — verify before relying on them.

No code implementations found yet.

Know of an implementation? Let us know in the comments below!

Similar Papers

Cite this paper

@article{chen2025scalable,
  title  = {Scalable Defense against In-the-wild Jailbreaking Attacks with Safety Context Retrieval},
  author = {Taiye Chen and Zeming Wei and Ang Li and Yisen Wang},
  year   = {2025},
  eprint = {2505.15753},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2505.15753v1}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2505.15753.svg)](https://codeofpaper.com/paper/2505.15753)

Discussion