KV ML Systems Security Brief

KV-cache reuse · security analysis

Securing Non-Prefix KV Cache Reuse

A cache hit confirms that the text matches, not that the context, conditioned KV state behind it is safe to reuse.

Lessons from HijackKV USENIX Security 2026 Position-independent KV Reuse

HijackKV paper information

HijackKV paper title, authors, and affiliations

Accepted at USENIX Security 2026, Paper · Code and artifacts We thank Dr. Junchen Jiang, CEO and Co-Founder of Tensormesh, for valuable discussions and feedback.

USENIX Artifact Available, Functional, and Reproduced badges

Same text does not mean same state

Non-prefix KV-cache reuse makes a useful bet: if the same text chunk appears in two prompts, part of the chunk’s earlier computation can be reused.

Logos representing the widespread deployment of KV caching across major AI systems
Figure 1.KV cache is widely deployed.

CacheBlend-style reuse makes this practical by retrieving a chunk’s cached KV state and selectively recomputing tokens under the new context.

Animated diagram of normal position-independent KV-cache reuse across two benign users
Figure 2.Two benign requests share an identical text chunk. The system reuses its cached KV state and repairs part of the context mismatch through selective recomputation.
HijackKV shows where that bet breaks: the cache lookup matches the chunk’s text, but the object being reused is a context-conditioned KV state.

HijackKV, accepted at USENIX Security 2026, turns non-prefix reuse from a matching problem into a trust problem. The state depends not only on the matched chunk, but also on the context that preceded it.

The missing binding

With strict prefix caching, the cached token sequence is tied to the preceding tokens in the same prefix. Position-independent reuse deliberately relaxes that restriction so the same document, code file, or agent skill can be reused at different prompt positions.

The optimization assumes that the old and new contexts are merely different. HijackKV considers an adversarial old context. A malicious prefix can change the KV representation of an otherwise unchanged chunk; matching the chunk later can retrieve a state influenced by that prefix.

Animated diagram showing a malicious prefix changing the KV state of unchanged text
Figure 3.Text Chunk 2 is unchanged, but its cached representation is not. Token equality therefore does not authenticate the associated KV state.
Core systems insight: token-content matching is insufficient when the cached value is context-conditioned.

Under the paper’s threat model, the cache key identifies the matched token sequence—but not who produced the state, under which preceding context, or whether that context was trusted.

The attack

HijackKV assumes a multi-tenant service with a shared position-independent KV-cache pool. The attacker is an unprivileged user: they cannot directly edit cache tensors, change the model, or modify the victim’s prompt.

The attacker chooses a benign chunk likely to be reused and optimizes a prefix that conditions the chunk’s KV state toward a target output. The optimized prefix and chunk are then submitted together to seed the shared cache.

Animated diagram of the HijackKV attack workflow
Figure 4.The attacker conditions and publishes a cache entry; a later text match can transfer that state into a benign user’s inference.

A victim later retrieves the same benign text chunk, causing the system to reuse its cached KV state. The malicious prefix was used only to create the cache entry and is then discarded—it never appears in the victim’s prompt and is not itself reused. Its influence, however, persists in the retrieved state.

What the findings show

HijackKV reports targeted attack success rate (T-ASR), a strict metric that counts an attack as successful when the attacked response matches the attacker-designated target answer and differs from the benign response.

94%average T-ASR with one cache-seeding attempt
80–100%T-ASR across evaluated 8B models under the main setup
3.53×recomputation cost for the stronger hybrid defense

Invisible at the text boundary

The victim prompt can remain entirely benign, leaving a victim-side scanner with no malicious token sequence to remove.

Broad coverage

The study spans general and medical QA, code generation, models from 1B to 70B, and multiple reuse settings.

Effective on code

On HumanEval, average T-ASR was 95.5% across decoding temperatures.

Persistent and transferable

The effect survived unrelated intervening context and transferred across model families without target-model gradients.

Recomputation alone is costly

At 50% recomputation, average T-ASR was still 39%. A stronger hybrid strategy reduced it to 11.5% at 80% recomputation, but incurred 3.53× recomputation cost.

The lesson is not simply “recompute more.” A quality repair asks whether reuse preserves average answer quality; a security check must ask whether an untrusted producer can control the residual error.

What they mean, and what they do not

HijackKV evaluates CacheBlend-style position-independent KV reuse under online, cross-user position-independent cache reuse in which cached chunks may inherit attacker-controlled preceding context.

What the paper does not show However, it does not demonstrate that TensorMesh’s production service was compromised or that customer data was exposed. All experiments were conducted offline using public datasets and locally deployed models.

Practical exploitability depends on deployment conditions that the study does not observe:

  • Whether untrusted requests can publish entries to a shared cache pool.
  • Whether a victim matches a malicious entry before it is evicted or overwritten through trusted pre-warming.
  • How cache admission, replacement, quotas, and namespaces are configured.
  • How accurately an attacker can predict shared content and transfer an optimized prefix to the deployed model.

Strict prefix caching, cache isolation by user, and RAG pipelines that independently precompute trusted document chunks before serving eliminate this attack path.

A safer reuse boundary

The strongest design principle is to prevent untrusted state from silently becoming shared state.

Isolate publication

Do not let untrusted requests populate caches used by other users.

Track provenance

Reuse state only when its source is compatible with the current request.

Verify before reuse

Compare selected cached states with a small fresh computation and reject unsafe deviation.

Rate limits, quarantine windows, cache-lineage logs, anomaly detection, and rapid invalidation can narrow the attack window, but they do not replace isolation and verification.

Resources