arXiv:2508.09442cs.CRcs.AI2025-08中稿 · Network and Distri…被引 27

KV缓存会泄露用户隐私,该研究提出有效防护方案。

Shadow in the Cache: Unveiling and Mitigating Privacy Risks of KV-cache in LLM Inference

  • 通过反演、碰撞和注入三类攻击,可从KV缓存还原用户输入。
  • 提出的防御方案在不降低精度的前提下,完全阻断攻击效果。
  • 适合关注大模型推理安全的开发者与部署者使用。

键值(KV)缓存通过存储中间注意力计算结果(键和值对),避免重复计算,是加速大语言模型推理的核心机制。然而,这一优化带来了显著却未被充分探索的隐私风险。本文首次全面分析了此类漏洞,证明攻击者可直接从KV缓存中重构敏感用户输入。我们设计并实现了三种攻击向量:直接反演攻击、更普适且强大的碰撞攻击,以及基于语义的注入攻击。这些方法展示了KV缓存隐私泄露的实际性和严重性。为应对该问题,我们提出KV-Cloak,一种新型、轻量且高效的防御机制。该方案采用可逆矩阵混淆策略,并结合算子融合,保护KV缓存。大量实验表明,KV-Cloak能有效抵御所有攻击,使重建结果退化为随机噪声。关键的是,它在几乎不损失模型精度且性能开销极小的情况下实现强安全防护,为可信的大模型部署提供了实用解决方案。

原文摘要 · Abstract (English)

The Key-Value (KV) cache, which stores intermediate attention computations (Key and Value pairs) to avoid redundant calculations, is a fundamental mechanism for accelerating Large Language Model (LLM) inference. However, this efficiency optimization introduces significant yet underexplored privacy risks. This paper provides the first comprehensive analysis of these vulnerabilities, demonstrating that an attacker can reconstruct sensitive user inputs directly from the KV-cache. We design and implement three distinct attack vectors: a direct Inversion Attack, a more broadly applicable and potent Collision Attack, and a semantic-based Injection Attack. These methods demonstrate the practicality and severity of KV-cache privacy leakage issues. To mitigate this, we propose KV-Cloak, a novel, lightweight, and efficient defense mechanism. KV-Cloak uses a reversible matrix-based obfuscation scheme, combined with operator fusion, to secure the KV-cache. Our extensive experiments show that KV-Cloak effectively thwarts all proposed attacks, reducing reconstruction quality to random noise. Crucially, it achieves this robust security with virtually no degradation in model accuracy and minimal performance overhead, offering a practical solution for trustworthy LLM deployment.

隐私安全大模型推理缓存防护

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