SPAR: Sparse-space Poisoning Attack on Retrieval-Augmented Generation Systems

Qingyuan Zheng, Min Ren, Saihui Hou, Huijia Wu, Weidong Liu, Zhaofeng HearXiv 2026

TL;DR

Retrieval-Augmented Generation (RAG) systems keep large language models (LLMs) factual by fetching relevant documents from external databases, but this opens the door to "knowledge poisoning." Existing poisoning attacks struggle when injecting just a single fake document because the retriever also pulls in plenty of real, factual documents that drown out the lie. SPAR solves this by using a short, optimized suffix to push both the user's query and the poisoned document into an empty "semantic void" in the embedding space—allowing a single fake document to hijack the LLM's answer while staying hidden from normal queries.

What Problem Does This Paper Address?

To reduce hallucinations, RAG systems convert a user's query into a vector and fetch the top-$k$ most similar documents from a massive external corpus. Attackers can exploit this by slipping poisoned documents into the database.

Traditional poisoning attacks (like PoisonedRAG and Joint-GCG) optimize their fake documents to look as semantically similar to the target query as possible. That places them right inside densely populated topic clusters. As illustrated below, this creates two major bottlenecks:

Fig. 1. Illustration of the dilution effect neutralizing existing attacks under the single-document injection setting. Schematically, green dots represent highly relevant, ground-truth clean documents; the red dot denotes the injected poisoned document; and grey dots indicate unrelated knowledge. The top-k retriever fetches multiple clean documents alongside the poisoned one. During generation, this abundant factual context dominates the model’s context window, submerging the isolated poisoned content and neutralizing the attack.
  1. The Dilution Effect: Because the poisoned document sits in a crowded neighborhood of legitimate facts, the top-$k$ retriever inevitably grabs several clean, accurate documents alongside the fake one. During generation, those clean facts overwhelm the poisoned content and neutralize the attack—especially if the attacker can only inject a single document.
  2. Unintended Recall: Placing a fake document in a dense topic cluster means that related-but-different benign queries (e.g., asking "What year did the first moon landing occur?" instead of "Who was the first person to walk on the moon?") will accidentally retrieve it, blowing the attacker's cover.

Methods

SPAR (Sparse-space Poisoning Attack on RAG Systems) flips the script: instead of competing inside crowded topic clusters, it hides in the vast, empty regions of high-dimensional embedding spaces. It works in two steps:

Overview of the SPAR framework
  1. Black-Box Heuristic Semantic Payload Generation: Rather than using expensive, gradient-based optimization to craft text, SPAR prompts a capable black-box LLM (Gemini 3.1 Pro) to write a fluent, persuasive paragraph that convinces a victim LLM of the attacker's desired answer.
  2. Sparse-Space Payload Deployment: Using a representative subset of the corpus, SPAR runs spherical K-means clustering ($K = 5000$) to map out where dense topic clusters live. It then appends a 5-token learnable suffix ($L = 5$) to the target query and uses Greedy Coordinate Gradient (GCG) optimization to repel the query's embedding away from the nearest cluster centroid ($m = 1$) into an empty semantic void.

The final poisoned document concatenates the shifted query (target query + suffix) with the persuasive payload. When the victim's query (with the covertly appended suffix) hits the retriever, it lands in that sparse void. The retriever returns the poisoned document(s) plus $k - n$ completely irrelevant clean documents (e.g., articles about marathons or French soufflés). Because irrelevant text doesn't contradict the lie, the poisoned document dominates the LLM's attention.

Datasets

The authors evaluate SPAR on three standard RAG question-answering benchmarks, reusing the exact target questions and fake-document setup from PoisonedRAG:

  • Natural Questions (NQ): 2,681,468 text passages.
  • HotpotQA: 5,233,329 text passages.
  • MS-MARCO: 8,841,823 text passages.

No new benchmark was introduced, though the authors generated topic-related non-target queries using Gemini 3.1 Pro to measure unintended recall.

Key Insights and Ideas

  • High-dimensional sparsity is a structural vulnerability: Dense retrievers assume geometric proximity equals semantic relevance. Because high-dimensional embedding spaces are mostly empty, shifting a query into a void forces the retriever to return irrelevant noise alongside the poisoned document—and irrelevant noise doesn't dilute the lie.
  • The capability paradox: Stronger, more advanced LLMs (like Gemini 3.1 Pro) are actually more vulnerable to single-document poisoning than smaller models (like Vicuna). Better instruction-following and information-extraction abilities make them more likely to latch onto the single poisoned document amid irrelevant context.
  • Standard defenses fail—or even help:
  • Robust System Prompting (warning the LLM to ignore gibberish and stick to the context) actually increases SPAR's success rate, because the LLM ignores the weird suffix and focuses squarely on the fluent poisoned paragraph.
  • Query Paraphrasing accidentally weaves the disjointed suffix tokens into natural-sounding sentences ("Adversarial Smoothing"), preserving the spatial shift while bypassing perplexity filters.
  • Knowledge Expansion (retrieving $k = 50$ documents instead of $5$) still leaves SPAR with a 70% attack success rate on NQ.

Key Results

  • Single-document injection ($n = 1, k = 5$): SPAR achieves 71%–78% Attack Success Rate (ASR) with Vicuna-13B (and 97%–100% on Gemini 3.1 Pro), outperforming baselines by an average of 22% and hitting the theoretical maximum 33% F1-score (100% recall of the single poisoned document).
  • Multi-document injection ($n = 5, k = 5$): SPAR reaches 94%–100% ASR across all five tested LLMs (Vicuna-7B/13B, Llama-3-8B, GPT-5.3-chat, Gemini 3.1 Pro) and 100% F1-score, maintaining an 8% lead over baselines.
  • Black-box transferability: Suffixes optimized on white-box retrievers (Contriever, ANCE) transfer effectively to unseen black-box retrievers (BGE-v1.5, SimCSE, E5-V2), achieving 92%–99% ASR at $n = 5$ and 50%–83% ASR at $n = 1$.
  • Stealthiness: SPAR consistently achieves the lowest False Trigger Rate (FTR) and Poison Exposure Rate (PER) across all datasets (e.g., 0.06% FTR on MS-MARCO at $n = 1$, compared to 9.80% for Joint-GCG).

Limitations and Future Work

  • Query modification requirement: To affect all normal users, the attacker must covertly append the optimized suffix to incoming queries (e.g., via compromised browser extensions, third-party UI wrappers, or middleware APIs). However, this also makes SPAR a natural backdoor mechanism when the attacker acts as the active user.
  • Corpus approximation: Locating optimal semantic voids requires a representative subset of the target corpus to approximate its cluster distribution, which may be difficult in strictly confidential enterprise RAG systems. Future work will explore zero-shot void discovery mechanisms.

Summary updated

BibTeX
@misc{zheng2026spar,
  author = {Qingyuan Zheng and Min Ren and Saihui Hou and Huijia Wu and Weidong Liu and Zhaofeng He},
  title = {{SPAR: Sparse-space Poisoning Attack on Retrieval-Augmented Generation Systems}},
  year = {2026},
  eprint = {2612.00859},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2612.00859},
}
Figure