Skip to content

HijackKV: A New Threat in Position-Independent KV Cache ReuseHijackKV: New Threat in Position-Independent KV Cache Reuse

arXiv· arXiv:2607.19957· USENIX Security 2026· Yichi Zhang, Zhiqi Wang, Huan Zhang, Yuchen YangThe Pennsylvania State University; University of Illinois Urbana-ChampaignIndexed by this site · 20 days ago· Originally publishedSelected AttacksSelectedAttention41

Quick read

Attacks

Based on the paper PDF (AI-generated); refer to the original

The authors propose H IJACK KV, a cross-user hijacking attack against position-independent KV cache reuse, achieving an average T-ASR of 94% per single attempt in the white-box setting.

Threat modelThe attacker has no system-level privileges, cannot read or write the shared KV cache or modify the victim's input, and can only submit inputs to the LLM service and observe outputs; there are two settings, white-box (the local proxy model is the same as the target model, and gradients are available) and black-box (optimize the prefix on a local substitute model and then transfer); the victim system is a multi-tenant LLM service that enables position-independent KV cache and shares a cache pool across users.

Questions
Position-independent KV cache reuse retrieves cached entries by token matching, but the cached KV encodes the original context; the authors state that this lets an attacker pollute the shared cache with a malicious prefix and hijack model outputs across users when the victim's input contains no malicious text at all.
Methods
Proposes H IJACK KV: on a local proxy model, use GCG to optimize an adversarial prefix so that the KV encoding of a public text block computed after concatenating the prefix encodes the attack target; the attacker submits this query to write the hijacked KV into the shared cache pool, and subsequent victim queries that hit this block have their outputs steered to the attacker-specified answer.
Experiments and results
White-box evaluation on 3 models and 4 QA benchmarks: for Llama-3.1-8B under Vanilla, T-ASR is mostly 0.90–1.00 (Table 1); at δ=0.1 and ρ=0.3, average T-ASR is still 67%; black-box transfer to Llama-3.3-70B gives T-ASR of 37%; the authors claim existing KV defenses and compression methods cannot eliminate this threat.
Limitations and future work
The authors note that the attack relies on the hijacked KV entering the shared cache before eviction and being reused, is not well suited to chunk-then-cache RAG pipelines, and that cache occupancy probing self-pollutes the cache state; experiments were conducted only in a controlled offline environment with public datasets and locally deployed models, and production services were not tested.
Experimental setupLlama-3.1-8B、Ministral-8B et al. · HotpotQA、SQuAD v1.1 et al. · Acc、U-ASR et al.
Evaluated models
Llama-3.1-8BMinistral-8BQwen3-8BQwen3-4BQwen3-14BLlama-3.2-1BLlama-3.2-3BLlama-3.3-70B
Benchmarks
HotpotQASQuAD v1.1SQuAD v2.0MedQAPubMedQAHumanEval
Metrics
AccU-ASRT-ASR
AI summaryand selection rationaleThe researchers propose the HijackKV attack framework, which exploits position-independent KV Cache reuse to hijack large language model outputs, with the victim's input containing no malicious text, achieving an average attack success rate of 94% in a single attempt. The attacker prepends a GCG-optimized adversarial prefix to a benign text block that is frequently reused, causing the KV state of that text block to encode the attack objective; when a subsequent user query hits the cache, the poisoned KV silently takes over the model's behavior, distinguishing it from prompt injection, which requires malicious text to appear in the input. On the HotpotQA, SQuAD, MedQA, and PubMedQA datasets and models such as Llama-3.1-8B, Ministral-8B, and Qwen3-8B, the attack remains effective when the cache hit rate is as low as 10% and the recomputation ratio rises to 50%, its influence persists after inserting more than 1000 irrelevant tokens, and a prefix optimized on Llama-3.1-8B still achieves 75% U-ASR and 37% T-ASR when transferred black-box to Llama-3.3-70B.

The researchers propose the HijackKV attack framework, which exploits position-independent KV Cache reuse to hijack large language model outputs, with the victim's input containing no malicious text, achieving an average attack success rate of 94% in a single attempt. The attacker prepends a GCG-optimized adversarial prefix to a benign text block that is frequently reused, causing the KV state of that text block to encode the attack objective; when a subsequent user query hits the cache, the poisoned KV silently takes over the model's behavior, distinguishing it from prompt injection, which requires malicious text to appear in the input. On the HotpotQA, SQuAD, MedQA, and PubMedQA datasets and models such as Llama-3.1-8B, Ministral-8B, and Qwen3-8B, the attack remains effective when the cache hit rate is as low as 10% and the recomputation ratio rises to 50%, its influence persists after inserting more than 1000 irrelevant tokens, and a prefix optimized on Llama-3.1-8B still achieves 75% U-ASR and 37% T-ASR when transferred black-box to Llama-3.3-70B.

Why it was selectedThe authors point out that existing text-level defenses struggle to intercept this attack, which does not rely on malicious input text, and that inference services employing position-independent KV Cache reuse can use this to inspect their own attack surface.

Paper analysis

6 questions; open one to read the full answer

  1. What problem does this paper attempt to solve?

    The authors state that position-independent KV cache reuse introduces a new threat: hijacking model outputs across users without system privileges.

    Core problem: position-independent KV cache reuse introduces a new cross-user integrity attack surface in multi-tenant LLM services, and the authors propose the H IJACK KV framework to validate its exploitability.

    • Problem setting: KV cache reuse can reduce inference latency; traditional prefix reuse requires exact token and position matching and has a low hit rate; recent position-independent reuse (e.g., CacheBlend, EPIC) can reuse as long as the text block is identical, and engines such as vLLM enable cross-user shared caching by default.
    • Core observation: the KV state inherently depends on the context in which it was computed, and the same text block has different internal states under different prefixes. The authors report (Figure 2): a KV numerical deviation of about 20% can change the model output, while the deviation inherent to position-independent reuse is about 50% for key and 25% for value.
    • Gap in existing understanding: prior work treated this deviation only as a utility problem, using selective recomputation (refreshing 10–20% of the KV) to restore accuracy; the authors argue that this is also a security vulnerability.
    • What the paper proposes: the authors state that H IJACK KV is the first attack framework to systematically exploit this vulnerability, and give design recommendations for secure KV reuse systems.
    • Threat model (Section 4.1):
      • Goal: cause adversarially conditioned KV states to be stored and reused by future users, persistently affecting other users' model outputs; this is a cross-user integrity attack.
      • Capabilities: no system-level privileges; cannot read or write the cache, model weights, or system configuration, and cannot directly or indirectly modify the victim's query; can only submit inputs to the service and observe outputs.
      • Knowledge: needs to know that the target system uses position-independent KV caching and reuses it across users; does not need to know other users' queries, cache contents, model configuration, or block boundaries.
      • Settings: white-box (the local proxy model is the same as the target model, and gradients are available) and black-box (optimize on a local substitute model and then transfer).
  2. What related research exists?

    Related work is grouped into three categories: KV cache system optimization, KV cache attacks, and input-layer attacks; this paper differs from attacks that require system privileges or malicious text entering the input.

    KV cache efficiency optimization

    • CacheBlend [62]: block-level position-independent KV reuse for RAG, selectively recomputing a small number of tokens to mitigate utility loss; EPIC [14] and MEPIC [49] formalize position-independent KV caching and propose the LegoLink algorithm; KVShare [57] uses a two-stage high-deviation algorithm for selective recomputation.
    • PagedAttention [20] and SGLang [64]: achieve multi-tenant KV cache sharing via zero-copy mapping and a Radix Tree, respectively.
    • KV cache compression: two categories, quantization [12, 27] and selective pruning [26, 54, 63]; the paper notes that compression alone cannot prevent KV cache hijacking (cited in Section 8, with actual results in Section 7.6).

    KV cache attacks

    • Privacy leakage: Wu et al. [53] study prompt leakage from KV sharing in multi-tenant serving such as SGLang and vLLM; Luo et al. [29] study KV privacy leakage under three paradigms; Song et al. [45] find a timing side channel in shared caches.
    • Cache tampering: CacheTrap [31] uses bit flips to corrupt the value vectors of the KV cache to achieve targeted misclassification; HistorySwap [7] overwrites a contiguous segment of the active KV with a precomputed cache; MTI [13] adds noise to, zeroes, or rotates the cache key vectors. The paper notes that these attacks require system-level access to directly modify the cache, whereas the attack in this paper does not require system-level privileges.

    Input-layer attacks

    • Prompt injection [10, 25, etc.] and jailbreak attacks [3, 24, 52, 65, etc.]: both rely on malicious text appearing in the user input (directly or indirectly via retrieved content); the paper notes that the attack in this paper can control the output when the victim's input contains no malicious text at all.

    Baselines and benchmarks: the attack-side baselines are three prefixes (random prefix, instruction-style prefix, and plain-text error-message prefix, Table 8); the defense-side comparisons are RobustKV [17], CachePrune [50], and four cache compression methods [2, 23, 55, 63]; the benchmarks are HotpotQA, SQuAD v1.1/v2.0, MedQA, PubMedQA, and HumanEval.

    The authors position this paper as: hijacking model outputs by exploiting the KV reuse mechanism introduced by efficiency optimization, without requiring system privileges and without requiring malicious text to enter the victim's input.

  3. How does the paper address this problem?

    GCG is used to optimize an adversarial prefix on a local proxy model, so that the KV of a public text chunk encodes the attack target; once written into the shared cache, it hijacks victim queries that hit that chunk.

    Overall approach: H IJACK KV has two stages—the attacker locally optimizes an adversarial prefix p and submits p ⊕ X̃ to the LLM service, so that the KV of the public text chunk X̃ is computed under the condition of p and stored in the shared cache pool; afterward, when a victim query hits that chunk, even though p is not in the input, the model output is steered to the malicious answer r̃ specified by the attacker (Figure 3).

    Attack surface formalization

    • Prefix hit vs position-independent hit: Definition 1 defines a prefix hit (X is exactly identical to the first S tokens of the cached sequence X̃); the authors argue that under this premise the hit KV is numerically identical to the true KV, so prefix reuse is therefore safe; Definition 2 defines a position-independent hit (any contiguous segment Xa:b of X being identical to a contiguous segment X̃m:n of X̃ suffices).
    • Core inequality: under a position-independent hit the preceding context differs (X1:a−1 ≠ X̃1:m−1), and under the LLM injectivity assumption it necessarily follows that K̃m:n ≠ Ka:b and Ṽm:n ≠ Va:b, i.e., the hit cache deviates from the true state; on this basis the authors call position-independent KV caching "inherently unsafe".

    Optimization objective

    • Objective function: p∗ = argminp ℒCE(LLM(X ⊕ q ∣ TX̃p), r̃), where TX̃p is the KV cache of X̃ obtained by querying with p ⊕ X̃; the meaning is to find a prefix p that minimizes the cross-entropy loss of the victim query outputting the malicious answer r̃ when reusing the hijacked cache.
    • Choice of X̃: X̃ can be a frequently used context (e.g., FAQ text), and should be able to provide an answer to q, to increase attack success rate.

    GCG optimization procedure (Algorithm 1)

    • Main loop: iterate for T steps; each step computes the gradient of the loss with respect to the one-hot prefix, takes the top-k candidate tokens of the negative gradient at each position, randomly samples B positions for substitution to construct a candidate set, and greedily selects the one with the smallest loss to proceed to the next step.
    • Loss computation (C OMPUTE L OSS): (1) multiply the one-hot prefix by the embedding matrix to obtain continuous embeddings; (2) concatenate with the embeddings of X̃, pass through the model to compute KV, and slice out only the KV at the positions corresponding to X̃ (L+1 to L+|X̃|) as the hijacked cache, discarding the prefix's own KV—aligned with real systems that cache only document chunks and do not store the prefix; (3) simulate victim inference: X̃ ⊕ q generates output while reusing this cache; (4) compute cross-entropy between the output and r̃.
    • Robustness design: the attacker can reproduce recomputation or compression operations in step (3) of optimization, making the prefix more robust to these operations; the entire optimization is performed in a local simulator without touching the remote cache, and the proxy model's KV cache is cleared each round.

    Key parameters

    • Default hyperparameters (Section 7.5): prefix length Lp = Lchunk (taken as an integer multiple of Lchunk), GCG steps T = 250, top-k = 512, search width η = 0.5; system defaults δ = 0.3, ρ = 0.1, Lchunk = 32 (following [14, 62]).

    Success criteria

    • U-ASR: under attack the output y ≠ the normal output x; T-ASR: y = r̃ and y ≠ x (stricter); Acc: x equals the standard answer r, measuring utility preservation. The malicious answer r̃ is generated by an LLM according to three question types (yes/no questions take the negation, multiple-choice questions randomly select a wrong option, open-ended questions generate a wrong entity of the same part of speech/category); the generation prompts are in Appendix D.
  4. What experiments did the paper conduct?

    In the white-box setting, T-ASR under Vanilla is mostly 0.90–1.00, and the attack remains effective under low hit rates, 50% recomputation, multi-turn dialogue, and black-box transfer.

    Experimental setup

    • Models tested: RQ1 uses Llama-3.1-8B, Ministral-8B, Qwen3-8B; RQ4 transfer targets are Qwen3-4B/8B/14B, Llama-3.2-1B/3B, Llama-3.3-70B, with Llama-3.1-8B as the proxy model.
    • Datasets: HotpotQA, SQuAD v1.1, SQuAD v2.0, MedQA, PubMedQA, each randomly sampled 200 entries, constructed into (question, standard answer, context containing the answer) triples; the code task uses HumanEval.
    • KV system configurations: recomputation methods Vanilla (no recomputation), Random, EPIC, CacheBlend, plus Full (full recomputation) as the utility baseline; defaults δ = 0.3, ρ = 0.1, Lchunk = 32.
    • Metrics: Acc, U-ASR, T-ASR (definitions in Question 3); the paper does not state how answer matching is judged (rule-based or model-judged).
    • Threat model division: RQ1–RQ3 are white-box, RQ4 is black-box; the paper does not report the number of repeated experiments (Table 9 reports mean ± standard deviation over 5 paraphrases).
    • Environment: a server with 4 NVIDIA RTX PRO 6000 Blackwell GPUs.

    Main results

    T-ASR excerpt from Table 1 (RQ1, δ = 0.3, ρ = 0.1, Lchunk = 32, 200 samples per dataset):

    Swipe horizontally to read the table

    ModelMethodHotpotQASQuADMedQAPubMedQA
    Llama-3.1-8BVanilla1.000.960.900.92
    Llama-3.1-8BEPIC0.850.750.820.91
    Llama-3.1-8BCacheBlend0.890.850.800.86
    Ministral-8BVanilla1.000.931.000.94
    Ministral-8BEPIC0.950.781.000.87
    Qwen3-8BVanilla0.941.000.961.00
    Qwen3-8BEPIC0.870.860.840.93

    (According to Table 1; Random rows and Acc, U-ASR columns omitted, as are the CacheBlend rows for Ministral-8B/Qwen3-8B.)

    • The authors claim H IJACK KV shows strong attack performance in all scenarios, with an average T-ASR of 89% on Llama-3.1-8B across the four recomputation methods.
    • The authors claim EPIC and CacheBlend reduce ASR only slightly compared with Vanilla, and the current recomputation ratio is insufficient to mitigate the attack.
    • Utility cost: under Vanilla, Acc drops from 0.71–0.95 for Full to 0.54–0.75 (Table 1), i.e., position-independent reuse itself already harms task accuracy.

    RQ2: System configuration robustness (HotpotQA, Llama-3.1-8B)

    • Cache ratio δ (Table 3): at δ = 0.1, Vanilla T-ASR is 0.81 and EPIC 0.53; at δ = 0.5, T-ASR is 0.96–1.00 across methods. The authors claim that at δ = 0.1, ρ = 0.3 (malicious cache accounts for only 7% of the user's KV context), average T-ASR is still 67%; EPIC is relatively more effective at low cache ratios, which the authors attribute to it recomputing the first k tokens of each chunk.
    • Recomputation ratio ρ (Table 4): as ρ rises from 0.1 to 0.5, Random's T-ASR drops from 0.94 to 0.31, EPIC from 0.85 to 0.49, CacheBlend from 0.89 to 0.38; the authors claim average T-ASR is 70% at ρ = 0.3 and 39% at ρ = 0.5, and that raising ρ defends better than lowering δ.
    • Chunk size Lchunk (Table 2): from 32 to 512, T-ASR is basically stable across methods (e.g., Vanilla is constantly 1.00, Random goes from 0.94 to 0.90); the authors claim the slight decrease at large chunks stems from partial cache misses at chunk heads and tails.

    RQ3: Multi-turn persistence (Table 5)

    • Method: after hijacking, insert topic-irrelevant filler tokens before the target query (Lcontext from 0 to 2048).
    • Results: at Lcontext = 1024, Vanilla T-ASR is 0.63 and 0.46–0.58 across methods; at Lcontext = 2048, Vanilla is 0.48 and the rest 0.46–0.48. The authors claim average T-ASR is 55% at 1024 tokens and 47% at 2048, and that beyond a certain context length, doubling it only reduces T-ASR by a further 8%.

    RQ4: Black-box transfer (Table 6, proxy model Llama-3.1-8B)

    • Method: optimize the prefix on the proxy model, send malicious queries to the target model, and evaluate U-ASR/T-ASR under cache hits.
    • Results: transfer to Llama-3.3-70B gives T-ASR of 0.37 (Vanilla)/0.38 (CacheBlend); Qwen3-8B 0.33/0.38; Llama-3.2-3B 0.44/0.44; but for Qwen3-4B and Llama-3.2-1B, T-ASR drops to 0.09–0.18, while U-ASR remains about 0.85–0.97.
    • Authors' interpretation: citing the Platonic Representation Hypothesis, they argue that target models of similar or greater capability have representation spaces close to the proxy model, while small models' representation spaces diverge, making precise steering to r̃ difficult; U-ASR is high because the prefix can still perturb the KV cache, causing context hallucination.

    Other ablations and analyses

    • Prefix baseline comparison (Table 8): a GCG prefix of 32 tokens reaches 100% T-ASR; a random prefix of the same length 0.0%, an instruction-style prefix (average 10.9 tokens) 17.5%, and a plain-text misinformation prefix (average 103.4 tokens) 23.5%.
    • Query paraphrasing (Table 9): each HotpotQA query paraphrased into 5 semantically equivalent variants, T-ASR 94.0 ± 2.6%.
    • Code task (Table 10): on HumanEval, ASR at temperatures τ ∈ {0.3, 0.7, 1.0, 1.5} is 98.1%/96.9%/95.1%/92.0%, average 95.5%.
    • Attack hyperparameters (Figure 4): T-ASR rises with increasing prefix length; with GCG steps it first grows rapidly then saturates; top-k has an optimal candidate pool size; higher search width η gives higher T-ASR (only axes and legend are readable in the figure; specific values are not labeled).
    • Adaptive attack (Figure 5(a)): the authors claim adding 10% recomputation during optimization can raise ASR by up to 19%, and remains effective when the recomputation method/ratio does not match the target system.
    • Existing defenses (Figure 5(b)): the authors claim that even when RobustKV and CachePrune evict 50% of KV, T-ASR drops by only 19% (the figure caption states 79% T-ASR is maintained); under cache compression (Figure 5(c), [2, 23, 55, 63]), average T-ASR remains 97%.
    • Recomputation defense (Table 11): the Hybrid strategy gives T-ASR of 73.0%/54.5%/29.0%/11.5% at ρ = 0.2/0.4/0.6/0.8, with normalized cost 1.00x–3.53x; the Attn Score strategy gives 49.5%/35.5%/22.5%/13.0%, with cost 1.15x–4.02x.
  5. What are some points that can be further explored?

    The authors discuss three practical constraints—cache availability, probing self-pollution, and eviction policy—and recommend trace-driven evaluation.

    Limitations and future directions noted by the authors

    • Cache availability trade-off (Section 8): the attack's practicality depends on whether the hijacked KV can enter the shared cache and be reused before being evicted or overwritten; popular chunks are more likely to appear in victim contexts but may already have benign caches, while unpopular chunks are easy to insert but hard to reuse, so the authors claim the attack is most practical for content with a moderate degree of sharing.
    • Side effects of cache occupancy probing (Section 8): probing is not entirely passive; probe queries may insert, refresh, or evict cache entries, causing self-pollution and changing the cache state before the attack; the authors suggest using a small probing budget in actual attacks.
    • Eviction policy and applicability (Section 8): attack feasibility depends on the cache replacement policy (FIFO/LRU/LFU affect the insertion window); it is less applicable to chunk-then-cache RAG pipelines (chunks encoded independently); the authors claim a complete evaluation requires trace-driven evaluation under real workloads and eviction policies.
    • Defense directions (Recommended Future Safeguards in Ethical Considerations): the authors suggest future systems adopt hybrid mechanisms (recompute high-impact KV and compress irrelevant entries so that user-computed data makes up the majority of the cache) and deviation-based rejection policies (reject reuse when recomputation finds deviation exceeds a safety threshold).

    Scope of experimental coverage

    • 8 models tested in total: Llama-3.1-8B, Ministral-8B, Qwen3-4B/8B/14B, Llama-3.2-1B/3B, Llama-3.3-70B, with parameter sizes 1B–70B, all open-source models.
    • Evaluation tasks are 4 QA benchmarks (200 samples each) plus HumanEval code generation; KV system configurations cover 3 recomputation methods and parameter sweeps over δ, ρ, Lchunk.
    • Defense evaluation includes RobustKV, CachePrune, four cache compression methods, and two recomputation strategies, Hybrid and Attn Score (ρ up to 0.8).
    • All experiments use public datasets and public or locally deployed models, conducted in a controlled offline environment, with no interaction with real users and no testing of production services (Ethical Considerations).
    • The paper does not report the number of attack queries, optimization time, or number of repeated experiments; how answer matching is judged (rules or a judge model) is not stated in the paper.
  6. Summarize the main content of the paper

    The authors propose and validate a cross-user hijacking attack against position-independent KV cache reuse, which existing defenses and compression methods cannot eliminate.

    A systems security attack paper: targeting position-independent KV cache reuse and multi-tenant cache sharing introduced to reduce inference latency, the authors propose H IJACK KV, which they state is the first KV cache hijacking attack that requires no system-level privileges and no malicious text entering the victim's input.

    • Problem addressed: position-independent reuse retrieves cached entries by token matching, but the KV encodes the original context; the authors report that a KV numerical deviation of about 20% can change the output, while the deviation inherent to this reuse mechanism is about 50% for key and 25% for value (Figure 2), constituting an exploitable attack surface.
    • Method summary: the attacker uses GCG on a local proxy model to optimize an adversarial prefix so that the KV of a public text block computed after concatenating the prefix encodes the attack target; submitting this query writes the hijacked KV into the shared cache pool, and subsequent victim queries that hit this block are steered to the attacker-specified answer.
    • Main results: in the white-box setting, Llama-3.1-8B achieves T-ASR of 0.90–1.00 on four datasets under the Vanilla setting (Table 1); with δ = 0.1 and ρ = 0.3, the average T-ASR is still 67%; when ρ is increased to 0.5, the average T-ASR is 39% (Table 4); after inserting 2048 tokens of irrelevant context, T-ASR is still 46%–48% (Table 5); black-box transfer to Llama-3.3-70B gives T-ASR of 37% (Table 6), but transfer to Qwen3-4B and Llama-3.2-1B drops T-ASR to about 13%.
    • Defense evaluation: the authors state that when RobustKV and CachePrune evict 50% of the KV, T-ASR drops by only 19%, and under cache compression the average T-ASR remains 97%; a high recomputation ratio (Hybrid, ρ = 0.8) can push T-ASR down to 11.5%, at the cost of 3.53× recomputation overhead (Table 11).
    • Authors' conclusion: position-independent KV reuse involves a key trade-off between efficiency and security, and existing defenses, recomputation, and compression methods cannot eliminate this threat; the authors call on the community to design KV reuse systems whose efficiency does not come at the cost of security, and recommend hybrid recomputation-compression mechanisms and deviation-based rejection strategies.

Related papers

Show 3 more papers
Read originalUSENIX Security 2026