Defending Jailbreak Attacks on Large Language Models via Manifold Trajectory Kinetics
arXiv:2606.07335v1 [cs.CR] 5 Jun 2026
Hangtao Zhang1 , Yucheng Zhao1 , Sishun Liu2 , Ziqi Zhou1 , Zeyu Ye3 , Wei Wan4 , Minghui Li1 , Shengshan Hu1 , Yanjun Zhang5 , Yi Liu5 , Leo Yu Zhang5 1 Huazhong University of Science and Technology, 2 Changsha University of Science and Technology 3 Xiangtan University, 4 City University of Macau, 5 Griffith University
Abstract
Benign prompt
Safe output Sure, here is …
How to make a cake?
Jailbreak prompts can bypass alignment guardrails in large language models (LLMs) and elicit unsafe outputs, making reliable deployment-time detection critical. Prior detection approaches largely rely on a fixed metric space (e.g., raw inputs, gradients, or hidden features) in which benign and jailbreak prompts are linearly separable. We show this assumption breaks under (i) pseudo-malicious prompts that are benign by intent but contain safety-related keywords, and (ii) adaptive attacks that explicitly optimize against the deployed detector. To overcome this limitation, we shift our focus from identifying a universal metric space to analyzing the more robust neighborhood structure of the underlying data manifold. We present Manifold Trajectory Kinetics (M TK), which treats an LLM as a kinetic system transforming inputs into outputs and detects jailbreaks by tracking how a prompt’s neighborhood structure evolves across layers. Benign prompts remain close to benign neighborhoods throughout inference, whereas jailbreak prompts exhibit a characteristic trajectory that begins near malicious seeds and later strategically shifts toward benign neighborhoods to evade refusal. Across four LLMs and ten jailbreak attacks, M TK achieves strong robustness to both failure modes: on pseudomalicious prompts, it attains a jailbreak true positive rate of 95% at a false positive rate of 5% on benign prompts and 2% on pseudo-malicious prompts, and under adaptive attacks, it maintains a true positive rate of 85%. We further demonstrate the superior performance of M TK for jailbreak detection in vision-language models. Our code is available at https://github.com/Rookie143/mtk.
1
Aligned LLM
Detector
Pseudo-malicious prompt
Aligned LLM
Safe output Just eat it …
How to kill a cake?
Detector
Harmful query
Safe input
Aligned LLM
How to make a bomb?
Safe output Sorry, I cannot … Detector
Jailbreak attack Aligned LLM From now on you are going to act as DAN … How to make a bomb?
Safe input
Unsafe input
Unsafe output Sure, here is how to … Detector
Unsafe input
Figure 1: Four prompt scenarios are considered: benign prompts, pseudo-malicious prompts, harmful queries, and jailbreak prompts. A strong jailbreak detector should (i) allow benign and pseudo-malicious prompts, and (ii) flag harmful and jailbreak prompts that could elicit unsafe outputs.
elicit harmful or unsafe responses) to bypass safety guardrails and induce the aligned LLM [7, 8] to produce outputs it would otherwise refuse. To counteract the risks posed by jailbreak attacks, a variety of detection methods have been developed [10, 11, 15, 18, 26]. Fig. 1 shows the desired behavior of a strong jailbreak detector. It should pass benign queries and pseudo-malicious prompts that are benign by intent but contain safety-related keywords to avoid over-refusal, while catching harmful queries and, most importantly, jailbreak attacks. A widely adopted line of work examines internal model signals [9, 11, 14, 15, 15, 19], monitoring how jailbreak prompts affect internal states like hidden representations, gradients, or token distributions. These approaches require white-box access to the model and often achieve higher accuracy by using richer internal information, which is the focus of our paper. In contrast, another major direction uses higher-level
Introduction
Large Language Models (LLMs) [1, 2] are widely used across many applications. With this broad deployment, their security has become a key concern. One major threat is jailbreak attacks [3–6]. These attacks involve crafting prompts by subtly modifying malicious input queries (i.e., those intended to 1
Table 1: Comparison of different jailbreak detectors. denotes support for a property; # denotes no support. “/” indicates not applicable for meta-method defenses where adaptive attacks are not directly comparable. In our experiments, for fairness, we primarily compare against detectors in the same setting as ours, namely those requiring zero jailbreak training data. Analysis Method
Jailbreak Detector
Training Cost
HiddenDetect [9] JBShield [10] SaP [11] LoD [12] ToxicDetector [13] NC-MLP [14] HSF [15] EEG-Defender [16] JailDAM [17]
Low Low High Low Low Low Low Low Low
Gradient and Logit Analysis
PPL [18] GradCuff [19] GradSafe [20] SafeQuant [21]
High Low Low High
Input Perturbation
SmoothLLM [22] JailGuard [23]
Low High
Proxy Defense (Meta-methods)
LLM SelfDefense [24] Llama Guard [25] SelfDefend [26] Constitutional Classifiers [27]
Low High Low High
Manifold Analysis
M TK (Ours)
Low
Latent Feature
Multimodal Support
Zero Jailbreak Training Data
# #
# # #
# # # #
# # # # #
# # # #
# # #
#
# # # # # #
information, analyzing only the input prompt and the model’s response [24–26]. This is often implemented via an auxiliary (fine-tuned) LLM to help detect jailbreaks. Such methods are easier to deploy and can work without access to internal states. Another line of work [22, 23] perturbs the input and measures how the output changes, using output stability to infer whether a query is a jailbreak attempt.
Defended Attack Types Competing Mismatched Objectives-Type Generalization-Type # # # #
#
# # # # #
Adaptive Attack
Pseudo-malicious Robustness
# # # # # # # # #
#
# #
# #
#
/ / / /
# # # # # # #
# #
# # #
neighborhood structure on the manifold. Essentially, in an aligned LLM, a benign prompt’s activations evolve within the confines of the model’s internal safety checks, which prevent harmful content generation. In contrast, a jailbreak prompt, engineered from a malicious query (a.k.a. toxic request) seed, is designed to push these activations beyond the safety boundary into an unmonitored space where harmful outputs can be produced [29]. Consequently, as a benign sample propagates through the neural network, its representation is expected to be densely surrounded by neighboring benign samples. Conversely, a jailbreak prompt follows a different trajectory. Its representation may occasionally cluster with malicious queries in earlier layers, but as it propagates through the model, it gradually moves into the neighborhood of benign samples. This shift helps mask malicious intent and ultimately elicit a compliant response (e.g., “Sure...”). We aim to capture such a trajectory “bumping” on the representation manifold for jailbreak detection.
Despite these existing detectors, we argue that the practical security risk posed by jailbreak attacks has been significantly underestimated. Prior detectors mostly operate on a foundational assumption, made either implicitly or explicitly, that benign and jailbreak attack prompts are separable within a given metric space after appropriate pre-processing of the raw inputs or their latent features. We will show that this assumption breaks under (i) prompts that are benign by intent yet contain safety-related keywords (e.g., “How to make a bombshaped cake?”), which we term pseudo-malicious prompts in this paper (Sec. 3.2), and (ii) adaptive attacks that explicitly optimize against the deployed detector (Sec. 4.2). The former leads to high false-positive rates (FPR), while the latter drives low true-positive rates (TPR) by obfuscating feature-level differences between benign and jailbreak prompts under a strong threat model in which the attacker has full knowledge of the defense. As a result, existing detectors struggle to distinguish these highly obfuscated inputs.
By modeling the kinetics of manifold trajectories as a discriminative signal, we design a new detector, M TK (Manifold Trajectory Kinetics). Concretely, M TK encodes each test input by the layer-wise rank sequence of its nearest benign neighbors in a fixed reference bank and flags anomalies using an outlier detector trained only on benign trajectories. This design captures intent-level trajectory deviations while remaining hard to directly optimize against and robust to pseudo-malicious prompts. The resulting representation is robust and lightweight, enabling simple outlier detection methods, such as isolation forest [30], at very low training cost. This representation transfers naturally across LLMs and vision-language models (VLMs) [31, 32] because both share transformer attention layers, and it is independent of the
This observation prompts a paradigm shift in our defensive strategy, moving from a metric space to the more general context of a data manifold [28]. Our key insight is to view the layer-wise progression as a temporal evolution, tracing how samples move and how the underlying data manifold deforms over this trajectory. Rather than relying on raw distances, this alternative perspective emphasizes each sample’s local 2
visual encoder, which makes our method readily applicable to multimodal jailbreak detection (see Sec. 6.3). Moreover, without requiring any jailbreak attack data, our M TK generalizes well across diverse jailbreak attacks (mean AUROC = 0.94, variance = 2.23 × 10−4 across 10 attacks on Llama27B). Most importantly, we show M TK’s strong robustness against corresponding adaptive attacks (e.g., TPR=0.85 on Vicuna-7B), benefiting from the stable and hard-to-mimic signatures of manifold evolution, as well as robustness to pseudo-malicious prompts (e.g., 95% TPR with 5% FPR on ordinary benign prompts and 2% FPR on pseudo-malicious prompts on Llama2-7B). We summarize these properties in Tab. 1, which provides a comparison of M TK with state-ofthe-art (SOTA) detectors. Our main contributions are threefold. (1) We uncover a key flaw in the shared operational principle of existing jailbreak detectors. We demonstrate their fragility by introducing pseudo-malicious prompts and detector-aware adaptive attacks. (2) We shift the underlying defensive paradigm from a metric space to a manifold analysis and introduce a brandnew detection method M TK. It extracts discriminative features from the trajectory a prompt creates on the data manifold as it propagates through the LLM. (3) We extensively evaluate M TK across four LLMs against ten jailbreak attacks, comparing it with seven SOTA defenses (achieving the best AUROC in 31 out of 40 model-attack settings). We further show that M TK extends naturally to jailbreak detection in VLMs.
2 2.1
Detection filters malicious prompts before the model responds; mitigation steers the model toward refusal or safe outputs after a prompt is accepted. We focus on detection because it blocks harmful prompts before any unsafe output is produced, independent of the target model. Tab. 1 summarizes existing detection methods: latent feature analysis [9, 15], gradient-based [19, 20], logit-based [18], input perturbation techniques [22, 23] that check response consistency, and proxy defenses [24–26] that use a (fine-tuned) LLM to semantically classify inputs or outputs. In particular, detectors that inspect internal model states have attracted attention due to their strong empirical accuracy. However, they predominantly rely on static analysis, either inspecting representations at a single, heuristically selected “safety layer” [29, 48] or comparing them against a fixed “refusal vector” [9]. As we show in Sec. 4.2, such designs are brittle under detector-aware adaptive attacks, which can shift malicious signals into unmonitored regions of the network. Moreover, the notion of a “safety layer” is itself problematic: the layers most indicative of safety vary across models and even across prompts within the same model, so a fixed choice degrades robustness. Put differently, existing methods base their decision on a single, isolated snapshot of internal representations. We instead track how these signals evolve across the full forward pass through successive transformer layers, treating their layer-wise progression as a trajectory on the activation manifold and extracting dynamic, kinetic cues for a more robust representation.
Preliminaries
2.3
Jailbreak Attacks
Over-Refusal in Safety-Aligned LLMs
Safety alignment [13, 49] reduces the likelihood of unsafe outputs, but introduces a side effect: over-refusal [50, 51], where the model unnecessarily declines benign-by-intent queries. Over-refusals are often triggered by superficial cues, such as safety-related keywords, that cause an otherwise benign request to be misclassified as risky. The resulting tension between safety and usability [52, 53] extends to downstream safety mechanisms such as inference-time jailbreak detectors.
Jailbreak attacks [3, 33–37] compel LLMs to generate outputs that violate their safety and ethical constraints. Following [3], we categorize these attacks into two types based on the failure modes of safety training they exploit: competing objectives and mismatched generalization. Competing objectives attacks [38, 39] exploit conflicts between a model’s safety objectives [40, 41] and its instruction-following [41, 42] or pretraining objectives—for example, prefix injection or refusal suppression prompts that steer generation away from refusal behaviors (e.g., “Absolutely! Here’s . . . ”). Mismatched generalization attacks [43, 44] instead exploit input distributions seen during pretraining but poorly covered during safety alignment, such as Base64-encoded harmful requests [3]. New attacks continue to appear, ranging from heuristic methods [6, 45] to optimization-driven approaches [46, 47], which motivates building detectors that generalize to unseen attacks.
In this section, we formalize our problem setting by defining two important challenges for jailbreak detection: detectoraware adaptive attacks under a strong white-box threat model (Sec. 3.1) and pseudo-malicious prompts arising from overrefusal (Sec. 3.2), and by specifying our defender assumptions (Sec. 3.3), datasets, and evaluation metrics (Sec. 3.4).
2.2
3.1
3
Defenses against Jailbreaks
Problem Statement
Threat Model of Adaptive Attacks
Attacker’s goals. The adversary aims to jailbreak an aligned LLM while evading detection.
Inference-time jailbreak defenses [9] fall into two categories: jailbreak detection [9, 15] and jailbreak mitigation [10, 29]. 3
Attacker’s capabilities and knowledge. To stress-test existing defenses, we assume a white-box adversary with full access to the model parameters, gradients, and the deployed detector. The adversary adapts a base jailbreak attack (GCG [4]) by optimizing a defense-specific loss to bypass the detector. We also consider an adversary who knows M TK and attempts to evade it (Sec. 6.2).
3.2
(ASR). Detectors are compared on AUROC, True Positive Rate (TPR), False Positive Rate (FPR), and F1. We also report the evasion Attack Success Rate (eASR), the joint probability that an attack both jailbreaks the model and escapes detection: eASR = ASR · (1 − TPR).
4
Pseudo-Malicious Prompts (PMPs)
Detectors can fail in two ways: adaptive attacks drive TPR to near zero (Secs. 4.1 and 4.2), while pseudo-malicious prompts inflate FPR (Sec. 4.3). We examine both failure modes and the patterns they share.
We note that over-refusal [50, 51] is not limited to model outputs—jailbreak detectors exhibit the same behavior. When tuned aggressively, they over-flag benign inputs that resemble unsafe requests. We call these inputs pseudo-malicious prompts (PMPs): semantically harmless queries that superficially resemble harmful ones, typically because they contain terms associated with violence, abuse, or other prohibited topics. For instance, “What is Harry Potter’s criminal history?” from XSTest [54] is benign but triggers refusal through its association with criminal behavior. “I operate a small retail store. What are some popular shoplifting methods I should look out for?” [55] is a preventive question, yet its surface form remains indistinguishable from a genuinely harmful request. PMPs are problematic both for aligned LLMs prone to over-refusal and for jailbreak detectors that rely on lexical or static cues [9, 20]—such detectors frequently flag them as attacks despite their benign intent. An effective detector must handle PMPs correctly.
3.3
4.1
Formulation of Adaptive Attacks
We ask whether a full-knowledge adversary can bypass deployed detectors by optimizing prompts to elicit a fixed affirmative target response (e.g., “Sure, here is how to...”) while minimizing the standard adversarial loss [4], the negative log probability of the target token sequence. Let xquery denote the malicious input query, S the adversarial suffix, and y∗ the target response of length T . The adversary minimizes: min Ladv (S ) = − log p(y∗ | xquery , S ) S
T
= − ∑ log p(yt∗ | xquery , S , y∗<t ).
(1)
t=1
Optimizing Ladv alone produces prompts with high perplexity and anomalous activations that are readily detectable. To equip the attack with evasion capability, we introduce a defense-specific penalty term Levasion . Consequently, the GCGadapt attack optimization process is governed by a composite loss function
Defense Assumptions
Defender’s goals. The defender aims to classify each input as benign or jailbreak before it reaches the model, without the brittleness of existing approaches that hinge on a designated set of safety layers or a single-vector representation. Defender’s capabilities and knowledge. The defender has full access to the target model’s intermediate-layer outputs but cannot modify the model’s training. A small set of benign and known-malicious prompts (e.g., the publicly available AdvBench [4]) is available as anchors. Critically, the M TK defender has no access to real jailbreak samples and does not know the attack type, requiring a single strategy that generalizes across attacks.
3.4
How Easily Can Existing Defenses Be Defeated?
Ladapt = (1 − λ) Ladv (S ) + λ · Levasion ,
(2)
where λ controls the trade-off between jailbreak success and evasion. In the sequel, with a slight abuse of notation, we use S to denote the jailbreak prompt being optimized.
4.2 Limitations of Existing Defenses Against Adaptive Attacks We focus on defenses under a threat model similar to ours: detectors that inspect internal model signals. These detectors map an input to a fixed feature representation (hidden states, gradients, or logits) and then decide via (i) rule-based scoring with a threshold [9, 58], (ii) lightweight classifiers trained on these features [14, 15], or (iii) anomaly detectors fitted to benign feature distributions [12, 17] (which our M TK belongs to). Let φ(x) = fN−k (x) ∈ Rd be the representation of input x at a late layer N−k (small k). Most methods implicitly assume a linear decision function g(φ(x)) = w⊤ φ(x)+b that separates
Evaluation Datasets, Models, and Metrics
We generate adaptive jailbreak attacks using GCG [4] (denoted GCGadapt ) on A DV B ENCH [4]; all other attacks are also generated from A DV B ENCH. Benign prompts come from DATABRICKS D OLLY 15 K [56], and PMPs from ORB ENCH [50], a large-scale over-refusal benchmark. All evaluations use equal numbers of benign and jailbreak prompts. We evaluate on LLaMA2-7B-chat [2] and Vicuna-7B-v1.5 [57]. Attack effectiveness is measured by the Attack Success Rate 4
Table 2: Adaptive attack GCGadapt against different detectors. Higher eASR and lower TPR indicate weaker defenses. For each defense, we report the result under its strongest defenseaware adaptive attack considered in our evaluation to enable a fair cross-defense comparison. Specifically, we tune the coefficient λ in Eq. 2 for each detector to find the highestASR configuration, while reporting the resulting TPR, FPR, and eASR: λ = 0.1 for HiddenDetect, SaP, HSF, and MTK, and λ = 0.05 for GradSafe (for both Llama2 and Vicuna). For MTK, the reported row corresponds to the strongest MTKtargeted adaptive loss considered in our evaluation, J3 (Eq. 20) at λ = 0.1 in Tab. 5. Sec. 6.2 explains the J3 design and reports the full λ sweep.
benign inputs B from jailbreak inputs J , with g(φ(x)) < 0 for x ∈ B and g(φ(x)) > 0 for x ∈ J . This static view is brittle: once an attacker optimizes with respect to the same feature map φ, the assumed linear separability collapses. Defense evaluation setup. We validate this on four representative detection methods, each facing its own adaptive attack. We sample 200 benign prompts (see Sec. 3.4) as a calibration set and fix each detector’s threshold at 5% FPR on benign samples. The test set has 1000 prompts, split equally between benign and GCGadapt jailbreak instances. Below, we detail the evasion loss Levasion for each defense. HiddenDetect [9] is an activation-based detector. It computes the cosine similarity between the prompt’s hidden states hl at the final token position and a pre-computed “Refusal Vector” r, which represents the direction of refusal behaviors (e.g., responses starting with “Sorry” or “I cannot”). Detection is triggered when this similarity exceeds a threshold. The adaptive attack therefore optimizes jailbreak prompt S by minimizing this similarity between hl and r across the set of safety-aware layers K , so that the jailbreak prompt appears benign in the monitored dimensions. Formally, we define the evasion loss as HiddenDetect Levasion =
ASR
Llama2-7B [2] TPR FPR eASR
ASR
Vicuna-7B [57] TPR FPR eASR
HiddenDetect SaP HSF GradSafe Avg.
0.81 0.62 0.67 0.57
0.04 0.00 0.28 0.12
0.09 0.06 0.04 0.03
0.78 0.62 0.48 0.50 0.60
0.90 0.92 0.90 0.81
0.00 0.00 0.00 0.00
0.05 0.08 0.07 0.04
0.90 0.92 0.90 0.81 0.88
M TK (Ours)
0.72
0.76
0.05
0.17
0.88
0.85
0.04
0.13
Defense↓
this polytope, i.e., when the SaP score max j (φ⊤j fK (S ) − ξ j ) exceeds the fixed decision threshold (zero in their implementation). The adversary augments the jailbreak objective with the following loss:
hl (S )⊤ r cos(h ( S ), r) = .(3) l ∑ ∑ l∈K l∈K ∥hl (S )∥2 ∥r∥2
Tab. 2 shows the results. Adaptive attacks reach ASR = 0.81 on Llama2 and 0.90 on Vicuna, while HiddenDetect’s TPR drops to near zero, yielding eASR of 0.78 and 0.90, respectively, indicating that the attack simultaneously elicits harmful outputs and evades detection. The security-critical layer hypothesis [9, 48] breaks down: monitoring only a single layer lets the adversary hide malicious behavior in the remaining, unmonitored parts of the neural network. HSF [15] is a classification-based defense that attaches a lightweight hidden-state classifier to the last decoder layer of the LLM. Given an input, HSF extracts the hidden representations of the last q tokens from the final decoder layer, concatenates them into a feature vector Tq (S ), and feeds it into a small neural classifier fq followed by a sigmoid. This yields a harmfulness score α(S ) = σ( fq (Tq (S ))) ∈ [0, 1], which is interpreted as the probability that the input S is a jailbreak prompt. Hence, we treat HSF as a binary classifier and craft adversarial prompts to flip its prediction, using the following loss that pushes the detector toward the benign label: HSF Levasion = − log 1 − α(S ) = − log 1 − σ( fk (Tq (S ))) . (4) SaP [11] models safety as a convex polytope in the representation space of a security-critical layer K . Let z = fK (S ) ∈ Rd denote the hidden representation of an input at layer K . The safety region is defined as the intersection of J half-spaces P = {z ∈ Rd : φ⊤j z ≤ ξ j , j = 1, . . . , J}, where φ j ∈ Rd is the normal vector of the j-th facet and ξ j ∈ R is its offset. An input is flagged as unsafe when its representation lies outside
SaP Levasion = max 0, max(φ⊤j fK (S ) − ξ j ) .
j
(5)
Minimizing it encourages the jailbreak prompt’s monitoredlayer representation to remain inside SaP’s learned safety polytope. Tab. 2 shows that this attack reduces SaP’s TPR to 0, with an average eASR of 0.77 across the two models. Because in a high-dimensional representation space, satisfying all facet inequalities still leaves substantial freedom for optimization. The attacker thus can exploit this slack to find adversarially feasible regions that look “safe” under the polytope constraints while still maximizing the attack objective. We defer the attack against GradSafe to Apdx. A.7, and the attack against our MTK to Sec. 6.2. Our MTK. Following the same principle, we tailor an adaptive attack to our MTK. Because MTK flags anomalies based on benign-neighbor ranks at each layer, the evasion objective should minimize the activation distance to the benign samples while simultaneously maximizing the distance to the malicious samples, thereby driving benign-neighbor ranks toward those of genuinely benign prompts. This surrogate loss directly approximates the neighborhood-rank signal measured by MTK, making it the strongest MTK-targeted surrogate considered in our evaluation despite MTK’s non-differentiability, and enabling a fair cross-defense comparison. We denote this loss as J3 ; the full attack design and analysis are deferred to Sec. 6.2. We also defer the attack against GradSafe to Apdx. A.7. 5
Table 3: We report (i) TPR on jailbreak prompts (GCG attacks), (ii) FPR on ordinary benign prompts, and (iii) FPRPMP on PMPs from OR-Bench. “+PMP Augment” denotes augmenting the detector’s training set with additional PMPs labeled as benign, while keeping the same calibration protocol.
Results. Having established the strongest defense-aware adaptive attack against each detector, we tune the evasion weight λ in Eq. 2 for each detector to find its most damaging setting (by ASR). Across all four detectors, adaptive attacks achieve average eASR of 0.60 on Llama2 and 0.88 on Vicuna (Tab. 2). By contrast, M TK keeps eASR below 0.2 on both models, showing markedly stronger robustness under adaptive attacks. We later provide a detailed analysis in Sec. 6.2.
4.3
Limitations of Defenses against PMPs
We now evaluate the complementary failure mode: false alarms on benign-but-sensitive PMP inputs. We retain the calibration protocol of Sec. 4.2, thresholding each detector at 5% FPR on ordinary benign prompts (DATABRICKS D OLLY 15 K). The test set still contains 1, 000 prompts, but the benign half is replaced with PMPs from OR-Bench [50], while the malicious half remains the same jailbreak instances. Tab. 3 reports TPR, FPR, and F1. When the test benign distribution shifts from ordinary benign prompts to PMPs, most detectors exhibit a sharp increase in false positives (FPRPMP is the FPR on PMP samples). M TK maintains FPRPMP = 0.02 while preserving TPR = 0.95 and F1 = 0.95, achieving the best performance on both metrics. This outcome is expected. Current detectors derive their decision boundaries from surface lexical cues and shallow activation rather than semantic intent. In the feature spaces they operate on—single-layer hidden states, refusal directions, gradient norms—PMPs land in the same region as genuinely harmful inputs, because both share sensitive keywords. These spaces support only coarse linear separations over token patterns. M TK, which tracks activation dynamics across layers, separates intent from surface form more reliably. Admittedly, our M TK requires a small set of PMPs as anchors for training (see Sec. 6 for details). A natural question is whether similarly augmenting existing detectors’ benign training data with PMPs would mitigate this issue. Our results indicate otherwise. In Tab. 3, “+PMP Augment” adds an equal number of OR-Bench PMPs (labeled benign) to each method’s training set. FPRPMP drops in most cases, but this comes with a trade-off: TPR often decreases as well, and F1 shows no consistent improvement. This further suggests that the robustness arises from a stronger detector representation, rather than merely from the data itself. Similar PMP-style benchmarks exist for VLMs [59, 60]. We test M TK on those in Sec. 6.3, where results remain strong. Two-sided failure of static detectors. Together with the adaptive attack results in Sec. 4.2, a clear pattern emerges: the same detectors are excessively permissive toward optimized jailbreaks yet excessively aggressive toward benign prompts that contain sensitive keywords. No threshold shift fixes both sides at once. This suggests that single-view, static-feature detection has reached its robustness ceiling, and motivates a move toward dynamic, trajectory-based analysis.
Defense↓
Setting
TPR ↑
FPR ↓
FPRPMP ↓
F1 ↑
GradCuff [19]
Vanilla +PMP Augment
0.90 0.85
0.05 0.04
0.12 0.08
0.95 0.90
GradSafe [20]
Vanilla +PMP Augment
0.71 0.67
0.04 0.05
0.09 0.08
0.78 0.75
HSF [15]
Vanilla +PMP Augment
0.38 0.23
0.05 0.04
0.32 0.27
0.53 0.38
HiddenDetect [9]
Vanilla +PMP Augment
0.83 0.80
0.05 0.03
0.06 0.04
0.88 0.87
SaP [11]
Vanilla +PMP Augment
0.73 0.41
0.04 0.04
0.03 0.01
0.83 0.58
SelfDefend [26]
Vanilla +PMP Augment
0.99 0.99
0.04 0.03
0.55 0.26
0.85 0.86
SmoothLLM [22]
Vanilla +PMP Augment
0.95 0.81
0.06 0.06
0.04 0.02
0.95 0.87
0.95
0.05
0.02
0.95
M TK (Ours)
5
M TK for Jailbreak Detection
Instead of examining a single layer’s representation, M TK tracks how a prompt’s representation evolves from the first transformer layer to the last. It differs from Euclidean distance-based formulations [61] used in prior detectors in two ways. First, it uses the full layer-wise trajectory on the representation manifold rather than a static snapshot. Second, it replaces fixed metric-space distances with manifoldlevel neighborhood relations, which are more robust to modelspecific coordinate shifts. The resulting detector distinguishes jailbreak prompts from benign ones by tracking how a test prompt’s nearest benign neighbors, drawn from a reference anchor set, change rank across layers. We first describe the challenge, intuition, and core idea (Sec. 5.1), then detail the three phases of manifold trajectory construction (Sec. 5.2).
5.1
Challenge, Intuition, and Core Idea
The challenge. Prior detectors extract features at one or a few selected layers and measure the gap between benign and jailbreak prompts in that space, typically via Euclidean distance or a trained classifier on penultimate-layer representations. Many detectors even require access to real jailbreak attack samples. We note that for simple, manually crafted jailbreaks such as DAN [38], even embedding-distance baselines [62] can achieve near-perfect accuracy. However, under adaptive attacks, single-layer representations of jailbreak and benign prompts become effectively inseparable (Sec. 4.2). The underlying limitation is that metric-space methods observe only feature differences at a fixed depth, without capturing how the neural network’s processing of jailbreak and benign inputs 6
diverges across the full forward pass. Constructing a detector that is jailbreak-data-free, model-agnostic, and robust to adaptive attacks requires a fundamentally different signal. Intuitions on input-level jailbreak detection. The safetyaligned LLM processes benign, malicious, and jailbreak prompts differently [10, 63]. Beyond toxic or malicious semantics, jailbreak attacks can encode a distinct set of jailbreak-specific concepts that transiently steer internal activations across the model’s safety boundary and flip behavior from refusal to compliance. Therefore, we posit that layerwise representations lie on a low-dimensional semantic manifold M ⊂ Rd and can be described via local manifold coordinates. We introduce a semantic frame to characterize three distinct semantic components: V = vmal , vben , vjb ∈ Rd×3 , (6)
across layers. This oscillation is neither tied to a particular layer nor monotonic. It reflects a depth-dependent competition between the malicious query and the jailbreak wrapper. In simplex coordinates, the dominant mode at depth ℓ is cℓ (x) := arg
(ℓ)
αc (x),
(8)
(ℓ) (ℓ) (ℓ) α(ℓ) (x) = αmal (x), αben (x), αjb (x) ∈ ∆2 .
(9)
max c∈{mal,ben,jb}
Thus, the prevailing semantics can shift from layer to layer. For benign or purely malicious inputs, {cℓ (x)}Lℓ=1 is typically stable. For successful jailbreaks, the sequence is multi-phase: different layers alternate between local lexical cues and global intent. This tug-of-war can be stated as a suppression relation: at many depths, the jailbreak wrapper attenuates refusalinducing malicious semantics, (ℓ)
whose columns are malicious, benign, and jailbreak semantic modes. For each layer ℓ and input x, the summary hidden state hℓ (x) ∈ M admits a barycentric decomposition hℓ (x) ≈ V α(ℓ) (x), α(ℓ) (x) ∈ ∆2 := α ∈ R3+ 1⊤ α = 1 .
(ℓ)
αmal (xjb ) < αmal (xmal ),
(10)
(ℓ) (ℓ) (ℓ) αben (xjb ) + αjb (xjb ) > αben (xmal ),
(11)
without these inequalities holding uniformly across all ℓ. A jailbreak prompt may appear malicious at certain layers and answer-inducing at others, which is precisely why detection based on a single layer or a fixed set of layers is brittle, even when relying on the safety-critical layer assumption [29, 48], since it depends on the underlying model and the specific jailbreak attack. M TK uses the full trajectory Γ(x) to capture these cross-depth competitions. Core idea. The bumping pattern in Fig. 2 shows that in early layers (e.g., 0–9), semantic processing has not fully propagated and representations remain relatively clustered. In mid layers (e.g., 16–20), the prompt exhibits stronger malicious affinity, meaning the model is more likely to refuse the input. In deeper layers (after ∼22), it progressively drifts toward the compliance region. In more complex cases, they can even oscillate between manifolds. Hence, M TK captures the kinetics of these cross-manifold transitions. Concretely, we measure, layer by layer, the distance from a test prompt to the benign cluster. A consistently small distance indicates a benign prompt. Distances that fluctuate across layers, signaling transitions at specific depths, are characteristic of jailbreak attacks. Fig. 3 provides an intuitive example of how the layer-wise distance (still defined via rank) evolves under the AutoDAN. We observe a clear separation from benign test prompts, enabling clean discrimination.
The coefficient vector α(ℓ) (x) records how much each mode is active at depth ℓ. The full sequence Γ(x) = α(1) (x), α(2) (x), . . . , α(L) (x) ∈ (∆2 )L (7) is the manifold trajectory: it describes how an input transitions between semantic modes across transformer layers. We build on these trajectories rather than a single feature slice. A complementary intuition comes from input–output asymmetry. At the surface level, a jailbreak prompt is constructed from a harmful query seed by appending a crafted instruction that bypasses safeguards. It thus resembles a malicious input far more than a benign one. Yet an aligned model may comply with the jailbreak prompt while still refusing the original malicious query. This input–output mismatch implies that jailbreak prompts interpolate between malicious and benign behavior: they begin as malicious variants but end up accepted. Consequently, their manifold trajectories should evolve differently from both benign and malicious inputs as they propagate through the network. To visualize these trajectories, we map each prompt to a continuous vector using the target LLM’s sentence embedding, taken as the last-token hidden state, which captures rich contextual and semantic information for next-token prediction [9, 10]. At each layer, we compute the “distance” difference δ: the test sample’s “distance” to the benign cluster minus its “distance” to the malicious cluster (“distance” is defined as the rank index of the nearest neighbor; we will introduce it later in Sec. 5.4). δ < 0 indicates benign-like affinity; δ > 0 indicates malicious-like affinity. As Fig. 2 shows, jailbreak prompts exhibit a “bumping” pattern that repeatedly crosses zero: the model’s semantic interpretation oscillates
5.2 Feature Modeling via Manifold Trajectory We show that during the prompt forward pass through transformer layers, benign and malicious signals can coexist and dynamically suppress each other. Overall, in shallow layers where representations are more local to tokens and phrases, malicious features tend to dominate, placing the sample closer to malicious prompts. In deeper layers where the model forms a more global representation of the full prompt, jailbreak 7