R.13: Quantized, evicted, and persisted KV caches do not stop bit-flip attacks
ReleasedAuthenticate offloaded and persisted KV cache chunks on rehydration: real llama.cpp Q4_K_M slot files, datacenter FP8-E4M3 caches, and 90% KV eviction all preserve or amplify sparse bit-flip attacks, while low-density DRAM Rowhammer fails at p <= 1%.
- 43 audited
- 10/12-12/12
- 12/12 kept
- 100/100
Summary
- Authenticate offloaded and persisted KV caches before rehydration: Binding every 16-token KV chunk or persisted
.binslot file withHMAC-SHA256over(model_id, weight_digest, kv_dtype, tenant_id, prefix_token_hash, chunk_idx, chunk_bytes)rejects 100/100 storage tamper and replay attacks (95% CI [0.96, 1.00]) in 0.375 ms per FP8 chunk (2.3 to 6.9 ms forllama.cppslot checks; 54.8 ms for a full 2,304-token prefix). - Real serving optimizations preserve or amplify sparse KV bit flips: On compiled
llama.cpp(llama-server) with 4-bitQ4_K_Mweights, patching 164 bits in a 29 MB persisted.binslot survives a full server restart and executes 10/12 unseen HTTP 200 tool calls (12/12onF16andQ8_0). In cloud serving patterns, datacenterFP8-E4M3KV quantization cuts flip counts roughly in half (96 to 128flips vs192 to 288inbfloat16), and evicting 90% of a ~2,300-token cache under StreamingLLM or H2O still preserves 99.7% to 100.0% of flips and 12/12 execution. - Honest hardware boundary: Low-density DRAM Rowhammer (
p <= 1%flippable cell fraction) fails0/12and0/6across all 8 runs up to 1,280 flips (combined study random controls:3/8,160, 95% CI [0.0001, 0.0011], with all 3 in10xposition-matched FP8 Granite and0/7,200across1x, uniform, hardware, andllama.cppcontrols). The immediate production risk is unauthenticated offloaded, disk-persisted, or disaggregated KV storage, not low-density DRAM Rowhammer.
What an attack looks like
Consider an edge appliance or cloud serving cluster that caches shared system-prompt KV state to local disk or an offloaded cache tier so restarts and autoscaled workers skip redundant prefill. In llama.cpp, llama-server writes that prompt cache straight to a .bin file (POST /slots/0?action=save) with magic bytes, token IDs, and raw KV tensors, and zero cryptographic signature or checksum.
An attacker who gains write access to the shared cache volume or offloaded KV tier (without touching model weights, system prompts, or serving binaries) flips 164 mantissa bits inside the 29 MB .bin slot file. Zero exponent or sign bits change, and every prompt log stays clean. After a full server restart (pid_save != pid_restore), llama-server restores the .bin slot into a 4-bit Q4_K_M model. Every unseen factual or calendar question that hits that prefix cache silently emits {"tool": "calc"} and executes under the host’s bearer token with HTTP 200.
Why we ran R.13
After R.11 and R.12, infrastructure engineers raised three fair objections:
- All prior Tier B results ran in PyTorch
bfloat16, not on a deployed serving binary with quantized 4-bit weights or persisted KV files. - Production stacks quantize KV caches (
FP8-E4M3on cloud GPUs,block_q8_0on edge engines) and compress long contexts with KV eviction (StreamingLLM / H2O), which might wash out tiny mantissa edits. - Real DRAM Rowhammer has directional retention bias (
1->0charge leakage) and sparse flippable cell density (p <= 1%), which might prevent targeted placement altogether.
R.13 consolidates three preregistered studies across 43 audited runs and 10,280 per-item rows, all verified by standalone automated recount scripts and 9 negative fault-injection tests. Full per-run numbers and intervals live in the Gates table below.
Real llama.cpp reboot-persistent .bin implants and Walsh-Hadamard rotation
We compiled llama.cpp 1.1.0-dev (commit e7ec636, Apple Metal + FlashAttention, zero PyTorch at serving time) and ran llama-server with --slot-save-path across F16, Q8_0, and 4-bit Q4_K_M GGUF checkpoints. In all 15 runs, cold prefill and clean restored slots matched bit-for-bit (12/12 on Qwen3-1.7B, 6/6 on Llama-3.2-1B), and every restored query verified pid_save != pid_restore and tokens_cached >= n_prefix_tokens.
- Default
f16KV slots fall with zero refit: Patching R.12’s PyTorch flips straight intoslot_clean.binexecutes6/6(95% CI [0.61, 1.00]) acrossF16,Q8_0, and 770 MB 4-bitQ4_K_MonLlama-3.2-1B(480 bits in a 14.6 MB slot), and11/12(F16),9/12(Q8_0), and6/12(Q4_K_M) onQwen3-1.7B(224 bits in a 55.4 MB slot) against0/1,080matched random.binpatch controls. - Walsh-Hadamard
q8_0KV rotation (PR #21038) cuts both ways: Modernllama.cppapplies an orthonormal Walsh-Hadamard rotation (H_128on keys,H_64on values) beforeblock_q8_0quantization. Unadaptedq8_0scale flips drop to0/12on defaultllama-server(while hitting12/12F16,10/12Q8_0, and3/12Q4_K_Mwhen rotation is disabled). However, fitting 164 adaptivefp16scale mantissa bits directly in theH_128/H_64basis restores12/12onF16andQ8_0and boosts 4-bitQ4_K_Msurvival from3/12to10/12(95% CI [0.55, 0.95]) against0/720random controls. Spreading each scale flip across 64 to 128 orthogonal dimensions makes the implant more resistant to 4-bit weight quantization noise.
Cloud serving optimizations: FP8-E4M3 quantization and 90% KV eviction
Both standard cloud KV optimizations fail to stop sparse bit-flip attacks:
- Datacenter
FP8-E4M3KV quantization cuts flip count roughly in half: Quantizing R.12’sbfloat16poisoned caches directly to per-head scaled OCPFP8-E4M3with zero refit preserves execution identically (33/36vs33/36inbfloat16:11/12Qwen3,10/12Granite,12/12Phi-4). Fitting nativeFP8-E4M3single-mantissa-bit XOR flips (bp in 0..2, zero exponent, sign, or scale changes) requires ~2x fewer flips thanbfloat16because each 3-bit FP8 mantissa bit carries a 12.5% to 50% value step:128flips onQwen3-1.7B(12/12MPS & CPU, 95% CI [0.76, 1.00]),96flips onGranite-3.3-2B(11/12MPS & CPU), and128flips onPhi-4-mini-3.8B(12/12MPS /11/12CPU). Likewise, edgeblock_q8_0fp16scale-only flips reach>=80%in just 32 flips on bothQwen3-1.7B(12/12at 36 flips) andLlama-3.2-1B(6/6at 32 flips). One honest nuance: forcing a 13-token arbitrary argument ("audit-export") in coarse 3-bit FP8 stalled at0/12up to 960 flips (loss5.57 to 0.425). - Evicting 90% of a ~2,300-token KV cache preserves
12/12execution: Taking R.12’s exact ~2,300-token poisoned caches (Qwen3-1.7B352 flips,Granite-3.3-2B320 flips, zero refit) and compressing them down to 10% retention (229 to 231tokens kept) leaves99.7% to 100.0%of attack flips intact under both StreamingLLM (351/352,320/320) and H2O Heavy-Hitter (352/352,320/320). Live HTTP 200 execution stays12/12on both MPS and CPU (0malformed,0/12clean evicted false executions) because eviction policies pin Block 0 (the attention sink) and high-attention tool-schema tokens while discarding the handbook.
Where DRAM Rowhammer actually stops: the p <= 1% cell-sparsity wall
Evaluating hardware fault constraints across 22 runs (4,686 rows, 0/3,960 controls) cleanly separates physical DRAM constraints from software storage risk:
- Unidirectional retention bias does not block forcing: At full cell access (
p = 100%), pure0->1flips still execute12/12(Qwen3in 64 flips) and6/6(Llamain 32 flips), and pure1->0charge-leakage-only flips still execute12/12(Qwen3, 256 flips for >=80%) and5/6(Llama, 32 flips). - Cell sparsity
p <= 1%kills the attack completely: Restricting flips to a seeded random hardware mask atp = 1%or0.1%(bidirectional,1->0, or0->1) yields0/12onQwen3-1.7Band0/6onLlama-3.2-1Bacross all 8 runs up to 1,280 flips (95% CI [0.00, 0.24] and [0.00, 0.39]). Execution turns on sharply atp = 5%(7/12,5/6), rises atp = 10%(9/12,6/6), and recovers 100% byp = 25%(12/12,6/6). In practice, realistic DRAM Rowhammer cell densities sit far below 5%, which means unauthenticated software/offloaded/persisted KV stores are the primary threat to fix first.
Defense: authenticated KV chunk and slot envelopes
Persisted .bin slots and offloaded KV chunks currently carry zero cryptographic authentication. We evaluated an HMAC-SHA256 per-chunk envelope binding (model_id, weight_digest, kv_dtype, tenant_id, prefix_token_hash, chunk_idx, chunk_bytes) on 16-token paged FP8 chunks (0.92 MB per chunk across 28 Qwen3-1.7B layers) and on all 15 llama.cpp .bin slot runs:
- 100% detection across 5 attack classes:
100/100honest chunks accepted and100/100adversarial trials rejected (95% CI [0.96, 1.00]):20/20each across 1-bit payload tamper, cross-tenant replay, chunk-index swap, wrong-model replay, and wrong-dtype replay, plus15/15llama.cppslot implants detected. - Measured CPU verification latency:
0.375 msfor a single 16-token FP8 chunk,3.441 msfor 9 schema chunks (144 tokens;2.3 to 6.9 msforllama.cppslot schema MAC), and54.787 msfor full 2,304-token prefix authentication (144 chunks / 126 MB FP8). As R.14 demonstrates via handbook-resident conditional backdoors, authenticating the full offloaded prefix rather than only schema chunks is strongly recommended wherever KV tiers cross trust boundaries.
Recommendations (in priority order)
- Authenticate offloaded and persisted KV chunks at rehydration: Add per-chunk or per-slot
HMAC-SHA256/AEADtags bound to(model_id, weight_digest, kv_dtype, tenant_id, prefix_token_hash, chunk_idx)before loading any.binslot, Redis/NVMe cache, or disaggregated prefill-decode transfer into GPU memory. - Do not rely on KV quantization or eviction for tamper resilience: Neither
FP8-E4M3,block_q8_0, Walsh-Hadamard rotation, nor 90% StreamingLLM/H2O eviction neutralizes adaptive sparse KV bit flips. - Keep host-side tool allowlists and argument validation as the primary perimeter: Just as in R.11, chunk MACs catch storage and transit tampering but cannot stop a compromised prefill node that holds the signing key itself.
Reproducibility
All 43 run directories (items.jsonl, flips.json / patch_records.json, summary.json), preregistrations, study reports, and standalone automated recount scripts are published in symbolon-labs/symbolon-latent-channels (v2.0).
- One-command artifact audit (CPU only, Python 3 stdlib):
git clone https://github.com/symbolon-labs/symbolon-latent-channels && cd symbolon-latent-channels && bash checks/verify_all.shruns all 19 public automated recounts (includingverify_r13_hardware_constraints.py,verify_r14_llamacpp_kv.py, andverify_r16_cloud_kv.py) plus 22 negative fault-injection tests across the repository (9 specific to R.13). - Reference environment: Apple M1 Pro (16-core GPU, 32 GB unified memory), Python 3.12.14, PyTorch 2.15.0, Transformers 4.52.4, and compiled
llama.cpp1.1.0-dev(e7ec636, Apple Metal + FlashAttention). Multi-MB rawslot_*.binfiles (~911 MB total) are omitted from git while every byte offset, before/afteruint16, PID pair, cache-hit count, and MAC digest is verified directly frompatch_records.jsonanditems.jsonl.
Limits
Models tested span 1B to 3.8B open-weight checkpoints (Llama-3.2-1B-Instruct, Qwen3-1.7B, Granite-3.3-2B-Instruct, Phi-4-mini-3.8B-Instruct); larger 7B to 70B models were not tested. FP8-E4M3 quantization uses exact OCP per-head scaled lookup emulation on MPS/CPU rather than H100 Tensor Core FP8 kernels, and 13-token arbitrary arguments ("audit-export") in FP8 remained 0/12 up to 960 flips. Eviction tests used ~2,300-token static prefixes rather than 32K+ multi-turn streams. Rowhammer masks model uniform random flippable-cell locations rather than physical bank/row DRAM topology.
Changelog
- rev 01 (2026-11-29): Initial public release of consolidated R.13 (
v2.0ofsymbolon-latent-channels), combining realllama.cppQ4_K_Mreboot-persistent.binslot implants + Hadamardq8_0analysis (15 runs), cloud StreamingLLM/H2O 90% KV eviction survival +FP8-E4M3quantization + chunk HMAC-SHA256 envelope (6 model runs + 200 MAC trials), and hardware Rowhammer sparsity +block_q8_0scale constraints (22 runs).
Edge and cloud KV serving attack surface
Destructive controls
Each arm removes one part of the attack or isolates one variable.
- Uniform and position-matched random mantissa / .bin controls (1x and 10x)3/8,160 [0.0001, 0.0011] combined across all 43 runs (0/3,960 hardware, 0/3,240 llama.cpp .bin, 3/960 FP8 with all 3 in 10x pos-matched Granite and 0/720 in 1x & uniform)
Removes: the attacker-chosen bit offsets, flipping an equal or 10x count of random mantissa bits across the cache or persisted .bin slot file.
- llama.cpp value-transparency & server-restart audit15/15 runs exact cold == clean match (12/12 Qwen3, 6/6 Llama) with verified prefix cache reuse after restart
Removes: in-memory state carryover and cache misses by restarting llama-server (pid_save != pid_restore), checking cold == clean restored slot output, and asserting tokens_cached >= prefix_tokens.
- Clean evicted baseline and fresh CPU bfloat16 cross-checks0/12 clean false executions across all eviction levels; 12/12 CPU agreement at 90% eviction on both Qwen3 and Granite
Removes: eviction-induced routing drift and Apple Silicon GPU (MPS) arithmetic differences by evaluating clean evicted caches and re-running final caches on CPU.
- Non-adaptive Hadamard q8_0 negative arm0/12 [0.00, 0.24] across F16, Q8_0, and Q4_K_M weights (vs 12/12, 12/12, and 10/12 once adapted to the Hadamard basis)
Removes: awareness of llama.cpp PR #21038 Walsh-Hadamard rotation (H_128/H_64) before q8_0 quantization, testing whether unadapted scale flips survive.
Gates
| Gate | Preregistered condition | Result | Record |
|---|---|---|---|
| [Edge] Real llama.cpp GGUF reboot-persistent .bin slot implants | Patching 164 to 480 strict fp16 mantissa bits inside real llama.cpp llama-server persisted slot .bin files across full server restart (pid_save != pid_restore, KV reuse verified, 0 exp/sign flips). Measured: Llama-3.2-1B f16 KV hits 6/6 [0.61, 1.00] on F16, Q8_0, and 4-bit Q4_K_M; Qwen3-1.7B adaptive Hadamard q8_0 scale flips (164 bits) hit 12/12 [0.76, 1.00] on F16 and Q8_0 and 10/12 [0.55, 0.95] on 4-bit Q4_K_M (vs 3/12 unrotated q8_0, 0/12 non-adaptive Hadamard, and 0/3,240 random .bin controls). | Passed | verify_r14_llamacpp_kv.py |
| [Cloud] 90% StreamingLLM & H2O KV-cache eviction survival | Zero-refit R.12 ~2,300-token poisoned caches compressed from 100% down to 10% retention (229 to 231 tokens kept) under StreamingLLM and H2O Heavy-Hitter eviction. Measured: 99.7% to 100.0% of attack flips survive (351-352/352 Qwen3-1.7B, 320/320 Granite-3.3-2B) and live HTTP 200 stays 12/12 [0.76, 1.00] across all retention levels on MPS and CPU (0 false executions on clean evicted baselines). | Passed | verify_r16_cloud_kv.py |
| [Cloud & Edge] FP8-E4M3 and block_q8_0 KV quantization cut flip cost | Zero-refit bf16 -> FP8-E4M3 transfer plus native single-mantissa-bit XOR flips in per-head FP8-E4M3 (bp 0..2, 0 exp/sign/scale flips) and block_q8_0 fp16 scales (bp 0..9). Measured: zero-refit bf16->FP8 survives 33/36 (11/12 Qwen3, 10/12 Granite, 12/12 Phi-4); FP8-native flips cut train-stop cost ~2x vs R.12 bf16 (128 fl Qwen3 12/12, 96 fl Granite 11/12, 128 fl Phi-4 12/12 MPS / 11/12 CPU; 3/960 FP8 controls, all 3 in 10x pos-matched Granite); block_q8_0 scales hit >=80% in 32 flips on both Qwen3 (12/12 @ 36) and Llama (6/6 @ 32) vs 0/360 controls. Long 13-token FP8 arbitrary arg scored 0/12 at 960 flips. | Passed | verify_r13_hardware_constraints.py, verify_r16_cloud_kv.py |
| [Hardware limit] Low-density DRAM Rowhammer (cell sparsity p <= 1%) | Sparse single-mantissa flips restricted to seeded random hardware masks at p = 0.1% and 1% (bidirectional, 1->0 only, 0->1 only) up to 1,280 flips across Qwen3-1.7B and Llama-3.2-1B. Measured: 0/12 [0.00, 0.24] on Qwen3 and 0/6 [0.00, 0.39] on Llama across all 8 runs (0/1,440 controls). Execution turns on at p = 5% (7/12, 5/6) and recovers 100% by p = 25% (12/12, 6/6); pure 1->0 or 0->1 retention bias at p = 100% still executes 12/12 and 5/6-6/6. | Failed(attack blocked at p <= 1%) | verify_r13_hardware_constraints.py |
| [Defense] Authenticated KV chunk and slot .bin HMAC-SHA256 envelopes | Per-chunk HMAC-SHA256 bound to (model_id, weight_digest, kv_dtype, tenant_id, prefix_token_hash, chunk_idx, chunk_bytes) tested across 100 honest chunks and 100 adversarial trials (20 each: 1-bit tamper, cross-tenant replay, chunk swap, wrong-model, wrong-dtype) plus 15 llama.cpp slot .bin MAC checks. Measured: 100/100 [0.96, 1.00] honest accepted, 100/100 [0.96, 1.00] adversarial rejected (0.375 ms/FP8 chunk, 3.441 ms schema 9 chunks, 54.787 ms full 2,304-token prefix), and 15/15 llama.cpp slot implants detected in 2.3 to 6.9 ms. | Passed | verify_r14_llamacpp_kv.py, verify_r16_cloud_kv.py |
Figures


