Provably Secure Retrieval-Augmented Generation

Pengcheng Zhou, Yinglun Feng, Zhongliang YangarXiv 2025

TL;DR

Retrieval-Augmented Generation (RAG) systems significantly improve LLM accuracy but introduce severe data leakage and poisoning vulnerabilities. This paper presents SAG, the first provably secure RAG framework that uses pre-storage full-encryption for both text chunks and vector embeddings. Backed by formal cryptographic proofs, SAG completely neutralizes state-of-the-art security threats, achieving a 0% attack success rate across multiple real-world datasets.

What Problem Does This Paper Address?

RAG systems have become the industry standard for grounding Large Language Models (LLMs) in domain-specific, real-time data. By encoding documents into dense vector representations and storing them in a vector database, RAG allows an LLM to retrieve relevant context to answer user queries accurately.

However, this architecture introduces two major security flaws:

  1. Knowledge Base Leakage: Malicious users can use prompt injection or indirect queries to trick the LLM into exfiltrating sensitive, private documents stored in the database.
  2. Knowledge Base Poisoning: Attackers can inject fraudulent or adversarial documents/embeddings into the database, corrupting the LLM's downstream responses and hijacking conversations.

Existing defenses rely heavily on heuristic filtering, rule-based matching, or guardrails (like Llama Guard). The authors argue that these methods lack formal security guarantees, suffer from poor interpretability, and are highly vulnerable to adaptive attacks where adversaries find clever ways around the filters.

Methods

The authors propose SAG (Secure Retrieval-Augmented Generation), a framework that shifts the defense paradigm from heuristic filtering to formal cryptographic isolation. SAG ensures that private data and its corresponding embeddings are fully encrypted before they ever hit persistent storage.

Figure 1: The overall architecture of SAG.

As shown in Figure 1, the architecture relies on four core components: a Validator (for user authentication), an Encryptor, a Decryptor, and a standard Retriever. Runtime secrets (like master keys) are assumed to be protected inside hardware-based Trusted Execution Environments (TEEs) like Intel SGX.

To cater to different application needs, SAG introduces two distinct encryption mechanisms:

  • Chained Dynamic Key Derivation: Private data chunks are organized into a logical linked list. Each node is encrypted using a unique symmetric key derived sequentially from the previous node using a Key Derivation Function (HKDF). It includes hash-based integrity verification, providing exceptional tamper resistance and forward security (compromising a current key won't expose historical keys).
  • Isolated AES Scheme: A more lightweight approach that applies modular AES-CBC encryption to document chunks and embeddings independently. This omits the linked-list structure in favor of lower latency and easier deployment.

Datasets

The framework was evaluated across four representative, real-world datasets spanning privacy-sensitive domains:

  • Enron: Corporate email communications (Communication).
  • HealthCareMagic: Medical dialogue data (Healthcare).
  • BillSum: US congressional bill summaries (Legal).
  • Fnspid: Financial news articles (Finance).

Key Insights and Ideas

  • Cryptographic Isolation vs. Heuristic Filtering: Instead of trying to guess if a prompt is malicious, SAG mathematically isolates private data. If a user fails the Validator's authentication check, the system completely blocks access to the private database (DBpriv), forcing the retriever to only query the public database (DBpub).
  • Dual-Layer Encryption: SAG encrypts both the raw text and the vector embeddings. This is a crucial defense against embedding inversion attacks (like Vec2Text), which can reconstruct readable text directly from raw vector representations.
  • The Cost of Chained Security: While the Chained Dynamic Key Derivation scheme offers superior tamper resistance, it introduces a non-linear computational overhead as the number of document chunks grows. The Isolated AES scheme, by contrast, scales linearly and is much better suited for latency-critical applications.

Key Results

The authors tested SAG against a formidable battery of state-of-the-art attacks, including prompt injections (RAG-Thief, PIDE, TGTB), membership inference (RAG_MIA), embedding inversions (Vec2Text, GEIA), and eight different poisoning attacks (CPA, Phantom, TrojanRAG, etc.).

  • 0% Attack Success Rate: Across all four datasets, SAG achieved a 0% Leakage Attack Success Rate (LASR) and a 0% Poisoning Attack Success Rate (PASR). No private data was leaked, and no poisoned content successfully corrupted the LLM's outputs.
  • Performance Trade-offs: For 10 data chunks, the Isolated AES Scheme added a manageable overhead, totaling ~2.27 seconds for the entire encryption, organization, and decryption pipeline. Meanwhile, the highly secure Chained Dynamic Key Derivation scheme required ~6.41 seconds for 10 chunks due to its complex sequential key generation.

Limitations and Future Work

The authors note two primary limitations of the current SAG framework:

  1. Open-Domain Collaborative Retrieval: In environments where multiple users contribute to a single, shared vector index for collaborative recommendations, SAG's strict user-level cryptographic isolation could break cross-user similarity calculations.
  2. Knowledge Graphs: The current design targets standard document retrieval and does not explicitly protect Knowledge-Augmented RAG (KAG) systems, where structured graph-based reasoning and multi-hop entity traversals introduce entirely new attack surfaces.

Extending these formal security guarantees to collaborative and graph-based retrieval paradigms represents the team's core focus for future work.

Summary updated

BibTeX
@misc{zhou2025provably,
  author = {Pengcheng Zhou and Yinglun Feng and Zhongliang Yang},
  title = {{Provably Secure Retrieval-Augmented Generation}},
  year = {2025},
  eprint = {2508.01084},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2508.01084},
}
Figure