arXiv:2604.07727cs.CRcs.AI2026-04ACL被引 1

通过分析解码过程中的隐藏状态轨迹,实现实时劫持攻击防御。

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

  • 利用解码时的隐藏状态轨迹检测风险信号
  • 平均防御率达95%,延迟仅5.2毫秒/令牌
  • 无需训练,适合部署在各类开源大模型上

现有劫持攻击防御方法多依赖静态检测输入提示、输出或内部状态,忽视了解码过程中风险动态演化。本工作实证发现,解码关键层的隐藏状态比输入劫持提示携带更强且更稳定的危险信号。具体而言,劫持尝试生成的词元隐藏表示会逐步逼近潜在空间中的高危区域。基于此,提出TrajGuard:一种无需训练、解码时运行的防御框架。该框架通过滑动窗口聚合隐藏状态轨迹,实时量化风险,当局部窗口内风险持续超过阈值时,触发轻量级语义判定并立即中断或约束后续解码。在12种劫持攻击和多个开源LLM上的实验表明,该方法平均防御率高达95%,检测延迟低至5.2毫秒/令牌,误报率低于1.5%。结果证实,解码阶段的隐藏状态轨迹可有效支撑实时劫持检测,为无需模型修改的防御提供新方向。

原文摘要 · Abstract (English)

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.

模型安全实时检测大模型防御隐状态分析

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。