INT8 tolerance hijacks 98-100% of queries and cuts Pi 5 accuracy from 0.75 to 0.39

Signed but Steerable: Measuring and Closing the Text-Vector Integrity Gap in Offline Retrieval-Augmented Generation

Georgios Feretzakis, Alexandros Papaspyridis

cs.CR, cs.IR, cs.LG

2026-11-04

The margin law converts a cosine tolerance into a hijack rate. An INT8 threshold exposes 98-100% of queries on five corpora; Pi 5 accuracy falls from 0.75 to 0.39.

What problem this solves

Offline RAG on a disconnected device is updated by a signed knowledge pack. The pack carries text plus precomputed embeddings, because a Raspberry Pi 5 CPU needs about 29 minutes to embed 950 passages.

The signature shows who published those bytes. It does not show that a vector is the embedding of its text. A compromised build pipeline, or an insider allowed to add passages, can ship text that passes review and vectors that pull retrieval toward a chosen passage. Defenses that look for malicious wording see nothing, because the words are clean.

Method

A cosine tolerance τ is an angle α = arccos τ. When the gold unit already ranks first, the angular margin is the gap to the nearest non-relevant unit. The strongest attacker rotates that competitor toward the query by α. Rank 1 flips if the margin is shorter than α, so the hijack rate is just the share of queries with a shorter margin. That identity is the margin law. Honest vectors and a query log are enough to evaluate it. On a 300-question set the law and a simulated attack differ by 0 at every tolerance.

The rate is per query: some edit of one vector can steal rank 1 for that query. Reported figures use one rotation, budget α. Rotating the gold unit as well raises the budget to 2α.

SQ8 and SQ4 round each coordinate onto a few levels. Product quantisation keeps, for each sub-vector, only the id of the nearest codebook centroid. Binary codes keep the sign. Reconstruction error runs from under a degree to tens of degrees. An audit that must accept every honest vector inherits that angle as an attack budget.

Checking codes takes the budget back. The verifier quantises its own embedding with a trusted codebook. A neighbouring code is allowed only where the verifier itself sees that float noise could cross a rounding boundary, the guard band. Accepted entries are then overwritten with the verifier's codes, called canonicalisation. The publisher has no code left to choose.

Results

Five corpora, SQuAD 2.0, SciFact, NFCorpus, FiQA and ArguAna, and two embedders, BGE-M3 and all-MiniLM-L6-v2. Median margins sit around 2.1° to 7.4°. The table covers SQuAD queries whose gold unit already ranks first: 3,648 passages for BGE-M3 and 3,301 windows of 128 tokens for MiniLM. That denominator is 78% and 70% of answerable questions.

ToleranceAngleBGE-M3MiniLM
Exact equality0°0%0%
FP32, x86 vs ARM0.04°0.49%0.24%
τ = 0.9992.56°24.6%16.8%
CPU INT8 reference (cosine 0.904)25.3°100%98.4%

The INT8 reference is the 0.1% quantile of dynamic-INT8 versus FP32 cosines for all-MiniLM-L6-v2 on the Pi: 1,745 windows, four threads, batch 32. Using the same angle on BGE-M3 is a sensitivity check, not a tolerance measured for that model. An attacker who misses the exact wording and only knows other questions about the passage still hijacks 81.2% (BGE-M3) and 44.0% (MiniLM).

At float-noise tolerance, 0% to 5.5% of queries are exposed across the five corpora. After documents with identical text are removed, the worst cell is ArguAna with BGE-M3 at 5/420 (1.2%); SciFact is 0. The INT8 threshold exposes 98.7% to 100%.

Set the tolerance at each format's largest honest reconstruction angle and the margin law gives FP16 0% to 5.2%, SQ8 2.0% to 14.5%, SQ4 55% to 89%, PQ 99.7% to 100%, and binary 100%. On a FAISS IndexPQ over all 57,638 FiQA documents, tampered codes for 60 targets all passed the check, and the attacker's document ranked first under the index's own inner product for 25% (95% interval 16% to 37%). Code checks plus canonicalisation blocked all 60. On that store the margin-law exposure is 8.3% for SQ8 and 100% for PQ and binary.

On a desktop GPU and x86 CPU, an Apple M2, and the Pi's ARM CPU, a calibrated guard band accepted every honest vector in the samples. Exact SQ8 equality holds for about 99% of MiniLM vectors and 91% of BGE-M3 vectors; the guards that close the rest are about 3×10⁻⁷ and 3×10⁻⁶. At those widths the publisher's best ambiguous codes hijack 0 queries for MiniLM and at most 0.16% for BGE-M3 SQ8. Canonicalisation removes the residual. FP32 between x86 and ARM moves by at most 0.04°, and dynamic INT8 moves by up to 0.03 when other inputs share the batch. Neither pipeline is bit-reproducible.

On the Pi 5, Qwen2.5-3B-Instruct (Q4KM) scores 0.75 correct and 0.13 refusals with no attack. The attack adds one fixed editorial note saying the requested information is not in the collection. At τ = 0.999 accuracy stays 0.74 and the note enters the top 3 on 2% of questions. At the INT8 threshold it enters on 94%, accuracy falls to 0.39, refusals rise to 0.50, and wrong answers are 0.11. Re-embedding 1,745 windows takes 72.9 s in FP32 and 41.6 s in INT8. Checking 8 pairs per second beside decoding costs 22.9% to 31.4% of decode speed (baseline 5.14 tokens/s) and raises p99 inter-token latency by 108% to 167%.

Three pre-registered checks failed. For answerable versus in-topic unanswerable questions, SQuAD AUROC is 0.69 for a bi-encoder, 0.63 for a cross-encoder, and 0.86 for an extractive QA no-answer margin; on MS MARCO the order flips to 0.76, 0.83, and 0.70. Keeping the three best sentences cuts latency from 25.1 s to 8.6 s and accuracy from 0.75 to 0.44. The answer string is still in 96% of pruned contexts. Wrong answers move from 0.12 to 0.13, while refusals rise from 0.13 to 0.43. A 5-point non-inferiority margin is missed. An NLI screen for a near-copy with one fact changed scores AUROC 0.18. Signatures, hashes, the version chain and the editor threshold rejected all 12 structural update attacks.

Why it matters

Signatures and a transparency log say who shipped a pack and whether its history was rolled back. They leave text and vectors unbound. The margin law turns a tolerance into a query share an operator can read off honest vectors and a query log.

If the device embeds the text itself and drops the shipped vectors, the publisher's vectors never enter retrieval. Compressed stores are better checked as codes and then canonicalised: in these samples every honest vector was accepted, and the publisher had no residual choice. The codebook and the embedding configuration have to be signed by someone other than the writer under audit. On the same CPU as the local model, 8 pairs per second already takes about a quarter to a third of decode speed.

The retriever is no more accurate. The scale is the finding: a tolerance wide enough to admit honest INT8 or PQ error is wider than almost every retrieval margin.

Limitations

The adversary can write a knowledge pack or a vector store. Remote attackers are out of scope, and so are edits to model weights, passage text, or the query channel. IVF lists and HNSW graphs were not tested; graph edges are not fixed by the text alone. The FAISS runs use flat indexes. The PQ attack is greedy and stays inside the codebook, so 25% is a lower bound.

The INT8 threshold belongs to all-MiniLM-L6-v2, ONNX Runtime dynamic INT8, and batch 32. Batch 64 moves the vectors by up to 0.03. The 100% cell for BGE-M3 reuses that angle. Guard widths are empirical on three platforms and these samples. The on-device run is 100 answerable questions, one 3B model, and one fixed note. The corpora are English, at most 57,638 documents, and the update cases are synthetic. The protocol was written before measurement and was not filed in a public registry.

Float-noise exposure overstates harm. Copies with the same text account for most of it, and at τ = 0.999 accuracy barely moves. The drop from 0.75 to 0.39 is the INT8 setting.

Terms

Source

Related papers

All paper explainers