已签名但可操控:测量并弥合离线检索增强生成中的文本-向量完整性差距
研究论文 · 2026/11/07
离线检索增强生成(RAG)在边缘设备上通过携带文本和预计算嵌入向量的签名知识包进行更新。签名仅证明发布者身份,不保证向量与文本语义一致。本文研究这种文本-向量完整性缺口。若验证器重新计算向量并在余弦容差内接受,则攻击者控制向量时可劫持查询的比例等于该容差下的角度检索边界分布(边界定律)。在五个语料库和两个嵌入模型中边界较小,理想浮点噪声级容差下最多5.5%查询暴露(排除完全重复文档后各语料库最多1.2%),而基于CPU INT8-FP32比较校准的阈值(诚实余弦的0.1%分位数)导致98-100%暴露;在树莓派5上运行本地语言模型时,此类攻击使正确答案率从0.75降至0.39。压缩向量存储的完整性审计同样不佳:在57,638个文档的FAISS乘积量化索引上,通过审计的篡改向量使攻击者文档在25%的目标中排名第一。改为验证量化码,由验证器解决歧义,并采用校准保护带和规范化,在三个平台上接受了所有诚实向量样本,且发布者无选择余地。我们还表明常见浮点与动态INT8推理流水线在不同批大小或架构下不可位级复现,并报告了关于弃权、上下文修剪和语义筛选的预注册负面结果。代码和数据已发布。
该研究首次系统量化了离线RAG中签名知识包的文本-向量完整性风险,提出了可预测攻击成功率的边界定律,并在真实边缘设备上验证了攻击效果。同时,文章给出了有效的防御方案,并揭示了推理流水线的不可复现性问题,对RAG系统的安全部署具有重要指导意义。
Offline retrieval-augmented generation (RAG) on edge devices is updated through signed knowledge packs that carry text and precomputed embedding vectors. A signature proves who published a pack, not that its vectors encode its text. We study this text-vector integrity gap. A verifier that recomputes vectors and accepts them within a cosine tolerance concedes a predictable share of queries to an attacker who controls the vectors: the hijack rate equals the distribution of angular retrieval margins at the tolerance (the margin law). Margins are small in five corpora and two embedding models, so an idealised tolerance at the level of floating-point noise leaves up to 5.5% of queries exposed (at most 1.2% in any corpus once exact duplicate documents are excluded), and a threshold calibrated from our CPU INT8-FP32 comparison of a small embedding model (at the empirical 0.1% quantile of honest cosines) leaves 98-100% exposed; on a Raspberry Pi 5 running a local language model, such an attack lowers correct answers from 0.75 to 0.39. Integrity audits of compressed vector stores fare no better: on a FAISS product-quantisation index over 57,638 documents, tampered vectors that all pass the audit put the attacker's document first for 25% of targets. Verifying quantisation codes instead, with ambiguity decided by the verifier, a calibrated guard band and canonicalisation, accepted every honest vector in our samples on three platforms and left the publisher no choice. We also show that common floating-point and dynamic-INT8 inference pipelines are not bit-reproducible across batch sizes or architectures, and report pre-registered negative results on abstention, context pruning and semantic screening. We release code and data.