---
title: 'PoisonedRAG: A RAG Corruption Attack'
url: https://www.emergentmind.com/topics/poisonedrag
type: topic
---

# PoisonedRAG: A RAG Corruption Attack

PoisonedRAG is a knowledge corruption attack on retrieval-augmented generation in which an attacker injects a few malicious texts into the knowledge database so that, for an attacker-chosen target question, the RAG system retrieves those texts and the large language model generates an attacker-chosen target answer [2402.07867]. Introduced as the first knowledge corruption attack to RAG, it established the external knowledge database as a practical attack surface and later became a standard reference point for pre-retrieval knowledge-substrate corruption in RAG security taxonomies [2402.07867].

## 1. Concept and threat model

PoisonedRAG assumes a standard dense-retrieval pipeline in which a question encoder \(f_Q\) maps a query \(Q\) to an embedding, a text encoder \(f_T\) maps each database text \(T_i\) to an embedding, and retrieval uses a similarity score
\[
\mathcal{S}(Q, T_i)=Sim(f_{Q}(Q), f_{T}(T_i)).
\]
The retrieved evidence is
\[
\mathcal{E}(Q; \mathcal{D})=Retrieve(Q, f_Q, f_T, \mathcal{D}),
\]
and answer generation is represented as \(LLM(Q, \mathcal{E}(Q; \mathcal D))\) [2402.07867].

The attack is targeted. The attacker selects one or more target questions \(Q_1,\dots,Q_M\) and, for each, a target answer \(R_i\). The poisoned texts are denoted \(\Gamma=\{P_i^j\}\), where \(P_i^j\) is the \(j\)-th poisoned text for target question \(Q_i\). The clean database is \(\mathcal D=\{T_1,\dots,T_d\}\). The attacker’s optimization objective is
\[
\max_{\Gamma} \frac{1}{M}\cdot \sum_{i=1}^{M}\mathbb{I}(LLM(Q_i; \mathcal{E}(Q_i; \mathcal{D}\cup \Gamma))=R_i),
\]
subject to
\[
\mathcal{E}(Q_i; \mathcal{D}\cup \Gamma)= Retrieve(Q_i, f_Q, f_T, \mathcal{D}\cup \Gamma).
\]
This formalizes PoisonedRAG as a corpus-side attack on grounded generation rather than on model weights or user prompts [2402.07867].

The threat model is deliberately restrictive. The attacker cannot access the texts in the clean database, cannot access or query the victim LLM, and can inject only a small number \(N\) of poisoned texts per target question. In the black-box setting, the attacker also lacks retriever parameters and cannot query the retriever directly. In the white-box setting, the attacker knows the retriever parameters \(f_Q\) and \(f_T\), but still does not access the clean database or the victim LLM [2402.07867].

Later surveys classify PoisonedRAG as a retrieval poisoning or adversarial corpus injection benchmark centered on top-\(k\) displacement and misinformation injection, and place it under pre-retrieval knowledge-substrate corruption rather than prompt-only manipulation [2606.25533].

## 2. Attack formulation and poisoning workflow

Directly optimizing the full end-to-end objective is difficult because the attacker would need gradients through discrete retrieval and through a generator they usually cannot access. PoisonedRAG therefore decomposes the attack into two heuristic conditions. First, a poisoned text \(P\) should satisfy the retrieval condition \(P \in \mathcal E(Q; \mathcal D \cup \Gamma)\). Second, it should satisfy an effectiveness condition: when used as context for the target question, it should cause the LLM to generate the target answer \(R\) [2402.07867].

Each poisoned text is written as
\[
P = S \oplus I,
\]
where \(S\) is retrieval-oriented and \(I\) is generation-oriented. The \(I\) component is produced by an attacker-controlled LLM from a prompt of the form: “This is my question: [question]. This is my answer: [answer]. Please craft a corpus such that the answer is [answer] when prompting with the question [question]. Please limit the corpus to \(V\) words.” The attacker regenerates \(I\) up to \(L\) trials until the chosen LLM outputs the target answer when given the target question and \(I\) as context [2402.07867].

In the black-box solution, the paper sets
\[
S = Q,
\]
so the final poisoned text is
\[
P = Q \oplus I.
\]
The rationale is that the target question is naturally highly similar to itself in retrieval space, while the fabricated supporting passage \(I\) preserves the target answer effect [2402.07867].

In the white-box solution, the attacker explicitly optimizes the retrieval-oriented prefix against the known retriever:
\[
S = argmax_{S'} Sim(f_{Q}(Q), f_{T}(S' \oplus I)).
\]
The paper uses HotFlip by default to optimize \(S\), and also notes an extended joint variant
\[
S^*, I^* = argmax_{S', I'} f_{Q}(Q)^{\mathcal{T}} \cdot f_{T}(S' \oplus I').
\]
In practice, the resulting optimized prefixes can be semantically odd but highly effective at raising retriever similarity [2402.07867].

This decomposition—retrieval-oriented \(S\) plus answer-inducing \(I\)—became one of the defining design patterns in subsequent RAG poisoning work. Later research explicitly described PoisonedRAG as a coarse-grained “Separate-and-Concatenate” strategy and used that framing as the basis for refinements and critiques [2604.07403].

## 3. Empirical behavior and attack efficacy

PoisonedRAG was evaluated on Natural Questions, HotpotQA, and MS-MARCO, with database sizes of 2,681,468, 5,233,329, and 8,841,823 texts, respectively. The main retrievers were Contriever, Contriever-ms, and ANCE, and the evaluated generators included PaLM 2, GPT-3.5-Turbo, GPT-4, LLaMA-2-7B, LLaMA-2-13B, Vicuna-7B, Vicuna-13B, and Vicuna-33B. The default setting used Contriever, top-\(k=5\), temperature \(0.1\), and \(N=5\) poisoned texts per target question [2402.07867].

| Dataset | Database size | Reported ASR with \(N=5\) |
|---|---:|---:|
| Natural Questions | 2,681,468 | \(0.88\) to \(0.99\) |
| HotpotQA | 5,233,329 | \(0.91\) to \(0.99\) |
| MS-MARCO | 8,841,823 | \(0.74\) to \(0.96\) |

These results underpin the paper’s headline claim that PoisonedRAG can achieve a 90% attack success rate when injecting five malicious texts for each target question into a knowledge database with millions of texts [2402.07867].

Retrieval-side metrics were also strong. On Natural Questions, the retrieval F1 was \(0.96\) for the black-box attack and \(1.0\) for the white-box attack; on HotpotQA, the retrieval F1 was \(1.0\) in both settings; on MS-MARCO, the retrieval F1 was \(0.89\) in black-box mode and \(0.94\) in white-box mode [2402.07867]. The attack therefore works not by globally corrupting the corpus, but by making a tiny number of malicious passages dominate the top-\(k\) evidence set for a target query.

Ablations clarified why the two-part construction matters. Using only \(S\) produced high retrieval F1 but very low attack success rate; using only \(I\) produced moderate attack success but weaker retrieval. The full \(S \oplus I\) construction achieved the highest ASR, showing that retrieval manipulation alone is insufficient and answer-inducing content alone is insufficient [2402.07867].

The original paper also evaluated several defenses and found them inadequate. Paraphrasing reduced ASR but did not stop the attack; perplexity-based detection had unfavorable true-positive/false-positive trade-offs; duplicate-text filtering had essentially no effect; and knowledge expansion by increasing \(k\) only diluted poisoning partially, since the attack still achieved 41% ASR in black-box mode and 43% ASR in white-box mode on HotpotQA with \(k=50\) and \(N=5\) [2402.07867].

## 4. Successors and reformulations

Later work did not simply replicate PoisonedRAG; it repeatedly reinterpreted its assumptions and limits.

| Direction | Representative paper | Stated shift |
|---|---|---|
| Source-poisoning realism | "The RAG Paradox" [2502.20995] | From internal corpus poisoning to poisoning public sources revealed by source transparency |
| Arbitrary-query compound attack | "PIDP-Attack" [2603.25164] | From targeted \(q\)-specific poisoning to universal query-time suffix plus poisoned passages |
| Query-agnostic end-to-end poisoning | "POISONCRAFT" [2505.06579] | From exact-query knowledge to shadow-query, retrieval-plus-generation optimization |
| Word-level refinement | "RefineRAG" [2604.07403] | From separate-and-concatenate to holistic word-level refinement |
| Agentic RAG poisoning | "KidnapRAG" [2607.00422] | From single-step evidence corruption to multi-step reasoning-chain hijacking |

“The RAG Paradox” reframed deployed poisoning as a black-box source-poisoning problem created by source transparency. Its core claim is that publicly cited sources such as LinkedIn, Wikipedia, Reddit, Blogger, or arXiv reveal where an attacker should inject content, so the attack surface shifts from internal corpus access to poisoning publicly visible, uploadable source ecosystems [2502.20995]. This suggests a broader operational reading of PoisonedRAG: the same attack logic persists even when the attacker never sees the internal corpus.

PIDP-Attack explicitly positioned PoisonedRAG as a strong but query-specific baseline and argued that requiring prior knowledge of the exact target question is a major practical limitation. It combined database poisoning with a universal injection suffix, improving attack success rates by 4% to 16% on Natural Questions and 5% to 12% on MS-MARCO relative to PoisonedRAG under matched settings, while keeping a small poison budget of \(n=5\) passages and top-\(k=5\) retrieval [2603.25164].

POISONCRAFT removed the need for exact target-query knowledge without modifying the user query at inference time. It constructed each poisoned document as
\[
C = C_{inject} + C_{freq} + C_{adv},
\]
where \(C_{inject}\) steers generation, \(C_{freq}\) contains common high-frequency words from a shadow query set, and \(C_{adv}\) is a retriever-optimized adversarial suffix. With a poisoning ratio of \(0.5\%\), it achieved on Natural Questions under GPT-4o-mini plus Contriever \(37.65\%\) ASR-r and \(31.88\%\) ASR-t at top-5, and on HotpotQA \(97.57\%\) ASR-r and \(96.41\%\) ASR-t at top-5 [2505.06579].

RefineRAG directly criticized PoisonedRAG-style separate-and-concatenate attacks as coarse-grained and detectable. It replaced the \(S \oplus I\) structure with “Macro Generation” to produce toxic seeds and “Micro Refinement” to optimize them via retriever-in-the-loop word-level substitutions. On Natural Questions it reported 90% ASR and lower grammar errors and repetition rates than PoisonedRAG baselines [2604.07403].

KidnapRAG then argued that PoisonedRAG’s one-shot retrieval logic does not transfer cleanly to Agentic RAG, where retrieval, reasoning, and action are interleaved. Its central claim is that in agentic systems the decisive vulnerability is not merely retrieving one poisoned document, but steering the sequence of retrieval intents through Bait, Chain-Link, and Mal-Ins documents so that the system leaves the user’s intended reasoning path [2607.00422].

## 5. Defenses, detection, and persistent weaknesses

Defense work after PoisonedRAG split into query-conditioned filtering, corpus sanitization, and retrieval-structure defenses.

FilterRAG and ML-FilterRAG defend specifically against PoisonedRAG by inserting a filtration phase between retrieval and generation. Their key statistic is Freq-Density,
\[
\text{Freq-Density} = \frac{\sum_{w \in (q_i \oplus a_j) \cap d_j} \text{Freq}(w, d_j)}{\text{UniqueWords}(d_j)},
\]
where \(a_j\) is a small-language-model output for query \(q_i\) and candidate document \(d_j\). FilterRAG uses a threshold \(\epsilon=0.2\), while ML-FilterRAG combines Freq-Density with perplexity, joint log probability, and semantic-frequency features. On MS-MARCO with GPT-4, ML-FilterRAG reduced ASR from \(0.824\) under PoisonedRAG to \(0.060\) while preserving accuracy at \(0.849\), compared with \(0.851\) for CleanRAG [2508.02835].

CleanBase moved defense upstream to the knowledge base itself. It builds a \(k\)-nearest-neighbor similarity graph over documents, prunes edges above
\[
\tau = \mu + z \cdot \sigma,
\]
and detects cliques of highly similar documents. Its premise is that malicious documents crafted for the same target question often form dense semantic clusters. Averaged over datasets, CleanBase reported about 1.9% false positive rate, 5.7% false negative rate on PoisonedRAG-B, and reduced average ASR from 52.7% to 8.3% for PoisonedRAG-B and from 58.3% to 29.5% for PoisonedRAG-W [2605.00460]. The paper also showed that adaptive attacks that diversify malicious documents or reduce them below clique size can substantially weaken this defense.

BiRD proposed a retrieval-structure defense rather than a semantic-content defense. For each forward-ranked document \(d_i^q\), it performs backward retrieval and computes a ranking-consistency signal \(r_{cc}^i\) using Spearman correlation, then combines it with forward relevance \(r_{cr}^i\) in the score
\[
S(d_i^q) = \frac{r_{cr}^i}{1 - r_{cc}^i}.
\]
Documents with \(S(d_i^q) \le \epsilon\) are retained. The paper reported that BiRD reduces the attack success rate of PoisonedRAG by up to 54% while simultaneously improving task accuracy by up to 56%, with average additional latency under 1 second [2605.20123].

These later defenses make a recurring point already visible in the original paper: simple paraphrasing, duplicate removal, and quality heuristics are insufficient when poisoning is retrieval-aware and semantically plausible. A common misconception is that poisoned RAG can be neutralized by removing only obviously malicious or low-quality text. The subsequent defense literature instead treats the problem as one of corpus integrity, query-conditioned filtering, or ranking-structure anomaly detection [2402.07867].

## 6. Generalizations and place in the RAG security landscape

Later surveys place PoisonedRAG at the center of RAG security taxonomies. “Securing Retrieval-Augmented Generation: A Taxonomy of Attacks, Defenses, and Future Directions” classifies it primarily as pre-retrieval knowledge-substrate corruption, specifically corpus/document poisoning, and argues that its importance comes from persistence, transferability across users, and the need for corpus-level remediation rather than prompt-level fixes [2604.08304]. A second survey extends that framing across centralized, on-device, federated, and hybrid RAG, treating PoisonedRAG as an adversarial corpus injection benchmark for top-\(k\) displacement and misinformation injection [2606.25533].

The concept also generalized beyond text-only, one-shot RAG. “Poisoned-MRAG” introduced the first knowledge poisoning attack on multimodal RAG by injecting a few malicious image-text pairs into a multimodal knowledge base. It achieved up to 98% ASR-G with just five malicious image-text pairs injected into the InfoSeek database of 481,782 pairs [2503.06254]. MM-PoisonRAG similarly showed that localized poisoning can reach 56.8% attack success on MultiModalQA, while its globalized poisoning attack can reduce accuracy to 0% with a single irrelevant knowledge injection in the strongest setting [2502.17832].

Graph-based RAG prompted another reformulation. LogicPoison argued that classic PoisonedRAG-style corpus poisoning is not the right abstraction for GraphRAG because graph construction filters many direct text attacks and reasoning depends on topology. It therefore attacked type-preserving entity swaps that corrupt logical pathways rather than explicit content, and substantially outperformed PoisonedRAG on GraphRAG benchmarks such as HotpotQA, 2WikiMultihopQA, and MuSiQue [2604.02954].

Agentic systems prompted a parallel rethinking. KidnapRAG maintained that once retrieval is embedded in an Observation–Thought–Action loop, the attack surface shifts from single-retrieval evidence corruption to reasoning-chain hijacking, so the PoisonedRAG assumption that one decisive retrieval event controls the outcome no longer holds [2607.00422].

Taken together, this later literature suggests that PoisonedRAG now names both a specific 2024 attack and a broader research lineage. In its original form, it is a targeted knowledge corruption attack on standard RAG. In the subsequent literature, it also functions as a baseline, a benchmark, and a conceptual template against which more realistic black-box source poisoning, arbitrary-query attacks, multimodal poisoning, graph-topology attacks, and agentic reasoning-chain hijacks are defined [2402.07867].

Source: https://www.emergentmind.com/topics/poisonedrag