Papers › PoisonedRAG: Knowledge Corruption Attacks to Retrieval-Augmented Generation of Large...

PoisonedRAG: Knowledge Corruption Attacks to Retrieval-Augmented Generation of Large Language Models

12 Feb 2024arXiv:2402.07867archive 2025-07-28

Wei Zou, Runpeng Geng, Binghui Wang, Jinyuan Jia

Large language models (LLMs) have achieved remarkable success due to their exceptional generative capabilities. Despite their success, they also have inherent limitations such as a lack of up-to-date knowledge and hallucination. Retrieval-Augmented Generation (RAG) is a state-of-the-art technique to mitigate these limitations. The key idea of RAG is to ground the answer generation of an LLM on external knowledge retrieved from a knowledge database. Existing studies mainly focus on improving the accuracy or efficiency of RAG, leaving its security largely unexplored. We aim to bridge the gap in this work. We find that the knowledge database in a RAG system introduces a new and practical attack surface. Based on this attack surface, we propose PoisonedRAG, the first knowledge corruption attack to RAG, where an attacker could inject a few malicious texts into the knowledge database of a RAG system to induce an LLM to generate an attacker-chosen target answer for an attacker-chosen target question. We formulate knowledge corruption attacks as an optimization problem, whose solution is a set of malicious texts. Depending on the background knowledge (e.g., black-box and white-box settings) of an attacker on a RAG system, we propose two solutions to solve the optimization problem, respectively. Our results show PoisonedRAG could achieve a 90% attack success rate when injecting five malicious texts for each target question into a knowledge database with millions of texts. We also evaluate several defenses and our results show they are insufficient to defend against PoisonedRAG, highlighting the need for new defenses.

PaperPDFCodeCode Syntology ran

In Syntology Open this paper in Syntology's Atlas, the map of the papers in Syntology's graph and their citations.

For agents, Syntology's MCP tool lists every function and class Syntology harvested from this paper and whether it ran (how to connect): get_harvested_code_for_paper(arxiv_id="2402.07867")

Code

Syntology Ran 6 of 17 code samples harvested from 2 repositories linked to this paper; 11 have no recorded run. Of those that ran: 1 ran · honoured contract; 1 ran · fixture could not drive it; 4 ran with no contract checked.

By repository: official repository: 15 samples from 1 repository, 5 ran; community (archive-listed): 2 samples from 1 repository, 1 ran. The run record, sample by sample. “Ran” means executed on a synthesized input, not that the code is correct or reproduces the paper.

sleeepeer/poisonedrag officialmentioned in papermentioned on GitHubpytorchMIT report
agrzheng/GRADA mentioned on GitHubpytorchMIT report

Repository list and official/mentioned flags are the archive's, frozen 2025-07-28. Reachability, where shown, is from one Syntology probe window (2026-09-16 to 2026-09-18); repositories not probed show nothing. GitHub stars are not tracked.

Code Syntology ran Syntology

17 samples harvested; 6 ran; 1 honoured the contract we drafted; 11 have no recorded run. Read from Syntology's graph 2026-09-24; that is when this build read the record, not when the samples ran.

1ran · honoured contract
1ran · fixture could not drive it
4ran
11unverified

Licence: 0 of the 17 samples are pointer only, meaning Syntology does not serve that copy's text. This page shows no code text for any sample; each one links to its file in the repository.

Harvested from 2 repositories linked to this paper, official or community; each sample names its own and says which. “Ran” means the sample executed on a synthesized input. It does not mean the output is correct, and nothing here reproduces the paper's results. “Honoured” and “violated” refer to a contract Syntology drafted from the code itself; “our draft was wrong” and “fixture could not drive it” are failures of Syntology's instrument, not of the code.

Each sample ends with its code_sha256, Syntology's identity for that exact code. An agent fetches the stored sample with Syntology's MCP tool get_code(code_sha256="…") (how to connect); click an identity to copy that call.

Repository labels, per sample. official repository: The archive marks this repository official for the paper. named in the paper: The archive records that the paper mentions this repository; it is not marked official. community (archive-listed): In the archive's code links for this paper, not marked official and not recorded as mentioned in the paper. found in paper text by Syntology: Syntology found this repository in the paper's own text; whether it is the authors' implementation is not asserted. community: Not in the archive's code links for this paper; a community repository Syntology harvested. Samples from a repository marked official are listed first. Licence labels name the repository's licence as recorded at harvest. “Pointer only” means Syntology does not serve that copy's text, for one of four reasons: no licence file was found; the licence was not identified; the licence is recorded as permissive but that copy's record is not marked cleared; or the licence is outside the permissive list Syntology serves text under (MIT, Apache-2.0, BSD and similar). Some licences outside that list permit redistribution, such as WTFPL, and GPL-3.0 under its conditions; they are simply not on the list. Hover a licence label for the reason. File links open the file on GitHub at the default branch, which may have changed since the harvest.

ance_get_emb sleeepeer/poisonedrag/src/utils.py official repository ran MIT (permissive) · 27c0647865d4872e · report
contriever_get_emb sleeepeer/poisonedrag/src/utils.py official repository ran MIT (permissive) · a1619cb3b16730df · report
dpr_get_emb sleeepeer/poisonedrag/src/utils.py official repository ran MIT (permissive) · a99ade31d3be8eec · report
gather_nograd sleeepeer/poisonedrag/src/contriever_src/dist_utils.py official repository ran · honoured contract fingerprinted MIT (permissive) · 01971cc37e6fe583 · report
wrap_prompt sleeepeer/poisonedrag/src/prompts.py official repository ran MIT (permissive) · 183fa5ce0ec5b32b · report
calculate_matches sleeepeer/poisonedrag/src/contriever_src/evaluation.py official repository unverified MIT (permissive) · 7a4988952dd3a127 · report
check_answer sleeepeer/poisonedrag/src/contriever_src/evaluation.py official repository unverified MIT (permissive) · 637b51b8df78832a · report
gather sleeepeer/poisonedrag/src/contriever_src/dist_utils.py official repository unverified MIT (permissive) · 9fb6e57668661c38 · report
has_answer sleeepeer/poisonedrag/src/contriever_src/evaluation.py official repository unverified MIT (permissive) · fa4ecbff4b9a354b · report
load_data sleeepeer/poisonedrag/src/contriever_src/data.py official repository unverified MIT (permissive) · 183aa13a4fe6a0cc · report
load_dataset sleeepeer/poisonedrag/src/contriever_src/data.py official repository unverified MIT (permissive) · 0c21433d8fb86d42 · report
load_retriever sleeepeer/poisonedrag/src/contriever_src/contriever.py official repository unverified MIT (permissive) · 02909384e87fd820 · report
query_gpt sleeepeer/poisonedrag/gen_adv.py official repository unverified MIT (permissive) · e238bddbf3216308 · report
randomcrop sleeepeer/poisonedrag/src/contriever_src/data.py official repository unverified MIT (permissive) · e037474365501512 · report
varsize_gather_nograd sleeepeer/poisonedrag/src/contriever_src/dist_utils.py official repository unverified MIT (permissive) · b1ad8cd3a7168b7f · report
hotflip_attack agrzheng/GRADA/src/attack.py community (archive-listed) ran · fixture could not drive it MIT (permissive) · 309e71f4157403d6 · report
wrap_prompt agrzheng/GRADA/src/prompts.py community (archive-listed) unverified MIT (permissive) · 96494dccb73d03f3 · report

Tasks

Answer GenerationHallucinationRAGRetrievalRetrieval-augmented Generation

Results from the paper archive 2025-07-28

No leaderboard rows for this paper in the archive.

Methods

AdamAttentionAttention DropoutBARTBERTBPEDense ConnectionsDropoutFocusLayer NormalizationLinear LayerLinear Warmup With Linear DecayMulti-Head AttentionRAGResidual ConnectionSETSoftmaxWeight DecayWordPiece

Report a problem or propose a change · a person checks every report against the paper or source before anything changes; decisions are listed on /corrections