Skip to content

SelfDefend: LLMs can defend themselves against jailbreak attacks in a practical waySelfDefend: LLMs Can Defend Themselves against Jailbreaking in a Practical Manner

arXiv· arXiv:2406.05498· USENIX Security 2025· Xunguang Wang, Daoyuan Wu, Zhenlan Ji, Zongjie Li, Pingchuan Ma, Shuai Wang, Yingjiu Li, Yang Liu, Ning Liu, Juergen Rahmel·Indexed by this site · 17 days ago· Originally publishedDefenses
AI summary

Researchers propose a jailbreak defense framework, SelfDefend, which runs a shadow LLM in parallel with the target model to detect jailbreak prompts; the distilled open-source defense model outperforms seven state-of-the-art defenses when protecting multiple mainstream models. The framework draws on the idea of the shadow stack in traditional security against memory overflow attacks, and implements checkpoint-based access control through collaboration between a shadow LLM in a detection state and a target LLM answering normally; its effectiveness is based on the observation that existing LLMs can identify harmful prompts or intent in user queries, which the authors verified against major jailbreak attacks using mainstream GPT-3.5/4. To improve robustness and reduce cost, the team fine-tuned a dedicated open-source defense model via data distillation; when deployed to protect GPT-3.5/4, Claude, Llama-2-7b/13b and Mistral, it performs comparably to the GPT-4-based SelfDefend with significantly lower additional latency. Experiments also show that the distilled model remains robust to adaptive jailbreaks and prompt injection.

Read originalUSENIX Security 2025