arXiv:2607.19957cs.CRcs.AI2026-07中稿 · USENIX Security 20…

新攻击方法利用位置无关缓存漏洞,悄悄操控大模型行为

HijackKV: New Threat in Position-Independent KV Cache Reuse

论文配图:HijackKV: New Threat in Position-Independent KV Cache Reuse
图 1 · 摘自论文原文
  • 通过伪造文本块让缓存携带恶意上下文,实现隐蔽劫持
  • 单次攻击成功率94%,低命中率下仍有效,跨模型可迁移
  • 揭示系统设计缺陷,适合关注模型安全的研究者参考

键值(KV)缓存能降低大语言模型的推理延迟。传统基于前缀的复用因需精确匹配标记和位置,缓存命中率较低。为提升效率,近期系统优化引入了位置无关的KV复用,使相同文本块无论位置如何均可复用缓存。我们发现该设计引入了新威胁:KV缓存劫持。由于缓存按标记匹配检索,却编码原始计算时的上下文,一个看似无害的标记块可能携带攻击者控制的前缀。当后续在受害者查询中复用时,该污染的缓存会悄然劫持模型行为,即使输入中未出现攻击者控制的文本。我们提出HIJACKKV,首个系统性利用此漏洞的攻击框架,证明其严重性和实用性。该框架优化攻击者控制的前缀,使后续常见良性文本对应的缓存编码攻击目标,而文本本身对后续缓存命中保持不变。实验显示,单次攻击平均成功率达94%,在低命中率(10%)和频繁重计算(50%)条件下仍有效,支持多轮交互,且在黑盒设置下跨模型迁移成功。我们进一步提供构建安全KV复用系统的改进设计思路。

原文摘要 · Abstract (English)

Key-Value (KV) cache reduces inference latency in large language models (LLMs). Traditional prefix-based reuse has low cache hit rates across inference requests because it requires exact token and position matches. To improve efficiency, recent system optimizations introduce position-independent KV reuse, allowing KV cache to be reused whenever identical text chunks appear, regardless of their position in the sequence. We show this design introduces a new threat, KV Cache Hijacking. Since KV caches are retrieved by token match but encode the context in which they were originally computed, the KV tied to a benign-looking token chunk may encode an attacker-controlled prefix. When later reused in a victim query, this contaminated KV silently hijacks the model's behavior, even if no attacker-controlled text appears in the input. We introduce HIJACKKV, the first attack framework that systematically exploits this vulnerability, demonstrating its severity and practicality. HIJACKKV optimizes an attacker-controlled prefix, so that the KV computed for a subsequent common benign text encodes the attacker's goal, while the text remains unchanged for future cache hits. HIJACKKV achieves an average 94% success rate in a single attempt, remains effective under realistic constraints including low hit rates (10%) and frequent recomputation (50%), persists over multi-turn interactions, and transfers across models in black-box settings. We further provide design insights for building secure KV reuse systems.

模型安全缓存攻击大模型

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