PrefixWall: Mitigating Prefix Caching Side Channels in Shared LLM Systems
Organizations: IMDEA Software Institute · Universidad Politécnica de Madrid
Abstract
Large Language Models (LLMs) rely on optimizations like Automatic Prefix Caching (APC) to accelerate inference. APC works by reusing previously computed states for the beginning part of a request (prefix), when another request starts with the same text. While APC improves throughput, it introduces timing side channels: cache hits are faster than misses, creating observable latency differences. In multi-tenant systems, attackers can exploit these differences to infer sensitive information, e.g., by incrementally reconstructing another user's request by observing hit/miss patterns. Current defenses take a sledgehammer approach: they disable APC and cache sharing, isolating users, and sacrificing efficiency for regular users. This paper presents PrefixWall, a system that secures multi-tenant LLM serving systems against APC side channels without sacrificing performance and efficiency. PrefixWall monitors cache reuse across users, flags suspicious sharing, and selectively isolates prefixes, restricting their reuse only when necessary. Evaluation shows that PrefixWall enables up to 70% higher cache reuse and 30% lower inference latency compared to existing defenses that isolate users. PrefixWall's lightweight design demonstrates how security in LLM serving does not have to come at the cost of unnecessarily reduced performance or unbearable overheads.
Figures & tables
| Related Work | Mitigation | Prefix Reuse | Low TTFT |
| Partitioning ( Pang et al., 2024 ) | Per-user Isolation | ✗ | ✗ |
| InputSnatch ( Zheng et al., 2024b ) | Per-user Isolation | ✗ | ✗ |
| Audit ( Gu et al., 2025 ) | Per-user Isolation | ✗ | ✗ |
| Remote ( Carlini and Nasr, 2024 ) | Timing Obfuscation | ✓ | ✗ |
| SafeKV ( Chu et al., 2025 ) | Selective Sharing | ✓ | ✗ |
| PrefixWall | Selective Sharing | ✓ | ✓ |
| Abbreviation | LLM Model | Model Memory | Cache Memory |
|---|---|---|---|
| Gemma3-4B | gemma-3-4b-it ( Google DeepMind, 2025 ) | 8.6 GB | 31.4 GB |
| Llava-0.5B | llava-onevision-qwen2-0.5b-ov-hf ( LLaVA Team, 2024a ) | 1.68 GB | 38.32 GB |
| Llava-7B | llava-onevision-qwen2-7b-ov-chat-hf ( LLaVA Team, 2024b ) | 15.03 GB | 24.97 GB |
| Llama2-7B | Llama-2-7b-chat-hf ( Meta AI, 2023b ) | 12.6 GB | 27.4 GB |
| Llama2-13B | Llama-2-13b-chat-hf ( Meta AI, 2023a ) | 24.3 GB | 15.7 GB |
| Qwen2-2B | Qwen2-VL-2B-Instruct ( Alibaba Cloud, 2024a ) | 4.15 GB | 35.85 GB |
| Component | Time | Memory |
|---|---|---|
| Detector | 0.004 ms per request | 32 bytes per cache entry |
| Activator | 0.003 ms | 16 bytes * len(window) |
LLM Security
Large language model (LLM) security studies attacks, privacy risks, and defenses across model training, inference, and deployment.
See all 322 papers