Connect the Dots: Knowledge Graph-Guided Crawler Attack on Retrieval-Augmented Generation Systems
Mengyu Yao, Ziqi Zhang, Ning Luo, Shaofei Li, Yifeng Cai, Xiangqun Chen, Yao Guo, Ding Li
TL;DR
This work addresses privacy risks in retrieval-augmented generation (RAG) by modeling adversarial data extraction as an Adaptive Stochastic Coverage Problem (ASCP) with a target of maximizing coverage under a query budget $B$. It introduces RAGCrawler, a knowledge-graph-guided attacker that maintains a global attacker KG, a KG-Constructor, a Strategy Scheduler, and a Query Generator to realize a near-optimal adaptive greedy policy based on Conditional Marginal Gain (CMG). The approach demonstrates robustness to defenses like query rewriting and multi-query retrieval, achieving high corpus coverage (average ~66.8%) and strong semantic fidelity across diverse datasets and configurations, and it can produce high-quality surrogate RAG systems from extracted content. The results highlight significant security gaps in current RAG architectures and underscore the urgent need for behavior-aware defenses and query-provenance-based safeguards to protect private knowledge bases against such long-horizon attacks.
Abstract
Retrieval-augmented generation (RAG) systems integrate document retrieval with large language models and have been widely adopted. However, in privacy-related scenarios, RAG introduces a new privacy risk: adversaries can issue carefully crafted queries to exfiltrate sensitive content from the underlying corpus gradually. Although recent studies have demonstrated multi-turn extraction attacks, they rely on heuristics and fail to perform long-term extraction planning. To address these limitations, we formulate the RAG extraction attack as an adaptive stochastic coverage problem (ASCP). In ASCP, each query is treated as a probabilistic action that aims to maximize conditional marginal gain (CMG), enabling principled long-term planning under uncertainty. However, integrating ASCP with practical RAG attack faces three key challenges: unobservable CMG, intractability in the action space, and feasibility constraints. To overcome these challenges, we maintain a global attacker-side state to guide the attack. Building on this idea, we introduce RAGCRAWLER, which builds a knowledge graph to represent revealed information, uses this global state to estimate CMG, and plans queries in semantic space that target unretrieved regions. In comprehensive experiments across diverse RAG architectures and datasets, our proposed method, RAGCRAWLER, consistently outperforms all baselines. It achieves up to 84.4% corpus coverage within a fixed query budget and deliver an average improvement of 20.7% over the top-performing baseline. It also maintains high semantic fidelity and strong content reconstruction accuracy with low attack cost. Crucially, RAGCRAWLER proves its robustness by maintaining effectiveness against advanced RAG systems employing query rewriting and multi-query retrieval strategies. Our work reveals significant security gaps and highlights the pressing need for stronger safeguards for RAG.
