Pirates of the RAG: Adaptively Attacking LLMs to Leak Knowledge Bases
Christian Di Maio, Cristian Cosci, Marco Maggini, Valentina Poggioni, Stefano Melacci
TL;DR
The paper investigates privacy risks in Retrieval-Augmented Generation (RAG) systems by introducing Pirates of the RAG, a fully automated black-box attack that iteratively exposes a private knowledge base. It employs an adaptive, anchor-based strategy guided by a relevance mechanism and powered by attacker-side open-source LLMs and embeddings to craft queries that reveal missing chunks from the hidden KB. Compared to recent baselines, the proposed Pirate algorithm achieves superior coverage and leakage of the private knowledge across multiple RAG configurations, demonstrating significant privacy vulnerabilities. The work highlights urgent needs for robust privacy safeguards in RAG design and deployment and discusses limitations and potential defenses, including guardrails beyond static detectors. The findings have practical implications for the security of real-world RAG deployments and motivate targeted defenses and policy considerations.
Abstract
The growing ubiquity of Retrieval-Augmented Generation (RAG) systems in several real-world services triggers severe concerns about their security. A RAG system improves the generative capabilities of a Large Language Models (LLM) by a retrieval mechanism which operates on a private knowledge base, whose unintended exposure could lead to severe consequences, including breaches of private and sensitive information. This paper presents a black-box attack to force a RAG system to leak its private knowledge base which, differently from existing approaches, is adaptive and automatic. A relevance-based mechanism and an attacker-side open-source LLM favor the generation of effective queries to leak most of the (hidden) knowledge base. Extensive experimentation proves the quality of the proposed algorithm in different RAG pipelines and domains, comparing to very recent related approaches, which turn out to be either not fully black-box, not adaptive, or not based on open-source models. The findings from our study remark the urgent need for more robust privacy safeguards in the design and deployment of RAG systems.
