RAG security, 2 of 2, about 3 h 23 min of reading
RAG Poisoning & Knowledge Corruption
About 3 h 7 min left
Concept. Retrieval-augmented generation (RAG) was meant to make large language models (LLMs) safer by grounding answers in a trusted corpus instead of the model's fallible memory. In this unit that promise inverts: the retrieval corpus becomes the highest-leverage attack surface in the whole stack. This is OWASP LLM09:2026 Vector and Embedding Weaknesses (LLM08 in the 2025 list) and the training-time data-poisoning family, studied from the attacker's side. The same result repeats in every paper below: a handful of documents, sometimes one, flips the model's answer, and the classic defenses (perplexity filtering, paraphrasing, deduplication) do not catch it.
๐ฏ Objectives
By the end of this unit you can:
- Run a PoisonedRAG-style corpus injection on a local vector database and explain the two independent conditions a poison must satisfy to work (PoisonedRAG, USENIX '25).
- Tell retrieval-time poisoning (corpus, knowledge graph, PhantomText) from training-time poisoning (label-flip, clean-label, backdoors, quantization-conditioned) and pick the right defense for each.
- Craft a poisoned document with vocabulary engineering and authority framing, and measure its attack success rate (ASR) against a real embedding model (Amine Raji walkthrough).
- Explain why graph-structured corpora move the attack instead of stopping it: GraphRAG filters naive poisons at indexing, but shared-relation and coreference attacks (GragPoison, UKPA) exploit the graph structure itself (GraphRAG under Fire).
- Explain why more numeric precision does not mean more safety: a clean model can hide a backdoor that only fires after int8 or int4 quantization (QVec).
- Instrument a corpus with canary documents, so that unauthorized retrieval and exfiltration trip a tripwire (Canarytokens).
- (Go deeper) Find a backdoor by trigger inversion and unlearn it, and compare robust aggregation rules against federated poisoning, saying how an adaptive attacker passes each (Neural Cleanse and Fang et al., arXiv 1911.11815).
The big picture
Imagine a support assistant that answers from a company wiki, and an attacker who can edit one page of that wiki. The assistant now repeats whatever that page says. That is retrieval-time poisoning. Poisoning in general splits along one axis: when the payload enters the model's knowledge. That axis decides how you detect it.
Retrieval-time attacks never touch the weights; they inject text that the retriever will fetch later. Training-time attacks bake the payload into the parameters themselves. RAG is the softer target, because the attacker needs no retraining, no gradient access and no privileged position, only write access to a corpus or some influence over it. As soon as an LLM reads any document it did not author, that document is untrusted input, and the prompt-injection rules from Prompt Hacking MasterclassInjection and guardrails, 1 of 5, about 7.8 h apply. The difference is that the injection is now persistent and is retrieved on demand.
๐ Frame for the week: a retrieved document is attacker-reachable input that the model has been told to trust, so it is not a fact. Treat the vector database the way you treat a request body: hostile until validated.
The attack surface
Retrieval-time and training-time poisoning: pick your defense
Defenses you can build this week
Offensive depth: exploiting RAG pipelines
๐ก๏ธ OWASP 2026: Vector and Embedding Weaknesses (LLM09:2026)
Go deeper: the defense side of training-time poisoning
โ Check yourself
๐ Poisoning technique reference
Finish RAG Poisoning & Knowledge Corruption
About 3 h 7 min left in this unit.
From memory first
Write the main points of this unit, in your own words.
What you set out to be able to do
Check each one against what you can do now.
- Run a PoisonedRAG-style corpus injection on a local vector database and explain the two independent conditions a poison must satisfy to work (PoisonedRAG, USENIX '25).
- Tell retrieval-time poisoning (corpus, knowledge graph, PhantomText) from training-time poisoning (label-flip, clean-label, backdoors, quantization-conditioned) and pick the right defense for each.
- Craft a poisoned document with vocabulary engineering and authority framing, and measure its attack success rate (ASR) against a real embedding model (Amine Raji walkthrough).
- Explain why graph-structured corpora move the attack instead of stopping it: GraphRAG filters naive poisons at indexing, but shared-relation and coreference attacks (GragPoison, UKPA) exploit the graph structure itself (GraphRAG under Fire).
- Explain why more numeric precision does not mean more safety: a clean model can hide a backdoor that only fires after int8 or int4 quantization (QVec).
- Instrument a corpus with canary documents, so that unauthorized retrieval and exfiltration trip a tripwire (Canarytokens).
- (Go deeper) Find a backdoor by trigger inversion and unlearn it, and compare robust aggregation rules against federated poisoning, saying how an adaptive attacker passes each (Neural Cleanse and Fang et al., arXiv 1911.11815).
The unit is done when you have answered the check and marked the required sources.
1 Check yourself
Do the check2 Required sources
Go to the sources
Sources in this unit
- PoisonedRAG: Zou et al. (USENIX 2025)
- Amine Raji: RAG Poisoning Walkthrough
- Promptfoo: RAG Poisoning Plugin
- Gu et al.: BadNets: Backdoor Attacks (2017)
- QVec: Quantization as a Malicious Task (arXiv 2606.20254, Jun 2026)
- Canary Tokens
- CorruptRAG: Practical Poisoning Attacks against RAG (Zhang et al., SACMAT 2026, arXiv 2504.03957)
- Architecture Matters: RAG Systems under Knowledge Base Poisoning (arXiv 2605.05632)
- GraphRAG under Fire: GragPoison (arXiv 2501.14050)
- A Few Words Can Distort Graphs: UKPA (arXiv 2508.04276)
- Can It Reach the Generator? Prompt-Injection Survival in Realistic RAG
- GASLITE: Vulnerabilities in Dense Embedding Search
- AGGD: Corpus Poisoning via Approximate Greedy Gradient Descent
- CRCP: When Poison Fails After Retrieval (chunking and reranking)
- Led to Mislead: Adversarial Content Injection against Neural Rankers (CRAFT)
- DeRAG: Black-box Adversarial Attacks on RAG via Prompt Injection
- Topic-FlipRAG: Adversarial Opinion Manipulation
- Machine Against the RAG: Jamming RAG with Blocker Documents (Shafran et al., USENIX Security 2025)
- Text Embeddings Reveal (Almost) As Much As Text: Vec2Text (Morris et al., EMNLP 2023)
- Is My Data in Your Retrieval Database? Membership Inference against RAG (Anderson et al., arXiv 2405.20446)
- Walking the Embedding Space: Datastore Extraction from Multimodal RAG: ImmRAG (arXiv 2610.01871)
- MITRE ATLAS: AML.T0070 RAG Poisoning
- Turner et al.: Clean Label Attacks (2019)
- NetSPI: Understanding Indirect Prompt Injection in LLM Workflows
- Exploiting Web Search Tools of AI Agents for Data Exfiltration
- Anatomy of an Attack: Poisoned RAG to Hijacked MCP Agent (Deconvolute Labs)
- HackAgent: AI-agent red-team toolkit (AISecurityLab)
- Build a canary-instrumented RAG pipeline: insert identifiable documents and verify that detection fires when they surface in outputs.
Checklist
It does not count toward done.
- Map the poisoning taxonomy by sorting each attack into retrieval-time (corpus, knowledge graph, PhantomText) or training-time (label-flip, clean-label, backdoor, quantization-conditioned backdoor, tensor steganography).
- Explain PoisonedRAG's two conditions (retrieval and generation) and why perplexity, paraphrase and deduplication defenses fail against the attack.
- Execute a PoisonedRAG-style attack with 5 documents on a test vector database and record whether the target answer flips.
- Craft a poison with vocabulary engineering and authority framing, and measure its attack success rate (ASR).
- Reproduce the CorruptRAG single-document attack (AS and AK freshness framing) and record whether one poisoned text flips the answer.
- Compare the CorruptRAG-AK ASR across RAG architectures (vanilla and reasoning) and write down the gap.
- Summarize GraphRAG poisoning by describing the three phases of the GragPoison shared-relation attack.
- Explain UKPA coreference fragmentation, including why changing 0.05% of words drops accuracy from 95% to 50%.
- Reproduce a PhantomText or document-loader injection (font size 0 or metadata) and show the hidden text appearing in the extracted chunk.
- Use RAG "fishing" prompts to probe document access with and without authentication, and list what each probe returned.
- Run the promptfoo RAG-poisoning plugin end to end (poison, inject, run) and read its pass or fail result.
- Describe BadNets and clean-label backdoors, and note how they persist through the supply chain.
- Explain QVec and quantization-conditioned backdoors, including why the model is clean in full precision and malicious after int8 or int4 quantization.
- Implement canary tokens in a test vector database and verify that detection fires when a canary surfaces in an output.
Keep planted documents out of a retrieval pipeline
Attack: Plant a short forum post that outranks the official answer for questions phrased in ways you have not seen. Defend: Admit documents by verified signer and current version, one index per tenant, so unseen poisons never rank.
Nothing to do here yet; the unit is complete without it.
Go deeper
Plant a backdoor, find it without the trigger, remove it
Attack: Stamp a few training images so a trigger of four pixels sends any image to your label Defend: Find the backdoored label without the trigger, remove it, and not flag a label that is easy by nature
Nothing to do here yet; the unit is complete without it.
One client cannot steer the average
Attack: Steer a federated average with a few compromised clients, and see the attack aimed at each robust rule Defend: Aggregate client updates with a rule that bounds f compromised clients, and keep the honest model learning
Nothing to do here yet; the unit is complete without it.
Practise this in the lab, Bind a credential to its issuer, then refuse it anywhere else.50 min to 1 h 10 min estimate
Practise this in the lab, Capstone: one engagement, replayable findings and a scope log.1 h 40 min estimate
Study notes
None yet
Sign in to take notes.
Your additions
None yet
More for this unit
25 readings
Readings no section cites. They do not count toward the unit.
RAG attack papers11 readings
- arxiv.orgpaper
The single-document attack. One poisoned text is framed as a freshness correction: CorruptRAG-AS fills a template that calls the real answer outdated and the attacker's answer confirmed by "the latest data", while CorruptRAG-AK has an LLM rewrite it into fluent adversarial knowledge. It beats multi-document baselines that must outnumber legitimate passages. Read it after PoisonedRAG.
Sign in to mark it done, keep it for later and open its questions.
- arxiv.orgpaper
Shows that the victim's architecture has a large effect. Under CorruptRAG-AK, attack success ranges from 81.9% on vanilla RAG to 24.4% on Recursive Language Models, at comparable clean accuracy of about 92%. Read it when you choose which defenses to build.
Sign in to mark it done, keep it for later and open its questions.
- arxiv.orgpaper
The cheapest knowledge-graph attack. It disrupts the coreference signals (pronouns and definite descriptions) the extractor uses to merge entity mentions. Changing 32โ60 words (0.03โ0.05% of the corpus) drops QA accuracy from 95% to 50%, and all three standard defenses (perplexity, LLM detection, semantic similarity) score an F1 of about 0. Read it for the knowledge-graph part of section 1.
Sign in to mark it done, keep it for later and open its questions.
- arxiv.orgpaper
A reality check you should read before the retrieval drills. The retriever drops about 20% of attacks, the re-ranker truncates to the top 5, and gradient attacks collapse to under 2% end to end, while readable LLM-driven ones survive at about 53%. It shows how to make poison survive retrieval and reranking.
Sign in to mark it done, keep it for later and open its questions.
- arxiv.orgpaper
Embedding-optimized adversarial passages were retrieved for 65% of queries, against 5% for raw text, and they survive chunking. The authors demonstrate it against OpenWebUI with MiniLM. Read it for the dense-retriever drill.
Sign in to mark it done, keep it for later and open its questions.
- arxiv.orgpaper
An efficient successor to HotFlip. One adversarial passage reaches 80.9% attack success on ANCE and transfers to unseen queries. Read it alongside GASLITE.
Sign in to mark it done, keep it for later and open its questions.
- arxiv.orgpaper
Chunk-aware, rerank-consistent poisoning. It jointly optimizes retrieval relevance, re-ranker consistency and chunk-boundary robustness, so payloads survive real multi-stage pipelines. Read it for the chunk-injection drill.
Sign in to mark it done, keep it for later and open its questions.
- arxiv.orgpaper
Rank-promotion attacks that transfer across embedding, cross-encoder and LLM re-rankers. Read it to see why a re-ranker is not a defense by itself.
Sign in to mark it done, keep it for later and open its questions.
- arxiv.orgpaper
A gradient-free adversarial suffix that hijacks the evidence set at the ranking stage with query-only access. Read it if you have no access to the target's models.
Sign in to mark it done, keep it for later and open its questions.
- arxiv.orgpaper
Flips stance and opinion instead of facts. Read it when the goal is to make the assistant argue a position.
Sign in to mark it done, keep it for later and open its questions.
- usenix.orgpaper
The retrieval-jamming (availability) attack. One black-box "blocker" document, built with query-only access, no knowledge of the embedder or the LLM and no malicious instructions, makes the RAG system refuse or claim it has no information. It is generated by maximizing similarity to a refusal string. Read it with the OWASP LLM09:2026 section.
Sign in to mark it done, keep it for later and open its questions.
Embedding privacy and vector-store leakage (LLM09:2026)4 readings
- arxiv.orgpaper
Embedding inversion. Iterative correction reconstructs up to about 92% of a 32-token input from its embedding alone, which is why "only the embeddings leaked" is not a safe-harbor classification. Read it before the membership-inference section.
Sign in to mark it done, keep it for later and open its questions.
- arxiv.orgpaper
Infers whether a target document is in the knowledge base, using crafted prompts or masked-span reconstruction. Raw similarity scores turn the index into a direct membership oracle. Read it with the membership-inference section.
Sign in to mark it done, keep it for later and open its questions.
- arxiv.orgpaper
Extends corpus extraction to image-returning multimodal RAG, where the retrieved image itself is the response. Instead of a malicious text prompt, ImmRAG hides the attack instruction inside an attacker-supplied query image. Relevance-weighted resampling then steers it into unexplored regions of the embedding space, rebuilding the private datastore step by step. Against CLIP-family retrievers (medical, document and general), a single 2,500-query run reconstructed up to 611 radiology images, 566 document scans and 416 general images, up to 5.6 times more distinct items than a non-adaptive baseline. It is the multimodal analog of Vec2Text and membership inference: the image channel is an extraction surface with no guardrails. Read it with the membership-inference section.
Sign in to mark it done, keep it for later and open its questions.
- atlas.mitre.orgpaper
The ATLAS technique (Persistence tactic) to which the OWASP 2026 entry maps retrieval-time poisoning, with the same two-condition frame of geometric retrieval and generation steering. Use it to cite the attack class in a report.
Sign in to mark it done, keep it for later and open its questions.
Data poisoning techniques1 reading
- arxiv.orgpaper
Label-consistent poison crafted with adversarial perturbations. It forces reliance on an implanted trigger, and no mislabeling reveals it, so it is stealthier than label flipping. Read it after BadNets.
Sign in to mark it done, keep it for later and open its questions.
Output control and indirect injection3 readings
- netspi.compaper
A pentester's view of how retrieved content becomes executable instructions, with override and exfiltration patterns. Read it before the output-control drill.
Sign in to mark it done, keep it for later and open its questions.
- arxiv.orgpaper
An end-to-end case where injected content makes a tool-using agent pull internal data and POST it to an attacker's log server through its own search tool. Read it for the tool-hijack escalation.
Sign in to mark it done, keep it for later and open its questions.
- deconvoluteai.comlab
A walkthrough demo in which one malicious chunk hijacks a downstream MCP tool-calling agent. Follow it before you build your own chunk-injection drill.
Sign in to mark it done, keep it for later and open its questions.
Hands-on tooling1 reading
- github.comtool
An Apache-2.0 Python SDK and terminal interface, v0.11.0 (Jul 2026). It tests prompt injection, jailbreaks, goal hijacking and tool misuse with more than 10 research attacks (AutoDAN-Turbo, PAIR, TAP, FlipAttack) and scores them with an LLM judge. Install it with
pip install hackagent; local models need no API key, and hooks exist for LangChain, the OpenAI SDK and Google ADK. Try it when you automate the red-team loop.Sign in to mark it done, keep it for later and open its questions.
Canary tokens1 reading
Build a canary-instrumented RAG pipeline: insert identifiable documents and verify that detection fires when they surface in outputs.
labSign in to mark it done, keep it for later and open its questions.
๐ก From the Resources feed4 readings
- arxiv.orgpaper
random-projects both the datastore and the query embeddings to defend a RAG datastore against extraction attacks, beating differential-privacy defenses on utility at comparable empirical privacy โ a defense for the embedding-leakage surface (cf. the LLM09:2026 embedding-privacy section)
Sign in to mark it done, keep it for later and open its questions.
- arxiv.orgpaper
a black-box attack (ImmRAG) that reconstructs hundreds of private images from a multimodal RAG datastore by blending attacker-held images and using relevance-weighted resampling to walk the embedding space into unexplored regions โ extends vector-store leakage (cf. the LLM09:2026 embedding-privacy section) to the multimodal setting
Sign in to mark it done, keep it for later and open its questions.
- arxiv.orgpaper
a fail-closed, deadline-based admission protocol for continuously-updated RAG stores: conceals unverified items and enforces lineage-scoped containment, cutting median poisoned retrievals ~5ร (34โ7) under verifier backlog at a measured freshness cost โ a defense for the ingest path of the corpus-poisoning stack
Sign in to mark it done, keep it for later and open its questions.
- arxiv.orgpaper
EMNLP 2026: RAG-style context does not erase training-data memorization โ a context-robust core stays extractable and context can newly enable extraction at the boundary, so retrieval context redistributes rather than removes the leakage surface
Sign in to mark it done, keep it for later and open its questions.
This unit's library holds 11 more readings for readers with access.