LLM Jailbreak Detection for (Almost) Free!
Preprint
Abstract
Large language models (LLMs) enhance security through alignment when widely used, but remain susceptible to jailbreak attacks capable of producing inappropriate content. Jailbreak detection methods show promise in mitigating jailbreak attacks through the assistance of other models or multiple model inferences. However, existing methods entail significant computational costs. In this paper, we first present a finding that the difference in output distributions between jailbreak and benign prompts can be employed for detecting jailbreak prompts. Based on this finding, we propose a Free Jailbreak Detection (FJD) which prepends an affirmative instruction to the input and scales the logits by temperature to further distinguish between jailbreak and benign prompts through the confidence of the first token. Furthermore, we enhance the detection performance of FJD through the integration of virtual instruction learning. Extensive experiments on aligned LLMs show that our FJD can effectively detect jailbreak prompts with almost no additional computational costs during LLM inference.Keywords
All Related Versions
This publication has 18 references indexed in Scilit:
- Jailbreaking Black Box Large Language Models in Twenty Queries2025
- Boosting Jailbreak Attack with Momentum2025
- Gradient-Based Language Model Red Teaming2024
- DrAttack: Prompt Decomposition and Reconstruction Makes Powerful LLMs Jailbreakers2024
- SafeDecoding: Defending against Jailbreak Attacks via Safety-Aware Decoding2024
- Defending Against Alignment-Breaking Attacks via Robustly Aligned LLM2024
- Defending Large Language Models Against Jailbreaking Attacks Through Goal Prioritization2024
- A Wolf in Sheep’s Clothing: Generalized Nested Jailbreak Prompts can Fool Large Language Models Easily2024
- Defending ChatGPT against jailbreak attack via self-remindersNature Machine Intelligence, 2023
- Multi-step Jailbreaking Privacy Attacks on ChatGPT2023