Skip to content

SPAR: Sparse Spatial Poisoning Attacks Against Retrieval-Augmented Generation SystemsSPAR: Sparse-space Poisoning Attack on Retrieval-Augmented Generation Systems

Qingyuan Zheng, Min Ren, Saihui Hou, Huijia Wu, Weidong Liu, Zhaofeng He
School of Artificial Intelligence, Beijing University of Posts and Telecommunications; Beijing Academy of Artificial Intelligence (BAAI); School of Artificial Intelligence, Beijing Normal University; China Mobile Research Institute
arXiv: Adversarial Attacks, Backdoors & PoisoningarXiv:2612.00859Originally published Indexed by this site · 17 hr agoAttacks

Quick read

Attacks

Based on the paper PDF (AI-generated); refer to the original

The authors propose SPAR, a RAG knowledge poisoning attack, and state that under single-document injection, ASR is on average 22% higher than the baseline, and it can transfer to unseen black-box retrievers.

Threat modelThe attacker injects a very small number of poisoned documents into an external knowledge base and can append an optimized suffix to the victim's query, making RAG output the specified answer for the target query. The generation LLM is black-box; existing clean documents cannot be modified, and only a representative subset of the public corpus is needed; the retriever is white-box during optimization, and transfer to unseen black-box retrievers is tested afterward.

Questions
The RAG external knowledge base can be poisoned. The authors state that existing attacks place poisoned documents into dense topic clusters, where they are diluted by clean relevant documents retrieved at the same time, and are also easily triggered accidentally by similar non-target queries.
Methods
SPAR first uses a black-box LLM to generate persuasive semantic payloads, then uses GCG to optimize the query suffix, moving the query and poisoned documents into sparse regions of the embedding space, so that the remaining top-k positions are mainly filled by irrelevant documents.
Experiments and results
The experiments cover three question-answering datasets, five generative LLMs, and five retrievers. The authors report that SPAR outperforms the listed baselines under both single-document and multi-document injection, and can transfer to unseen retrievers; none of the four tested defenses effectively prevents it.
Limitations and future work
The authors state that deployment to all users still requires third-party suffix injection, and that localizing sparse regions also depends on approximating the target corpus distribution; future work will explore a zero-shot discovery mechanism. The experiments do not report the number of target questions, number of repetitions, or query cost.
Experimental setupVicuna-7B、Vicuna-13B et al. · Natural Questions (NQ)、HotpotQA et al. · ASR、F1-Score et al.
AI summaryThe researchers propose SPAR, a knowledge poisoning attack method against retrieval-augmented generation (RAG) systems. Existing poisoning attacks are affected by dilution effects, where clean relevant documents retrieved together override the poisoned content during generation, and poisoned payloads placed in dense semantic clusters are easily falsely recalled by semantically similar non-target queries. SPAR exploits the sparsity of high-dimensional embedding spaces to isolate poisoned documents into sparse regions with very few clean relevant documents, thereby mitigating the dilution effect and reducing false recall. Under the difficult single-document injection setting, SPAR's attack success rate exceeds baselines by an average of 22%, and maintains an 8% lead in the multi-document setting, with the adversarial payload showing strong transferability to unseen black-box retrievers. The authors also evaluate multiple existing defenses and find that SPAR remains effective against them, indicating the need for new defense methods.

The researchers propose SPAR, a knowledge poisoning attack method against retrieval-augmented generation (RAG) systems. Existing poisoning attacks are affected by dilution effects, where clean relevant documents retrieved together override the poisoned content during generation, and poisoned payloads placed in dense semantic clusters are easily falsely recalled by semantically similar non-target queries. SPAR exploits the sparsity of high-dimensional embedding spaces to isolate poisoned documents into sparse regions with very few clean relevant documents, thereby mitigating the dilution effect and reducing false recall. Under the difficult single-document injection setting, SPAR's attack success rate exceeds baselines by an average of 22%, and maintains an 8% lead in the multi-document setting, with the adversarial payload showing strong transferability to unseen black-box retrievers. The authors also evaluate multiple existing defenses and find that SPAR remains effective against them, indicating the need for new defense methods.

Related events and news

1 events · 0 news mentions

Paper analysis

6 questions; open one to read the full answer

  1. What problem does this paper attempt to solve?

    To address the dilution effect and non-target unintended recall in RAG poisoning, the authors propose SPAR, which exploits sparse regions of the embedding space.

    The core problem is how to stably control RAG's answer to a target query with a very small number of poisoned documents, while reducing unintended exposure caused by similar non-target queries.

    • Attack scenario: RAG retrieves the top-k documents from an external corpus and hands them to an LLM to generate an answer. The authors argue that the system's trust in retrieved facts makes the external corpus a knowledge-poisoning attack surface.
    • Dilution effect: Existing methods optimize poisoned documents into the dense topic cluster of the target query, and retrieval also brings in multiple clean relevant documents. The authors state that this factual context overrides the poisoned content, forcing attackers to increase the injection volume.
    • Non-target false recall: Semantically similar but different queries may also retrieve the poisoned documents, which the authors call unintended recall and consider to reduce stealth and increase the chance of discovery.
    • Core observation: The high-dimensional embedding space is not uniformly filled; there are sparse regions. The authors hypothesize that moving the target query and the poisoned documents together away from the topic cluster can make the remaining retrieval slots mostly filled with irrelevant documents, reducing factual dilution.
    • Proposed method: SPAR combines black-box semantic payload generation with spatial-shift suffix optimization on a white-box retriever, and evaluates ASR, retrieval F1, FTR, PER, and four defenses.
    • Threat model:
      • Goal: Given a target query and a specified malicious answer, make the victim RAG output that answer without reducing general utility on non-target queries.
      • Capability: Insert a limited number of poisoned documents into the external knowledge base, and covertly append an optimized suffix to the victim's query.
      • Knowledge: The generative LLM is black-box; existing clean documents cannot be rewritten, and only a representative subset of public corpora is collected to approximate density; during optimization the retriever is white-box.
      • Victim system: A standard RAG consisting of a dual-encoder dense retriever, an external knowledge base, and a generative LLM; transfer of the suffix to unseen black-box retrievers is also tested.
  2. What related research exists?

    Related work is divided into LLM adversarial attacks, RAG knowledge poisoning, and defenses; SPAR differs through spatial isolation rather than semantic similarity optimization.

    Heuristic semantic attacks on LLMs

    • Manual prompt manipulation: The paper groups direct hijacking, misleading context, and complex prompt wrapping into one category, relying on human language constructions to induce the model to output specified content or bypass safety alignment.
    • Shortcomings in RAG: The authors argue that such semantic payloads have low topic similarity to the user query, and the dense retriever may simply ignore them at the top-k stage, causing the attack to fail.

    Gradient-guided token optimization

    • HotFlip and GCG: HotFlip uses gradients to measure the effect of token substitutions on the target output; GCG scores, ranks, and samples candidate substitutions at each position to construct adversarial suffixes.
    • AutoDan: Adds a readability objective to the gradient search to generate more semantically meaningful jailbreak prompts, responding to the stealthiness problem of GCG's gibberish strings.
    • The authors' criticism of RAG applications: The paper states that iterative forward and backward propagation imposes a computational burden, and that such methods only optimize generation and do not consider retrieval; tokens may still fall into dense topic clusters, causing dilution and unintended recall.

    RAG knowledge poisoning

    • Early corpus injection research: Related work injects deceptive content into the retrieval database, showing that an attacker can manipulate outputs without knowing the retriever or model internals.
    • PoisonedRAG, HijackRAG, and Phantom: PoisonedRAG generates poisoned documents with heuristic black-box optimization; HijackRAG combines retrieval induction with hijacking commands in the text; Phantom uses two-stage optimization to bind the malicious payload to a natural-language trigger word.
    • CPA-RAG and Joint-GCG: CPA-RAG performs black-box optimization through retriever and multi-LLM scoring and rewriting feedback; Joint-GCG turns retrieval and generation into joint white-box gradient optimization. The authors summarize that these methods still rigidly optimize semantic similarity, and thus push poisoned documents into dense topic clusters.

    Baselines and defenses

    • Comparison baselines: The experiments use PoisonedRAG-Whitebox, PoisonedRAG-Blackbox, and Joint-GCG, comparing ASR and F1 for n=1 and n=5 on NQ, HotpotQA, and MS-MARCO.
    • Defense evaluation: Includes Robust System Prompting, Paraphrasing, Perplexity Filtering, and Knowledge Expansion; the authors state that traditional data poisoning defenses do not apply to SPAR, which operates only at inference time.

    The authors position SPAR as exploiting the inherent sparsity of the embedding space: rather than competing for similarity within dense topic clusters, it isolates the query and payload together into sparse regions, addressing retrieval, generation, and stealthiness simultaneously.

  3. How does the paper address this problem?

    SPAR first generates semantic payloads, then uses GCG to push the query and documents together into sparse regions, isolating relevant clean context.

    SPAR (Sparse-space Poisoning Attack) splits the attack into black-box semantic payload generation and white-box spatial-offset deployment: the former is responsible for persuading the generation LLM, and the latter for making the poisoned documents avoid relevant clean documents in the retrieval context.

    Problem setting and attack objective

    • RAG pipeline: The retriever maps the query and documents into a shared embedding space, takes the top-k by similarity, and then the generation model answers based on the query and retrieved context, written in the paper as y = M(q ⊕ Ret(q, C, k)).
    • Optimization objective: Inject a set of poisoned documents A into corpus C so as to maximize the probability that the model outputs the specified answer for the target query, i.e., A∗ = argmaxA P(M(qt ⊕ Ck)=at).
    • Two bottlenecks: The authors call the reduction in the target answer probability caused by clean relevant documents the dilution effect; and the retrieval of poisoned documents by similar non-target queries due to high similarity unintended recall.

    Black-box semantic payload generation

    • Generation method: A black-box LLM is given the target query, target answer, and length requirement, and asked to generate a fluent, persuasive, and logically coherent background passage; the paper states that this avoids gradient optimization on enterprise LLMs.
    • Models used: The method implementation states that Gemini 3.1 Pro is used to generate payloads; the default experimental setting also specifies Vicuna-13B as the default black-box LLM, and the main text does not further distinguish the scope of use of the two across result tables.
    • Prompt materials: The main text gives the generation template and a complete poisoning example; here only the inputs and outputs are summarized, and the payload content is not reproduced.

    Sparse-region localization and suffix optimization

    • Corpus topology profiling: Spherical K-means is run on a representative subset of the clean corpus to obtain K centroids, which approximate topic cluster centers without requiring access to the full database.
    • Spatial offset: L discrete-token suffixes are appended after the target query, the m centroids nearest to the current query embedding are selected, and the sum of cosine similarities between the query and these centroids is minimized, moving the query away from local dense clusters.
    • Discrete optimization: The suffix is randomly initialized, and GCG is used to iteratively replace tokens based on the loss gradient. Defaults are L=5, T=30, number of corpus centroids |VC|=5000, and number of repulsion centroids m=1.

    Payload assembly and triggering

    • Shared prefix: Each poisoned document is formed by concatenating the target query, the optimized suffix, and the corresponding semantic payload, and the n variants share the same query prefix; triggering uses the query with the suffix.
    • Expected retrieval structure: The authors state that the shared prefix makes the poisoned documents fall into the same sparse region, and after retrieval returns n poisoned documents, the remaining k−n positions are filled by clean documents unrelated to the target question.
    • Default evaluation conditions: Unless otherwise specified, Contriever is used as the white-box target retriever, k=5 in top-k, with n=1 and n=5 injected respectively; the temperature of all tested LLMs is set to 0.1.

    Success criteria and stealthiness metrics

    • Attack and retrieval: ASR uses strict substring matching to determine whether the generated answer contains the target answer; F1 measures the Precision and Recall of poisoned documents in retrieval for the target query.
    • Non-target exposure: FTR is the probability that a relevant non-target query retrieves at least one poisoned document, and PER is the average proportion of poisoned documents in the top-k when retrieval occurs; lower values of both indicate less exposure in non-target scenarios.
    • Adaptive variants: For PPL filtering, SPAR-PPL-Constraint uses a local Vicuna-7B to penalize high-perplexity token combinations; SPAR-Paraphrase has an LLM rewrite the suffix and query into coherent sentences before deployment. Full defense and rewriting prompts are in supplementary materials S.V–S.VII.
  4. What experiments did the paper conduct?

    The experiments cover three datasets, five LLMs, and five retrievers; the authors report that SPAR outperforms the baselines, but the transfer and defense results have exceptions.

    Experimental setup

    • Generation models: Vicuna-7B, Vicuna-13B, Meta-Llama-3-8B-Instruct, GPT-5.3-chat, Gemini 3.1 Pro; Table I uses the abbreviations Llama-3-8B and Gemini-3.1-Pro.
    • Retrievers: White-box optimization uses Contriever and ANCE; black-box transfer uses bge-base-en-v1.5, SimCSE, and E5-base-V2.
    • Datasets: The knowledge bases of NQ, HotpotQA, and MS-MARCO contain 2,681,468, 5,233,329, and 8,841,823 text passages, respectively; the target questions and corresponding fake documents reuse the official PoisonedRAG repository, and the paper does not report the number of questions.
    • Baselines and metrics: Compares PoisonedRAG-Whitebox, PoisonedRAG-Blackbox, and Joint-GCG; metrics are ASR by substring matching, retrieval F1, and FTR and PER on non-target queries.
    • Default conditions: Contriever, top-5, n=1 or n=5, L=5, T=30, |VC|=5000, m=1, generation temperature=0.1; the paper does not report the number of repetitions, variance, or statistical significance tests.
    • Non-target queries and evaluation: Relevant non-target queries are generated by Gemini 3.1 Pro; ASR is rule-based matching, and the paper does not use an LLM judge to determine attack success, nor does it report human evaluation.

    Main results

    Table II compares the attacks on the three datasets; the default generation LLM is Vicuna-13B, the retriever is Contriever, and the values are ASR.

    Swipe horizontally to read the table

    DatasetMethodn=1n=5
    NQSPAR78%98%
    NQJoint-GCG62%97%
    NQPoisonedRAG (White)39%89%
    NQPoisonedRAG (Black)48%89%
    HotpotQA / MS-MARCOSPAR74% / 71%99% / 99%
    HotpotQA / MS-MARCOJoint-GCG59% / 57%99% / 93%
    HotpotQA / MS-MARCOPoisonedRAG (White)44% / 36%84% / 84%
    HotpotQA / MS-MARCOPoisonedRAG (Black)68% / 55%93% / 87%
    • Single-document results: The authors state that SPAR maintains 71%–78% ASR with n=1, while the baselines decline due to dilution by the remaining four clean relevant documents; this range is taken from the full three datasets in Table II.
    • Cross-LLM results: In Table I, with n=5, F1 is 100% across five LLMs and three datasets, and ASR is 94%–100%; with n=1, ASR is 71%–100%, among which Gemini-3.1-Pro achieves 100%, 99%, and 97% on NQ, HotpotQA, and MS-MARCO, respectively.
    • Retrieval interpretation: With n=1 and top-5, F1 is mostly 33%; the authors interpret this as a single-document recall of 100% based on a theoretical upper bound of about 33.3%; this is the authors' interpretation derived from F1, not a separately reported recall measurement.

    Retriever generalization and black-box transfer

    • Another white-box retriever: In Table III on ANCE, with n=5, ASR on NQ, HotpotQA, and MS-MARCO is 99%, 97%, and 98%, respectively, and F1 is 100% in all cases; with n=1, ASR is 78%, 83%, and 75%, and F1 is 33% in all cases.
    • Transfer paths: Suffixes optimized on Contriever are transferred to SimCSE and E5-base-V2, and suffixes optimized on ANCE are transferred to bge-base-en-v1.5; the target retriever differs from the optimization retriever, and its parameters or gradients are not accessed during testing.
    • Transfer results and exceptions: In Table IV, ASR with n=5 is 92%–99%; with n=1, SimCSE gives 73%, 83%, and 67%, BGE-v1.5 gives 67%, 65%, and 51%, and E5-V2 gives 66%, 68%, and 50%. The authors argue that the sparse structure remains transferable across architectures, while also stating that weaker isolation on BGE and E5 allows more relevant clean documents into the context.

    Stealthiness and hyperparameter analysis

    • Non-target exposure: In Table V on ANCE, top-5, SPAR's FTR/PER on NQ is 13.4%/2.7% (n=1) and 18.2%/10.4% (n=5), on HotpotQA is 18.0%/3.6% and 23.0%/13.0%, and on MS-MARCO is 0.06%/0.01% and 0.09%/0.04%.
    • Baseline comparison: In the same table, Joint-GCG's FTR/PER on MS-MARCO is 9.80%/1.96% (n=1) and 14.40%/5.88% (n=5); the other corresponding cells are also all higher than SPAR. The authors attribute Joint-GCG's exposure to its joint alignment with dense topic clusters.
    • Ablation conditions: Figure 3 varies suffix length, number of repulsion centroids, number of optimization steps, and number of semantic clusters on NQ with n=1; the text conversion can only read the axis labels and figure caption, and bar heights and curve positions are not supplemented.

    Four defenses and adaptive attacks

    • Robust System Prompting: In Table VI, with n=1, ASR on NQ goes from 78% to 82%, HotpotQA from 74% to 76%, and MS-MARCO from 71% to 67%; with n=5, NQ goes from 98% to 100%, HotpotQA from 99% to 96%, and MS-MARCO from 99% to 90%. The authors state that safety prompts may lead the model to ignore the suffix and irrelevant documents and rely more on the semantic payload.
    • Paraphrasing: In Table VII, with n=1, ASR after rewriting on NQ, HotpotQA, and MS-MARCO is 70%, 67%, and 59%, respectively, and with n=5 it is 91%, 95%, and 86%. The authors state that rewriting incorporates part of the suffix into a coherent query, forming Adversarial Smoothing.
    • Perplexity Filtering: Figure 5 labels standard SPAR with AUC=0.95, SPAR-PPL-Constraint with 0.78, SPAR-Paraphrase with 0.65, and Random Guess with 0.50; Figure 4 compares its PPL density with clean MS MARCO, and the specific curve shapes are not supplemented.
    • Cost of adaptive variants: In Table VIII, standard SPAR's ASR with n=1/n=5 is 71%/99%; the PPL-constraint variant is 70%/98%, and the Paraphrasing variant is 70%/93%, with both maintaining F1 of 33% at n=1.
    • Knowledge Expansion: With n=5 fixed, Table IX shows that with k=10, ASR on NQ, HotpotQA, and MS-MARCO is 90%, 85%, and 93%; on NQ with k=50 and GPT-5.3-chat, ASR is 70% and F1 is 18%. The authors state that k=15 or 20 would exceed the Vicuna-13B context window, and note that large contexts bring computational cost and latency, but do not report specific timings.

    Other ablations and analyses

    • Suffix length L: The main text of Figure 3(a) reports ASR of 64% at L=0, 78% at L=1, and 80% at L=5; F1 stabilizes at about 33.3% for L≥5.
    • Number of repulsion centroids m: The authors state that m=1 gives the best geometric isolation, and that increasing m introduces multiple competing constraints; complete values for each m are not given.
    • Number of optimization steps T: The authors state that ASR rises in the first 10 steps and plateaus around T=10; step-by-step values are not given.
    • Number of semantic clusters K: The authors state that K=5000 characterizes the corpus structure well, and that too small or too large values cause overly broad centroids or excessive fragmentation of the space, respectively; complete values for each K are not given.
  5. What are some points that can be further explored?

    The authors list two dependencies: suffix injection and approximation of the corpus distribution; the experiments do not report sample size, number of repetitions, or query cost.

    Limitations and future directions noted by the authors

    • Universal deployment depends on suffix injection: Section Vc states that deployment for all normal users currently requires third-party suffix injection, which brings additional operational overhead in real-world deployment.
    • Targeted backdoor scenario: The same section notes that under a targeted threat model where the attacker is an active user, the optimized suffix can serve as a covert trigger; the authors regard this as a potential threat to RAG-based agents and embodied intelligence.
    • Dependence on approximating the corpus distribution: The same section states that finding suitable semantic voids requires approximating the target corpus distribution, which may be difficult in highly confidential enterprise RAG systems.
    • Future research direction: The same section states that future work will explore zero-shot discovery mechanisms to reduce the above dependence; this is a plan, not a completed capability.

    Scope of experimental coverage

    • Generative models and datasets: Table I covers five generative LLMs and NQ, HotpotQA, and MS-MARCO; the target questions reuse the PoisonedRAG evaluation set, and the paper does not report the number of target questions per dataset.
    • Retriever scope: White-box experiments include Contriever and ANCE; transfer experiments include bge-base-en-v1.5, SimCSE, and E5-base-V2, with the transfer paths given in Section IV-B4.
    • Injection and retrieval budget: The main experiments use n=1 or n=5 per target query, with default top-k=5; Knowledge Expansion additionally tests k=10, and k=50 with GPT-5.3-chat on NQ.
    • Defense scope: Section IV-D evaluates Robust System Prompting, Paraphrasing, Perplexity Filtering, and Knowledge Expansion, and includes two adaptive SPAR variants targeting PPL filtering.
    • Unreported information: The paper does not report the number of repeated experiments, confidence intervals, statistical significance tests, the number of attack queries, or optimization time; ASR uses substring matching, and no human agreement is reported.
  6. Summarize the main content of the paper

    SPAR isolates poisoned documents in sparse regions of the embedding space, maintains high ASR across multiple RAG experiment settings, and exposes the limitations of existing defenses.

    SPAR is a knowledge poisoning framework for RAG that studies how to use a small number of injected documents to make the system output a specified answer for a target query while reducing unintended triggering by similar non-target queries.

    • Problem: The authors state that existing attacks place poisoned documents into dense embedding clusters of the target topic, clean relevant documents dilute the malicious content during generation, and similar queries also increase unintended exposure.
    • Method: First, a black-box LLM generates coherent semantic payloads; then, on a white-box retriever, GCG optimizes the query suffix so that the query and poisoned documents enter a sparse region together; the remaining top-k positions are mainly filled by irrelevant clean documents.
    • Main results: In Table II under the default Vicuna-13B and Contriever setting, SPAR with n=1 achieves ASR of 78%, 74%, and 71% on NQ, HotpotQA, and MS-MARCO, respectively, all higher than the three baselines in the same table.
    • Cross-model results: In Table I, with n=5, ASR across five LLMs and three datasets is 94%–100%, and F1 is 100% in all cases; Gemini-3.1-Pro achieves 100% ASR on NQ with n=1.
    • Transfer and stealthiness: In Table IV, when transferred to three unseen black-box retrievers, ASR with n=5 is 92%–99%, while with n=1 it is 50%–83% depending on dataset and retriever; in Table V, SPAR's FTR and PER are both lower than the baselines in the same table.
    • Defense results: None of the four tested defenses prevents the attack; PPL detection has an AUC of 0.95 for standard SPAR, and the two adaptive variants reduce it to 0.78 and 0.65, respectively (Figure 5).

    On this basis, the authors argue that the structural sparsity of the embedding space constitutes an attack surface for RAG and requires new defense mechanisms. Its explicit limitations are that universal deployment still relies on query suffix injection, and that sparse-region localization requires approximating the target corpus distribution; the authors plan to explore a zero-shot discovery mechanism.

Research lineage

6 foundations · 0 follow-ups in library
Explore in knowledge graph →

Hover or focus a connected paper to inspect the citation context.

Related papers

Show 3 more papers
Read originalarxiv.org