Deep dives · 2026-12-01 · Advanced · By bombong
Side channels in inference servers: information leaking through the KV cache and batching
In LLM serving engines shared by many users, optimizations such as KV cache sharing, batching and sparse computation leave traces in response times and memory access patterns. That makes it possible to snoop on other users' prompts. This note covers how the attacks work, why efficiency and security pull against each other, and what each defense design gives up and what it protects.
Contents
- Why it matters: the traces left by efficiency optimizations
- Core idea: what 'dishes already prepared' reveal
- How it works: the steps of a prefix-probing attack
- How the field has developed: from simple prefixes to real production environments
- Defense designs: what they give up and what they protect
- Recent directions: cache key separation, and batching and sparsity side channels
- Limitations and open issues: what to weigh in practice
- Further reading
- Cache hits return faster, so a difference in TTFT alone reveals that 'someone has already sent this prefix.' Attackers extend this one token at a time to reconstruct other users' prompts.
- The leakage paths are not limited to the prefix cache. Information also leaks through non-prefix cache concatenation (RAG), scheduler state, dynamic quantization applied across a shared batch, and the memory accesses of sparse attention.
- Under real production load, timing signals can weaken considerably. Attack success rates measured on a quiet system can therefore easily overstate the real risk.
- Defenses started with turning sharing off and are diversifying into blocking only sensitive parts (SafeKV, CachePrune), partitioning cache keys by principal (KVGov), and hiding response timing at the gateway (Mirage).
- In practice, the first step is to decide at what level cache sharing applies (tenant, API key or gateway account). Each time a performance optimization is turned on, check whether it leaves traces that depend on the input.
Why it matters: the traces left by efficiency optimizations
To save expensive GPU time, LLM serving engines process requests from many users together. A common technique is sharing the KV cache (the memory that stores previously computed attention intermediates). If the opening part that appears identically in many requests, such as a system prompt, is computed once and reused, the first token comes out much faster. In multi-tenant environments, where several customers (tenants) share one server, this cache is often shared across tenants too.
The problem is that 'getting faster' is itself information. KVGov paper, a study on KV cache management, ran Qwen2.5-7B-Instruct on vLLM on an A100 GPU and measured a TTFT (time to first token) ratio of 0.22 for cache hits relative to cache misses (cold). A gap that large lets an outsider tell hits from misses just by calling the API. The same paper lists three attacks targeting this path: PROMPTPEEK, EarlyBird and InputSnatch. These attacks reached success rates of up to 100% on unprotected vLLM and SGLang, and the rates varied with cache structure and prompt form.
Attacks like these are called side-channel attacks. They read secrets not from the system's official outputs but from side effects such as elapsed time, memory access order and resource state. Because the target is the serving infrastructure rather than model weights or training data, this is a different layer of risk from prompt injection or training data extraction.
Core idea: what 'dishes already prepared' reveal
Think of a restaurant kitchen. The kitchen prepares popular dishes in advance, so they come out quickly when ordered. Then the mere fact that a dish arrived unusually fast lets you guess that 'someone else just ordered this.' By ordering one dish after another, you could work out fairly accurately what other diners ate. That is exactly how KV cache timing attacks work.
The key point of this analogy is that the kitchen did nothing wrong. Preparing in advance (cache sharing) is a legitimate optimization; the problem is that its effect is visible to every diner alike. So the central question in this field is less 'how do we fix it' and more 'how do we erase the traces while keeping as much of the speed gain as possible.' This is why defense papers all report TTFT and cache hit rate together.
The same principle applies beyond the cache. Any optimization whose processing changes with the input content is a potential side channel. Examples include setting the quantization range based on the values in a shared batch, and sparse computation that reads only the important tokens.
How it works: the steps of a prefix-probing attack
The most basic prefix-matching attack proceeds as follows. First, a victim sends a prompt, and the serving engine leaves its KV blocks in the shared cache. Second, the attacker sends text they guess is the start of the victim's prompt (for example, a public system prompt plus a candidate word). Third, the attacker measures the response's TTFT. Fourth, if it is fast, the attacker treats it as a hit, meaning the candidate is correct, extends it by one token and repeats the process. Mirage paper also describes this attack as one that infers sensitive prompt tokens from the TTFT difference between cache hits and misses.
This method rests on one assumption: the attacker's guess must match the victim's prompt exactly from the very beginning. In real RAG queries, where the opening part contains personal information that differs from user to user, this assumption breaks. However, a study on non-prefix KV cache attacks paper showed that 'non-prefix cache concatenation', which stitches together KV for each document chunk so it can be reused even when the beginnings differ, becomes a new channel. The deterministic mechanism that aligns and merges chunks leaves a staircase-shaped 'Step-Wave' timing pattern. The study's SpliceLeak first finds the exact length of a hidden private prompt, then manipulates collisions at chunk boundaries to extract the content token by token. On a setup combining vLLM and LMCache, it achieved up to 100% extraction in settings where the number of possible candidates is limited. The authors report that a deterministic +104ms delay let them cut through the noise of continuous batching with as few as 63 requests per token.
What gets observed can also be scheduler state rather than prompt content. A study on latency attacks paper reported that algorithm-level attacks that inflate output length barely work on today's serving systems. Continuous batching (a batching method that slots in new requests as soon as earlier ones finish) logically prevents delays from spreading to other users. Instead, the study demonstrated an attack that probes memory state as a side channel, fills the global KV cache (Fill) and forces repeated preemption (Squeeze). On vLLM, TTFT became 75 to 742 times worse than for normal requests. This is an availability attack rather than an information leak, but it likewise depends on the same cache state being observable from outside.
How the field has developed: from simple prefixes to real production environments
The research quickly moved from the starting question of 'is the attack possible?' to 'does it work in real environments?' and 'how do we stop it?' On the attack side, SpliceLeak paper removed the prefix-alignment assumption and extended the attack surface to RAG environments. Fill and Squeeze paper used the same cache-state observation for denial of service.
A measurement study under contention paper pushed back on this trend. It ran seven experiments on serving systems that were actually being shared. Running DeepSeek-R1-Distill-Llama-8B on vLLM on an NVIDIA GB10, the mean effect size separating hits from misses (Cohen's d) dropped from 0.7789 with no load workers to 0.2109 with two. Adding more workers produced no further statistically detectable drop. Discriminative power (AUROC) fell from 0.650 when idle to 0.531 in an overlap regime of around 61%, then partly recovered to 0.574 at saturation. In a 2-node, 2-GPU tensor-parallel setup, d also collapsed from 3.418 to 0.511. The authors concluded that values measured on quiet systems can overestimate real production risk.
The two results seem to conflict at first, but the signal sizes differ. A deterministic delay much larger than the noise (SpliceLeak's +104ms) survives contention, while attacks that depend on subtle hit/miss differences get buried under load. For defenders, this is no reason to dismiss the risk with 'our servers are always busy, so we're fine.' Instead, it means they need to examine separately which optimizations produce large staircase-shaped signals.
Defense designs: what they give up and what they protect
The simplest defense is to turn off cache sharing between users. But as CachePrune paper points out, much of a prompt, such as system instructions or public material, has nothing to do with personal information. Turning sharing off entirely throws away a large share of the reuse benefit. Later work therefore moved toward choosing more precisely 'what to block.'
SafeKV paper added a three-stage asynchronous detection pipeline to the serving runtime that separates sensitivity classification from inference. It also added a radix tree-based memory manager that excludes only sensitive blocks from cross-tenant reuse, and an RDR (reuse diversity ratio) safeguard that detects remaining leakage. Compared with full isolation, it reduced TTFT overhead by up to 40.58% and raised throughput by up to 2.66x. CachePrune went a step further: masking sensitive spans makes the length and position of reusable spans irregular, and it solved this with token-level cache management. On vLLM, it reported eliminating direct leakage through the KV cache reuse side channel while cutting TTFT by 4.5x and raising the cache hit rate by 44% compared with the previous state-of-the-art method.
There are also defenses with an entirely different approach. Mirage paper does not stall the GPU or make it redo the same computation. Instead, it delays when the gateway releases tokens, so the response looks like a natural cache miss to the attacker. A 'Privacy Odometer' tracks how aggressively a prefix is being probed through branching, and only for prefixes that cross a safety threshold does it pad TTFT to match the cache-miss baseline. In experiments with 500 samples and three models, it suppressed the timing side channel to near random-guess level. The design lets the GPU keep its full benefit while slowing down only suspicious requests.
Confidential computing serving protected by a trusted execution environment (TEE) also has gaps. OTRO paper noted that a prompt can be recovered solely from the memory access pattern of a CPU-based tokenizer looking up its tables. Simply attaching PathORAM, a commonly used tree-based ORAM (a technique that hides access patterns), makes the tokenizer about 13x slower and increases TTFT by 10–58%. OTRO reduced this overhead with a pool of square-root ORAM replicas, per-epoch rotation, and KV cache-aware chunked tokenization.
Comparison of KV cache defenses
| Preserves cross-user reuse | Requires sensitivity classification | Modifies engine internals | |
|---|---|---|---|
| Full isolation | ✕ | ✕ | ✕ |
| SafeKV | △ | ✓ | ✓ |
| CachePrune | △ | ✓ | ✓ |
| KVGov salt | △ | ✕ | ✓ |
| Mirage | ✓ | ✕ | ✕ |
Recent directions: cache key separation, and batching and sparsity side channels
A notable trend on the defense side is a governance approach that partitions the cache by 'whose it is.' KVGov paper uses a salt (an HMAC value) generated with a secret key for each principal as the starting value of the block hash chain, so that cache keys for different principals cannot cryptographically overlap. In an ablation experiment with 1,000 trials, it showed that this salt is both necessary and sufficient to block the prefix cache path of three attack families. However, as the authors state, the defense's effectiveness itself was evaluated in a simulation calibrated with measured values.
On the attack side, the scope is expanding beyond the cache to other optimizations. Quantamination paper showed that dynamic quantization, which sets quantization ranges at runtime based on input values, can reveal the inputs of other users in the same batch. It reports that at least four widely used ML frameworks use, or can use, settings by default that leak data across batch boundaries. Being grouped into a batch becomes a risk factor in itself.
SparLeak paper targeted the fact that sparse attention, which speeds up long-context inference, reads different KV cache blocks depending on the input — a GPU microarchitectural side channel called SIMA. It recovered attributes of the query from traces in the prefill stage and the model's response from traces in the decoding stage. Across three model architectures, three sparse attention methods and three datasets, the average success rate was 90.9% for attribute inference and 87.3% for response recovery. The common lesson is that any optimization that creates 'input-dependent execution paths' should be included in side-channel checks.
Limitations and open issues: what to weigh in practice
First, define the threat model first. Most of these attacks assume the attacker uses the same serving instance as the victim and can send requests repeatedly. Even an internal-only server is in scope if departments or client companies share the cache; conversely, if each tenant uses a separate instance, the cache timing risk drops sharply. Also keep in mind that if multiple users are bundled into one account through a gateway, that boundary can become meaningless even if the provider isolates the cache per account.
Second, do not carry over attack success rates as-is. As the contention measurement study paper showed, the signal fluctuates widely depending on load and the serving stack. That does not mean a busy system is safe, either. Designs like SpliceLeak paper, which deterministically create large delays, cut through the noise. When evaluating, measure both a quiet environment and a real load environment.
Third, each defense makes different trade-offs. Full isolation is simple but costly. SafeKV and CachePrune must judge sensitivity, so misclassification means either leakage or lost benefit. The salt approach preserves reuse within the same principal, but its effect depends on what unit is chosen as the principal. Mirage preserves GPU efficiency but increases latency for requests caught by detection.
A common mistake is to feel safe after looking only at the KV cache. Every time a performance optimization such as dynamic quantization, sparse attention or the tokenizer is turned on, check whether it creates input-dependent traces. Confidential computing (TEE) also does not automatically hide memory access patterns.
Inference server side-channel checklist
Sharing scope
- At what unit (tenant, API key) is the KV cache shared?
- Does the gateway avoid bundling multiple users into one account?
- Is RAG chunk concatenation (non-prefix caching) enabled?
Traces by optimization
- Does dynamic quantization avoid setting ranges per batch?
- Are access patterns of sparse attention and sparse operations kept hidden?
- Are tokenizer access patterns protected even inside the TEE?
Validation
- Was the TTFT difference measured both when idle and under real load?
- Are requests that repeatedly probe the same prefix through branching detected?
Further reading
As an introduction, read the threat model explanation in Mirage paper and the summary of attack families in KVGov paper first to get a picture of the basic prefix attack. Then read the contention measurement study paper to get a sense of how to interpret lab figures.
If you want to look deeply at attack mechanisms, we recommend SpliceLeak paper for non-prefix caches in RAG and Fill and Squeeze paper for observing scheduler state. If you are designing defenses, reading SafeKV paper and CachePrune paper side by side shows two implementations of 'blocking only the sensitive parts.'
For risks beyond the cache, start with Quantamination paper(batching and dynamic quantization) and SparLeak paper(sparse attention); for gaps in confidential computing environments, start with OTRO paper(tokenizer access patterns).
Related terms
KV cache Prompt caching Continuous batching PagedAttention TTFT Confidential computing Quantization Inference engine
References
Foundational papers
- Agent-Assisted Side-Channel Attacks on Non-Prefix KV Cache in RAG (2026)
- Rethinking Latency Denial-of-Service: Attacking the LLM Serving Framework, Not the Model (2026)
- Characterizing Contention-Induced Reliability Collapse in KV-Cache Timing Side Channels for Multi-Tenant LLM Serving (2026)
- CachePrune: Privacy-Aware and Fine-Grained KV Cache Sharing for Efficient LLM Inference (2026)
- Selective KV-Cache Sharing to Mitigate Timing Side-Channels in LLM Inference (2025)
- Mirage: Provable Defense Against LLM KV Cache Timing Side Channels with Topology-Aware Isolation (2026)
- OTRO: Oblivious Tokenization Path with Square-Root ORAM (2026)
Recent research
Written by AI from the listed references and reviewed. Please check the original sources for details.