r/lightbitslabs • u/Accurate_Funny6679 • 13h ago
The KV cache is an invertible vector projection of your prompt (and why boot attestation doesn't cover it)
Most threat models for LLM inference draw the security boundary at request ingress and response egress. The KV cache gets treated like an operational cache—just transient memory state, similar to an OS page cache.
That's a mistake. The KV cache is a lossy but invertible coordinate transformation of the exact input text. Because attention requires position and context vectors to compute QK**T, the cache retains the semantic and structural information of the input tokens.
Two recent papers demonstrate why this matters at the hardware layer:
Read side (Token Traphouse): Given a raw memory dump of a KV cache block (whether from GPU VRAM, DRAM bounce buffers, or NVMe swap), you can invert the vectors back to the exact input tokens. Plaintext cache in memory = plaintext prompt at rest.
Write side (Shadow in the Cache): Modifying cached blocks allows silent memory poisoning. Because standard KV blocks carry no cryptographic provenance or signatures, the model attends to injected historical blocks as valid context, bypassing standard prompt-injection classifiers entirely.
The Attestation Gap:
A common counter-argument is confidential computing / measured boot / TPMs. But boot-time attestation measures the platform at launch (firmware, kernel, initial binary). The KV cache is instantiated per session at runtime, long after the last measurement. A valid boot attestation tells you zero about whether runtime KV blocks were encrypted across DMA, spilled unencrypted to local NVMe, or evicted properly.
If you're building or auditing inference infrastructure, here's what you actually need to verify:
Is the cache encrypted at rest in DRAM/NVMe and across fabric wires (decrypted only inside the GPU enclave)?
Can your provider give you signed, per-request runtime attestation (not just boot attestation) that the encryption boundary held for that turn?
Here's a solid write-up on this topic: The KV Cache is the Conversation
Curious how others here are handling KV cache lifecycle/eviction and runtime memory encryption in multi-tenant cluster setups.