Multi-tenant LLM serving frameworks widely adopt shared Key-Value caches to enhance efficiency. However, this creates side-channel vulnerabilities enabling prompt leakage attacks. Prior studies identified these attack surfaces yet focused on expanding attack vectors rather than optimizing attack performance, reporting impractically high attack costs that underestimate the true privacy risk. We propose OptiLeak, a reinforcement learning-enhanced framework that maximizes prompt reconstruction efficiency through two-stage fine-tuning. Our key insight is that domain-specific ``hard tokens'' -- terms difficult to predict yet carrying sensitive information -- can be automatically identified via likelihood ranking and used to construct preference pairs for Direct Preference Optimization, eliminating manual annotation. This enables effective preference alignment while avoiding the overfitting issues of extended supervised fine-tuning. Evaluated on three benchmarks spanning medical and financial domains, OptiLeak achieves up to 12.48× reduction in average requests per token compared to baseline approaches, with consistent improvements across model scales from 3B to 14B parameters. Our findings demonstrate that cache-based prompt leakage poses a more severe threat than previously reported, underscoring the need for robust cache isolation in production deployments.
Figures & tables
Figure 1: Attack scenario overview
Figure 2: An overview of OptiLeak ’s operation pipeline.
Model
Method
MedQA
FinanceBench
PubMedQA
ASR 500
ASR 1000
ASR 10000
w/l
ARPT
ASR 500
ASR 1000
ASR 10000
w/l
ARPT
ASR 500
ASR 1000
ASR 10000
w/l
ARPT
Qwen-2.5-3B-Instruct
Base
18.0%
37.3%
95.3%
-
41.99
2.0%
2.0%
54.0%
-
240.81
0.0%
3.0%
68.0%
-
628.50
SFT
27.3%
53.3%
98.0%
80.0%
26.37
88.0%
90.0%
100.0%
100.0%
20.81
12.0%
28.0%
94.0%
91.0%
220.85
DPO
18.0%
38.0%
95.3%
48.7%
41.86
2.0%
2.0%
56.0%
68.0%
238.81
1.0%
5.0%
71.0%
63.0%
571.51
OptiLeak
29.3%
55.3%
98.6%
84.0%
21.60
88.0%
90.0%
100.0%
100.0%
19.29
11.0%
31.0%
94.0%
91.0%
208.72
Qwen-2.5-7B-Instruct
Base
18.0%
36.0%
94.0%
-
54.50
6.0%
6.0%
66.0%
-
259.65
0.0%
1.0%
49.0%
-
943.05
Table 1: Main experimental results on MedQA, FinanceBench, and PubMedQA datasets. DPO results are obtained by directly training the base model using OptiLeak ’s auto-annotation approach. The best-performing results in the table are highlighted for clarity.
Figure 3: Ablation Study Results. The left figures show ARPT changes during SFT training, while the right figures show DPO training results based on SFT-tuned models (MedQA: SFT training step 500, FinanceBench: SFT training step 100).
Benchmark
Prior Knowledge
ARPT ( ↓ )
MedQA
Base
41.99
FinanceBench
51.90 (23.6 % ↑ )
PubMedQA
30.27 (27.9% ↓ )
MedQA
21.60 (48.6 % ↓ )
PubMedQA
Base
628.50
FinanceBench
966.59 (53.8 % ↑ )
Table 2: Attack performance with different levels of prior knowledge. “Benchmark” indicates the target testing dataset, “Prior Knowledge” indicates the dataset used for training.
Privacy leakage in language models concerns how models expose training data, infer sensitive traits, or transmit private context through outputs and internal channels.
Large Language Models (LLMs) rely on proprietary system prompts to enforce task directives, safety policies, and access controls. These prompts are vulnerable to query-based leakage attacks, where black-box adversaries extract confidential instructions through adaptive, multi-turn interactions. Existing defenses often assess queries independently, missing malicious behavior that emerges across interactions. We present AdvGuard, a model-agnostic framework for detecting and mitigating system prompt leakage. AdvGuard models cross-query relationships using a bounded semantic interaction graph, statistically filters candidate components, and converts them into line graphs for graph convolutional network (GCN) classification. This approach captures multi-hop patterns in query similarity that distinguish coordinated extraction from benign workflows. A lightweight prompt-level detector provides protection before sufficient interaction history accumulates, and the framework supports black-box LLM deployments. In mixed-query evaluations, AdvGuard improves recall by up to 36% over the strongest baseline while maintaining a false positive rate of at most 3.4%. In multi-turn workloads, it achieves 97.23%-99.1% F1 with 100% recall. Leave-one-attack-family-out tests yield 99.98% mean recall and 99.99% mean F1, with no observed false positives. Integrated into the adaptive PLeak and LeakAgent attack loops, AdvGuard limits exact-match leakage to 0.00-0.01 and substring-match leakage to 0.01-0.09 across evaluated victim models. These results demonstrate robust detection of unseen attack families and substantially reduced prompt reconstruction.
Tushar Nayan, Pratik Poudel, Qian Lou +3
Florida International University · University of Central Florida · University of Texas at Arlington
The key-value (KV) cache is the primary throughput optimization in modern large language model (LLM) inference, enabling prefix reuse across requests. In multi-tenant deployments this cache is shared across tenants, creating a timing side channel: an adversarial tenant can reconstruct another tenant's private prompt by probing cache-hit latency. Three published attacks exploit it -- PROMPTPEEK, EarlyBird and InputSnatch -- reaching up to 100% attack success rate against unprotected vLLM and SGLang, with rates varying by cache architecture and prompt structure. We present KVGov, a governance layer addressing all three attack families' prefix-cache paths under one mechanism. A per-principal salt sigma_p = HMAC_K(secret, principal_id) seeds the block-hash chain, making cache keys cryptographically disjoint across principals. An ablation (N=1000 trials, seed 2026, deterministic judges) isolates this salt as the necessary and sufficient component. KVGov adds ORIGAMI, a Stackelberg water-filling audit scheduler that reduces adversary expected utility by 12.6% at realistic tenant heterogeneity (Gini 0.63), and an evolutionary stability analysis giving a 31.6% adversary-prevalence tipping point below which global caching remains stable. On real hardware (Qwen2.5-7B-Instruct, vLLM 0.26.0, NVIDIA A100) we measure a gate-verified cold/cached TTFT ratio of 0.22, confirming the channel is exploitable at production scale; the defense itself is evaluated in simulation calibrated to those measurements. We replicate the channel on an independent stack (llama.cpp on Apple Metal, ratio 0.093). Finally, isolation and cache efficiency need not conflict: identifying information resides only where prompts diverge, so injecting the salt at that boundary rather than the chain root retains an estimated 93% of the prefix-cache benefit with no cross-principal signal.
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.
Panagiotis Georgios Pennas, Konstantinos Papaioannou, Marco Guarnieri +1
IMDEA Software Institute · Universidad Politécnica de Madrid