Similarity Is Not Validity: Defending LLM Semantic Caches Against Poisoning
Zihan Zhang, Shuangjie Yao, Zesen Liu, Zhixiang Zhang, Wai Ip Lai, Dung Hiu Hilton Yeung, Chun Kit Zhang, Fuchen Ma, Yuanyuan Yuan, Yu Jiang, Dongdong She
Abstract
Semantic caches reduce LLM serving costs by reusing previously generated answers for semantically similar queries. However, retrieval is based solely on embedding similarity between the incoming query and cached queries. This design enables cache poisoning: an attacker can cache a malicious response under a query with high cosine similarity to benign requests. The vulnerability stems from a gap between retrieval similarity and answer validity. From an information-bottleneck perspective, query embeddings can lose information needed to distinguish valid from invalid cache hits, which limits any matching algorithm that uses only these embeddings. We propose a novel defense that recovers this necessary information from the raw text of the cache key. Across poisoning attacks, adversarial queries share a rewrite-residual structure: they pair a rewrite of the target query with residual content. The rewrite maintains high similarity, while the residual elicits the malicious response. Deleting the residual makes the remaining rewrite more similar to the incoming query. We exploit this structure using Deletion Gain to search shortened variants of the cached query for similarity gains, and an Answer Check to test whether the removed text contributes to the stored answer. We prove that Deletion Gain stays positive when a deletion leaves text close enough to the rewrite, and we search for such deletions with a sliding window. Across three poisoning attack classes, our defense blocks 82.0% to 98.2% of poisoned entries at a 5% false-positive rate, with negligible serving overhead.
Create a lesson
Metadata
- Categories
- cs.CR, cs.AI
- Comments
- 25 pages, 5 figures, 17 tables. Code: https://github.com/shentoumengxin/deletion-gain
Related papers
Ichnia: Semantic Effect Oracles for Black-Box Broken Access Control Detection in Web Applications
Shared title terminologycs.CRRuozhao Yang, Jiongchi Yu, Yuqiang Sun et al.
Data Poisoning Attacks and Defenses to Local Differential Privacy Protocols: A Survey
Shared title terminologycs.CRXinyu Li, Xuebin Ren, Shusen Yang et al.
DiffuVader: Validity-Constrained Discrete Diffusion for Flow-Level NIDS Red Teaming
Shared title terminologycs.CRHamed Fard, Ilya Komarov, Gerhard Wunder
Blocked Is Not Fixed: Validating C/C++ Spatial Out-of-Bounds Patches with Counterexamples and Runtime Evidence
Shared title terminologycs.CRYi Chen, HaiQuan Wang, Shihao Li et al.
SPAR: Sparse-space Poisoning Attack on Retrieval-Augmented Generation Systems
Shared title terminologycs.CRQingyuan Zheng, Min Ren, Saihui Hou et al.
Poisoning the Evidence: Document and Data Attacks on LLM-driven Retrieval-Assisted Analytical Process-Property Model Generation
Shared title terminologycs.CRHoang Anh Nguyen, Ziqin Liu, Yuan Hong et al.