Towards Secure Retrieval-Augmented Generation: A Comprehensive Review of Threats, Defenses and Benchmarks
Organizations: State Key Laboratory of Mathematical Engineering and Advanced Computing, Zhengzhou, 450001, China. · Information Engineering University, Zhengzhou, 450001, China. · Henan Key Laboratory of Information Security, Zhengzhou, 450001, China. · School of Cyber Security, University of Chinese Academy of Sciences, Beijing, 100000, China.
Abstract
Retrieval-Augmented Generation (RAG) significantly mitigates the hallucinations and domain knowledge deficiency in large language models by incorporating external knowledge bases. However, the multi-module architecture of RAG introduces complex system-level security vulnerabilities. Guided by the RAG workflow, this paper analyzes the underlying vulnerability mechanisms and systematically categorizes core threat vectors such as data poisoning, adversarial attacks, and membership inference attacks. Based on this threat assessment, we construct a taxonomy of RAG defense technologies from a dual perspective encompassing both input and output stages. The input-side analysis reviews data protection mechanisms including dynamic access control, homomorphic encryption retrieval, and adversarial pre-filtering. The output-side examination summarizes advanced leakage prevention techniques such as federated learning isolation, differential privacy perturbation, and lightweight data sanitization. To establish a unified benchmark for future experimental design, we consolidate authoritative test datasets, security standards, and evaluation frameworks. To the best of our knowledge, this paper presents the first end-to-end survey dedicated to the security of RAG systems. Distinct from existing literature that isolates specific vulnerabilities, we systematically map the entire pipeline-providing a unified analysis of threat models, defense mechanisms, and evaluation benchmarks. By enabling deep insights into potential risks, this work seeks to foster the development of highly robust and trustworthy next-generation RAG systems.
Figures & tables
| Aspect | This survey | Wu (2025) | Gu (2025) | He (2025) | Arz (2025) | Wang (2025) |
| RAG Architecture Anatomy | ✓ | ✓ | ✓ | ✓ | ✓ | |
| Attack Vectors & Threat Surfaces | ✓ | ✓ | ✓ | ✓ | ✓ | |
| Security Defense & Mitigation Strategies | ✓ | ✓ | ✓ | ✓ | ||
| Evaluation Benchmarks & Metrics System | ✓ | ✓ |
| Paper | Method | Target Models | Advantages |
| TrojanRAG Cheng et al. (2024a) | Contrastive Learning | Gemma, LLaMA-2, Vicuna, ChatGLM, GPT-3.5-Turbo, GPT-4, DPR, BGE-Large-En-V1.5, UAE-Large-V1 | Combined with knowledge graphs to improve the recall rate of malicious text. |
| BadRAG Xue et al. (2024) | Contrastive Learning | Not Mentioned | Introduced trigger words into malicious text to enhance stealthiness. |
| AESP Gonen et al. (2022) | Perplexity | OPT, Bloom | Discovered a negative correlation between perplexity and the performance of poisoning attacks. |
| DLMA Alon and Kamfonas (2023) | Perplexity | GPT-2 | Utilized perplexity combined with a prompt length classifier to resolve the high false positive rate of single-perplexity detection. |
| FedGhost Ma et al. (2025) | Federated Learning | FC, AlexNet, CNN, VGG16 BN | Achieved unsupervised attacks. |
| Malla Lin et al. (2024) | Reverse Eng. | OpenAI GPT-3.5, GPT-4, Davinci-002, Davinci-003, Anthropic Claude-instant, Claude-2-100k, Pygmalion-13B, Luna AI Llama2 Uncensored | Exposed the vulnerabilities of Malla. |
| Paper | Method | Target Models | Advantages |
| EL-MIA Satvaty et al. (2025) | Reference Set Normalization | Pythia | Proposed entity-level membership risk discovery for sensitive information. |
| RAG-leaks Wang et al. (2025c) | Difficulty Calibration | Meta-Llama-3-8B-Instruct, Mistral-7B-Instruct-V02, glm-4-9b-chat; all-MiniLM-L6-v2, BGE-en, BM25; FAISS | Addressing the phenomenon where question difficulty correlates with LLM accuracy, it calibrates membership for samples with similar raw similarity scores via likelihood ratio tests. |
| Anderson Anderson et al. (2024) | Prompt Engineering | google/flan-ul2, meta-llama/llama-3-8b-instruct, mistralai/mistral-7b-instruct-v0-2; sentence-transformers/all-minilm-l6-v2; Milvus Lite | Achieved membership inference attacks via prompt engineering, making the attack efficient and easy to use. |
| SPRD Choi et al. (2025) | Semantic Similarity | Llama 3.2 3B Instruct, Llama 3.1 8B Instruct, Phi-4 Mini Instruct, BGEm3, GTE Large En v1.5, FAISS, GPT-4o, GPT-4o-mini | Detected entries within the query and the database based on semantic similarity; the strategy is simple and straightforward. |
| MBA Liu et al. (2025) | Masking | GPT-4o-mini, GPT-3.5-turbo, Gemini-1.5, BAAI/bge-smallen, FAISS, GPT2-xl, oliverguhr/spelling-correction-english-base | Determined the existence of members based on the LLM’s prediction accuracy for masked prompts. |
| S2MIA Li et al. (2024) | Semantic Similarity | LLaMA-2-7b-chat-hf, LLaMA-2-13b-chat-hf, Vicuna, Alpaca, GPT-3.5-turbo; Contriever, DPR | Utilized the semantic similarity between the target sample and RAG-generated content, along with generation perplexity, as membership features. |
| Paper | Method | Target Models | Advantages |
| BMAR Chen et al. (2024) | Opinion Manipulation Attack | LLAMA3-8B, Qwen1.5-14B, coCondenser, MiniLM | Improved stealthiness by training a surrogate model to simulate the RAG retriever, eliminating the need for frequent anomalous access to the RAG system. |
| FlippedRAG Chen et al. (2025b) | Opinion Manipulation Attack | Llama3, Vicuna, Mixtral, Contriever, Co-Condenser, ANCE, Nboost/pt-bert-base-uncased-msmarco, Qwen2.5-Instruct-72B, LangChain | Generated targeted triggers to achieve opinion manipulation with high stealthiness. |
| Silent Saboteur Song et al. (2025b) | Reinforcement Learning | Co-Condenser, Contriever-ms; LLaMA-3-8B, Qwen-2.5-7B, GPT-4o | Utilized reinforcement learning with coarse-to-fine training of a surrogate model to simulate the target system, resulting in minimal perturbation to the malicious text. |
| RAG-Thief | Optimization Model | ChatGPT-4, Qwen2-72B-Instruct, GLM-4-Plus; nlp_corom_sentence-embedding_english-base | Employed agents to implement automated adversarial attacks, reducing attack overhead. |
| Topic-FlipRAG Gong et al. (2025) | Opinion Manipulation Attack | Llama3.1, Qwen2.5; Contriever, DPR, ANCE | Achieved opinion manipulation by generating topic-specific triggers via semantic-level perturbation and gradient optimization. |
| Dataset | Application Scopes | Target RAG Modules | Size | Year | Limitations |
| HotpotQA | Complex multi-hop logical reasoning QA tasks | Multi-hop retrieval, context fusion | 113K QA pairs (10 topics) | 2018 | Lacks security attack designs; solely evaluates foundational capabilities |
| NQ | Single-hop knowledge QA in real-world scenarios | Retriever, generator | 307K training, 15K test pairs | 2019 | Limited to single-hop tasks; no security evaluation |
| TREC2022Fair | 8 cognitive templates for bias verification | Retriever | 6.47M+ docs, 48 queries | 2022 | No active attack evaluations; no security threat coverage |
| AdvBench | 32 harmful behavior-inducing attacks | Generator | 520 harmful instruction samples | 2023 | No RAG-specific attack designs; weak adaptability |
| AlpacaEval | 10+ general instruction tasks | Generation quality | 529 general instruction samples | 2023 | No security evaluation; no RAG-specific support |
| SafeRAG | 4 RAG-specific injection attacks | Full pipeline | 100 test pairs (5 domains) | 2025 | Small sample size; Chinese-only support |
| No. | \justify Insight / Challenge / Prospect |
| Insight I | \justify Trust Paradox and the Contextual Security Gap shift the security focus. The structural dependence of RAG on external retrieval causes the model to suppress internal security priors in the presence of malicious contexts (i.e., the Contextual Security Gap). This trust mechanism flaw allows minimal poisoning samples to hijack the generation process via the retrieval interface, revealing that system security is essentially bound by context integrity. |
| Insight II | \justify Semantic Gap renders embedding space attacks an intrinsic defect. A fundamental inconsistency exists between human natural language logic and machine dense vector representations. Attackers exploit the statistical limitations of cosine similarity to create “adversarial collisions.” Without a symbolic logic verification layer, relying solely on vector retrieval cannot eradicate covert attacks targeting the embedding space. |
| Insight III | \justify Data flow is trapped in a Privacy-Efficiency zero-sum game. In existing solutions, Fully Homomorphic Encryption (FHE) is inefficient, TEEs face side-channel risks, while plaintext retrieval turns RAG into a “data leakage amplifier.” Attackers can steal sensitive records via inference side-channels (e.g., Logits analysis) or embedding inversion, making it difficult to balance real-time performance with confidentiality. |
| Challenge I | \justify Runtime encrypted data streams face dual bottlenecks of efficiency and side channels. Static encryption cannot protect high-frequency runtime vector operations. Searchable Encryption (SE) faces a conflict between computational overhead and accuracy in high-dimensional retrieval, with complex dynamic index maintenance. Furthermore, pure encrypted retrieval fails to mask access patterns, enabling attackers to infer query intent or knowledge base distribution via traffic statistics. |
| Challenge II | \justify The Agentic evolution introduces risks of physical cascading failures. As RAG transitions toward active task execution, retrieval poisoning can translate into physical malicious operations. Facing network-wide “delusions” caused by cross-agent infection and uncontrolled tool invocation, traditional defenses based on text matching struggle to semantically block malicious API calls disguised as normal logic. |
| Challenge III | \justify Evaluation benchmarks are lagging and constrained by multi-dimensional metric coupling. Existing evaluations lack end-to-end standards, with security and efficacy metrics highly coupled. Static datasets fail to capture black-box ranking attacks or adaptive stealthy poisoning, while automated testing relying on “LLM-as-a-Judge” suffers from bias and hallucinations, making it difficult to quantify the defense boundaries against unknown threats. |