TrajGuard: Streaming Hidden-state Trajectory Detection for Decoding-time Jailbreak Defense

Fuente: arXiv
Enregistré dans:
Détails bibliographiques
Auteurs principaux: Liu, Cheng, Liu, Xiaolei, Li, Xingyu, Xin, Bangzhou, Ding, Kangyi
Format: Preprint
Publié: 2026
Sujets:
Accès en ligne:
Tags: Ajouter un tag
Pas de tags, Soyez le premier à ajouter un tag!
_version_ 1866918436371693568
author Liu, Cheng
Liu, Xiaolei
Li, Xingyu
Xin, Bangzhou
Ding, Kangyi
author_facet Liu, Cheng
Liu, Xiaolei
Li, Xingyu
Xin, Bangzhou
Ding, Kangyi
contents Existing jailbreak defense paradigms primarily rely on static detection of prompts, outputs, or internal states, often neglecting the dynamic evolution of risk during decoding. This oversight leaves risk signals embedded in decoding trajectories underutilized, constituting a critical blind spot in current defense systems. In this work, we empirically demonstrate that hidden states in critical layers during the decoding phase carry stronger and more stable risk signals than input jailbreak prompts. Specifically, the hidden representations of tokens generated during jailbreak attempts progressively approach high-risk regions in the latent space. Based on this observation, we propose TrajGuard, a training-free, decoding-time defense framework. TrajGuard aggregates hidden-state trajectories via a sliding window to quantify risk in real time, triggering a lightweight semantic adjudication only when risk within a local window persistently exceeds a threshold. This mechanism enables the immediate interruption or constraint of subsequent decoding. Extensive experiments across 12 jailbreak attacks and various open-source LLMs show that TrajGuard achieves an average defense rate of 95%. Furthermore, it reduces detection latency to 5.2 ms/token while maintaining a false positive rate below 1.5%. These results confirm that hidden-state trajectories during decoding can effectively support real-time jailbreak detection, highlighting a promising direction for defenses without model modification.
format Preprint
id arxiv_https___arxiv_org_abs_2604_07727
institution arXiv
publishDate 2026
record_format arxiv
spellingShingle TrajGuard: Streaming Hidden-state Trajectory Detection for Decoding-time Jailbreak Defense
Liu, Cheng
Liu, Xiaolei
Li, Xingyu
Xin, Bangzhou
Ding, Kangyi
Cryptography and Security
Artificial Intelligence
Existing jailbreak defense paradigms primarily rely on static detection of prompts, outputs, or internal states, often neglecting the dynamic evolution of risk during decoding. This oversight leaves risk signals embedded in decoding trajectories underutilized, constituting a critical blind spot in current defense systems. In this work, we empirically demonstrate that hidden states in critical layers during the decoding phase carry stronger and more stable risk signals than input jailbreak prompts. Specifically, the hidden representations of tokens generated during jailbreak attempts progressively approach high-risk regions in the latent space. Based on this observation, we propose TrajGuard, a training-free, decoding-time defense framework. TrajGuard aggregates hidden-state trajectories via a sliding window to quantify risk in real time, triggering a lightweight semantic adjudication only when risk within a local window persistently exceeds a threshold. This mechanism enables the immediate interruption or constraint of subsequent decoding. Extensive experiments across 12 jailbreak attacks and various open-source LLMs show that TrajGuard achieves an average defense rate of 95%. Furthermore, it reduces detection latency to 5.2 ms/token while maintaining a false positive rate below 1.5%. These results confirm that hidden-state trajectories during decoding can effectively support real-time jailbreak detection, highlighting a promising direction for defenses without model modification.
title TrajGuard: Streaming Hidden-state Trajectory Detection for Decoding-time Jailbreak Defense
topic Cryptography and Security
Artificial Intelligence
url https://arxiv.org/abs/2604.07727