---
title: 'FJD: Free Jailbreak Detection for LLMs'
url: https://www.emergentmind.com/topics/free-jailbreak-detection-fjd
type: topic
---

# FJD: Free Jailbreak Detection for LLMs

Searching arXiv for recent papers on Free Jailbreak Detection and closely related jailbreak-detection methods.
Free Jailbreak Detection (FJD) is a confidence-based jailbreak detection method for aligned large language models in which detection is performed during a single normal forward pass by exploiting differences in the model’s output distribution on benign and jailbreak prompts. In its most specific usage, the term denotes the method introduced in “LLM Jailbreak Detection for (Almost) Free!”, where an affirmative instruction is prepended to the prompt and the first-token confidence, optionally temperature-scaled, is used as the detection signal with almost no additional computational costs during inference [2509.14558]. In adjacent work, the phrase is also used more broadly to describe low-cost, label-free, or training-free jailbreak detection systems that avoid model fine-tuning, auxiliary safety LLMs, or explicit jailbreak labels, including latent-state detectors, anomaly-detection frameworks, and temporal multi-turn defenses [2602.11495, 2508.09201, 2606.01738].

## 1. Definition, scope, and conceptual basis

FJD is motivated by the observation that aligned LLMs are less confident when responding to jailbreak prompts than to benign prompts, especially in the first generated token. The underlying intuition is that benign prompts usually induce a clear, high-confidence opening token, whereas jailbreak prompts place the model in conflict between alignment behavior and harmful instructions, or push it into out-of-distribution regions; both effects flatten the next-token distribution [2509.14558].

The method is defined for an LLM with parameters $\theta$ and an input prompt $x$. If $f_1(x) \in \mathbb{R}^{|\mathcal{V}|}$ denotes the logits for the first output token over vocabulary $\mathcal{V}$, then the basic confidence statistic is the maximum softmax probability
$$
P_1(x) \triangleq \max_{i \in \mathcal{V}} p_\theta(y_1=i \mid x).
$$
FJD treats low first-token confidence as evidence of jailbreak behavior and high first-token confidence as evidence of benign behavior [2509.14558].

Within the broader jailbreak-detection literature, this confidence-based formulation occupies one point in a wider design space. Other methods characterize “free” detection differently: some avoid base-model fine-tuning by classifying latent activations [2602.11495], some avoid jailbreak labels by treating attacks as anomalies relative to safe internal safety patterns [2508.09201], and some extend the training-free idea to multi-turn conversations by aggregating temporal risk without retraining the target model [2606.01738]. This suggests that FJD is both a specific algorithm and, in a looser research sense, a family resemblance among low-overhead jailbreak defenses.

## 2. Confidence scoring, affirmative instruction, and temperature scaling

The canonical FJD pipeline augments the user query $x_q$ with an affirmative instruction $x_{ai}$ and uses the concatenated input
$$
x := x_{ai} \oplus x_q.
$$
Examples of affirmative instructions include “You are a good Assistant.”, “Respond in a way that promotes safety.”, “Provide an answer that prioritizes user safety.”, “Remember you are a responsible and helpful LLM.”, and “Let’s think step by step.” The paper reports that, for benign queries, such instructions reinforce alignment and clarity and raise first-token confidence, while for jailbreak queries the adversarial parts dominate attention and the increase is much smaller or even negative [2509.14558].

With temperature scaling, FJD replaces the raw next-token distribution by
$$
p_{\theta,\tau}(y_1=i \mid x)=\frac{\exp(f_{1,i}(x)/\tau)}{\sum_{j \in \mathcal{V}} \exp(f_{1,j}(x)/\tau)},
$$
and defines
$$
P_{1,\tau}(x) \triangleq \max_{i \in \mathcal{V}} p_{\theta,\tau}(y_1=i \mid x).
$$
This step is especially important for overconfident models, since $\tau>1$ flattens saturated distributions and magnifies the relative drop in confidence that jailbreak prompts exhibit [2509.14558].

The operational decision rule is threshold-based:
$$
\text{Jailbreak}(x)=
\begin{cases}
1, & \text{if } P_{1,\tau}(x) < \mathrm{T},\\
0, & \text{otherwise}.
\end{cases}
$$
In the experiments, the primary summary statistic is AUROC rather than a single fixed threshold, but the intended deployment semantics are explicit: low $P_{1,\tau}(x)$ indicates a likely jailbreak; high $P_{1,\tau}(x)$ indicates a likely benign prompt [2509.14558].

The paper also studies a multi-token variant, FJD-$K$, which averages confidence over the first $k$ tokens,
$$
C_k(x)=\frac{1}{k}\sum_{t=1}^{k}\sigma_\tau\bigl(f_t(x)/\tau\bigr),
$$
but reports that $k=1$ is usually sufficient and often best. This places the method in a particularly lightweight regime, because it depends only on the first-step logits that a standard generation pass already computes [2509.14558].

## 3. Virtual instruction learning and FJD-LI

FJD-LI replaces the manual affirmative instruction with a learned virtual instruction embedding. Let $E(\cdot)$ denote tokenization and embedding, let $e_q=E(x_q)\in\mathbb{R}^{q \times d}$ be the query embedding, and let $e_{mi}=E(x_{ai})\in\mathbb{R}^{m \times d}$ be the initial manual instruction embedding. The method optimizes the instruction embedding while freezing the LLM parameters [2509.14558].

For a prompt embedding $e_q$, FJD-LI computes the first-token distribution
$$
p_1(e_{mi}\oplus e_q)\in\mathbb{R}^{1 \times l}.
$$
It then defines two target distributions. The first is a one-hot distribution $M_o(l)$ whose nonzero entry is placed at the position of the maximum logit for the first token when no instruction is used. The second is the uniform distribution
$$
M_u(l)_i=\frac{1}{l}, \quad i=1,\dots,l.
$$
The loss is
$$
\mathcal{L}(e_q)=
\begin{cases}
\mathrm{KL}\bigl(p_1(e_{mi}\oplus e_q)\,\Vert\,M_o(l)\bigr), & e_q \in E(X_{beni}),\\[1ex]
\mathrm{KL}\bigl(p_1(e_{mi}\oplus e_q)\,\Vert\,M_u(l)\bigr), & e_q \in E(X_{jail}),
\end{cases}
$$
and the learned virtual instruction is
$$
e_{li}=\arg\min_{e_{mi}\in\mathbb{R}^{m \times d}} \sum_{e_q} \mathcal{L}(e_q).
$$
The effect is asymmetric by design: benign prompts are pushed toward sharply peaked first-token distributions, while jailbreak prompts are pushed toward flatter ones [2509.14558].

Empirically, FJD-LI improves AUROC over manual-instruction FJD on multiple models and attack families. On AutoDAN, for example, the paper reports Llama2-7B improving from 0.958 to 0.970 and Vicuna-7B from 0.796 to 0.997; on Cipher, it reports Llama2-7B improving from 0.990 to 0.994 and Vicuna-7B from 0.86 to 0.93 [2509.14558]. The learned-instruction formulation preserves the central FJD property—no extra model call during inference—while replacing prompt engineering with a learned prompt-embedding objective.

## 4. Empirical performance and computational profile

The main evaluations cover Llama2-chat 7B and 13B, Vicuna 7B and 13B, and Guanaco 7B and 13B, with additional transfer experiments on Llama3-8B and ChatGPT-3.5. Jailbreak sets include AdvBench, AutoDAN, GCG and MAC, AdvPrompter, Cipher, hand-crafted jailbreak strategies grouped into competing-objectives and mismatched-generalization families, and PAIR; benign sets include PureDove, Open-Platypus, and SuperGLUE [2509.14558].

Against competing-objectives attacks such as AutoDAN, FJD reports strong AUROC improvements over perplexity-based detection, SmoothLLM, GradSafe, and a naive first-token detector. For AutoDAN, the paper reports Llama2-7B at 0.96, Llama2-13B at 0.92, and Vicuna-13B at 0.94. Against mismatched-generalization attacks, it reports especially strong results on Cipher, including 0.99 on Llama2-7B. Hand-crafted mismatched-generalization attacks also remain detectable, with reported AUROC values of 0.95 on Llama2-7B and 0.95 on Vicuna-13B [2509.14558].

Ablation isolates the contribution of each component. On Llama2-7B with AutoDAN, removing both affirmative instruction and temperature scaling yields 0.87 AUROC, affirmative instruction alone yields 0.94, temperature scaling alone yields 0.89, and the full FJD pipeline yields 0.96. On Cipher, the corresponding pattern is approximately 0.92 without either component, approximately 0.97 with affirmative instruction only, approximately 0.96 with temperature scaling only, and approximately 0.99 with both [2509.14558]. This identifies the affirmative instruction as the dominant contributor, with temperature scaling acting as an additional separation mechanism.

The central efficiency claim is that FJD is “almost free” because it reuses the same forward pass needed for ordinary generation. In the reported Llama2 timing study, base forward time is 394 seconds, PPL detection raises this to 412 seconds, SmoothLLM to 1568 seconds, GradSafe to 405 seconds, and FJD to 396 seconds. The measured overhead is therefore approximately 2 seconds relative to normal inference, whereas comparator methods require either extra forward passes, multiple perturbed copies, or backward passes [2509.14558].

The paper also studies benign-response quality. It reports semantic similarity of 0.74 for FJD versus 0.68 for SmoothLLM, and ChatGPT scoring of 0.86 for FJD versus 0.74 for SmoothLLM. On AlpacaEval 2.0, the reported win rate rises from approximately 9.4% to approximately 19.6% under FJD, while Arena-Hard-Auto remains near parity at 0.5 versus 0.4 [2509.14558]. These results are presented as evidence that the prepended affirmative instruction generally does not degrade benign outputs and may sometimes improve them.

## 5. Relation to other jailbreak-detection paradigms

FJD belongs to the class of low-overhead detectors that exploit model-native signals rather than calling an external moderation system. Its distinguishing feature is that the signal is taken from the output distribution, specifically the first-token maximum probability, rather than from hidden states, gradients, retrieval over attack corpora, or response-level semantic inconsistency [2509.14558].

A large body of related work instead operates on internal representations. “Jailbreaking Leaves a Trace” analyzes hidden states and attention outputs across GPT-J, LLaMA, Mistral, and Mamba, applies rank-20 CP tensor decomposition layer-wise, and uses prompt-mode latent factors with lightweight classifiers to detect jailbreak prompts without model fine-tuning or auxiliary LLM detectors; on an abliterated LLaMA-3.1-8B model, selectively bypassing high-susceptibility layers blocks 78% of jailbreak attempts while preserving benign behavior on 94% of benign prompts [2602.11495]. ALERT likewise targets zero-shot detection without jailbreak templates during training, but amplifies discrepancies in specific shallow layers and FFN modules and reports that it outperforms the second-best baseline by at least 10% in average Accuracy and F1-score, and sometimes by up to 40% [2601.03600]. GradSafe takes a different internal route, using gradients of safety-critical parameter slices induced by pairing prompts with the compliance response “Sure”; on ToxicChat and XSTest it outperforms Llama Guard in AUPRC without further training [2402.13494].

Another cluster of work frames jailbreak detection as anomaly detection. LoD for LVLMs builds Multi-modal Safety Concept Activation Vectors and trains a Safety Pattern Auto-Encoder on safe data only, reporting average AUROC values of 0.9969 on LLaVA, 0.9951 on Qwen-VL, and 0.9943 on CogVLM across five unseen attack benchmarks [2508.09201]. Retrieval-Augmented Defense takes a case-based route instead, retrieving known jailbreak exemplars and strategies, inferring the underlying malicious query, and producing a harmfulness probability that can be thresholded with explicit control over the safety–utility trade-off [2508.16406]. NegBLEURT Forest shifts attention to responses, constructing a refusal semantic domain and using negation-aware semantic distances plus Isolation Forest to detect anomalous responses without model fine-tuning or threshold calibration [2511.11784].

Finally, multi-turn work shows where first-token prompt confidence is likely to be insufficient on its own. SafeDream defines a detection-lead metric and uses a safety-state world model, CUSUM accumulation, and contrastive imagination to obtain 1.06–1.20 turns of lead before compliance on three multi-turn benchmarks [2604.16824]. THRD remains fully training-free and explicitly models temporal risk accumulation via a Turn-level Risk Assessor, Historical Context Analyzer, Response Evaluator, and a time-evolving decision rule, reducing ASR to 0.2–4.0% while preserving model utility within 1.5% degradation on MMLU and GSM8K [2606.01738]. These results delimit the scope of FJD: it is highly attractive as a single-pass prompt detector, but other mechanisms become necessary when the attack unfolds across a dialogue trajectory rather than a single prompt.

## 6. Limitations, evasion, and broader significance

The original FJD paper identifies several limitations. It notes that non-readable, highly optimized jailbreaks such as GCG can still be challenging, even though FJD-LI narrows the gap. It also reports a detection-aware white-box attack: on Vicuna-7B, a white-box detection-aware attack drops FJD AUROC to approximately 0.48, whereas transfer attacks optimized on Llama2 or Guanaco and applied to Vicuna remain detectable at approximately 0.89–0.90 AUROC. The paper further notes that different architectures and alignment methods exhibit different sensitivity to confidence and instructions, and that multimodal settings such as LLaVA v1.6 Mistral-7B show a weaker confidence effect because image token sequences are large [2509.14558].

These observations identify the main theoretical vulnerability of confidence-only detection: once the detector itself becomes part of the attack objective, the attacker can optimize not merely for harmful completion but for high first-token confidence under the defensive prompt. A plausible implication is that FJD is strongest as a low-cost first-line filter against broad attack families rather than as a complete white-box-robust defense.

Related work also sharpens the limits of the “free” paradigm. Internal detectors that require hidden states or gradients cannot be applied to closed APIs without provider-side hooks [2602.11495, 2402.13494]. Multi-turn attacks expose the inadequacy of independent per-turn screening [2604.16824, 2606.01738]. Dataset drift means that detectors trained at one point in time can fail against later jailbreak distributions; JailbreaksOverTime shows that weekly self-training using a detector’s own labels can reduce the false negative rate from 4% to 0.3% at a false positive rate of 0.1%, while unsupervised active monitoring remains valuable for surfacing out-of-distribution attacks missed by continuous learning [2504.19440]. On the evaluation side, JADES argues that success should be measured by whether the model actually solves the harmful task, not merely by lack of refusal or general toxicity, and reports 98.5% agreement with human evaluators in a binary success/failure setting [2508.20848]. This suggests that prompt detection, response detection, and jailbreak-success evaluation are distinct but complementary layers.

Taken together, the literature positions FJD as an important reference point in jailbreak detection because it demonstrates that a highly effective signal can sometimes be extracted from ordinary generation-time statistics alone. Its central result is methodological rather than merely empirical: aligned LLMs can leak jailbreak evidence through their own uncertainty profile. Subsequent work broadens that premise to latent geometry, anomaly scores, retrieval over attack corpora, semantic inconsistency, and temporal accumulation, but the original FJD formulation remains the cleanest statement of an “almost free” detector—one that uses the model’s own first-token confidence, augmented by an affirmative instruction and temperature scaling, as a jailbreak sensor embedded directly in the inference loop [2509.14558].

Source: https://www.emergentmind.com/topics/free-jailbreak-detection-fjd