Certifiably Robust RAG against Retrieval Corruption

Chong Xiang, Tong Wu, Zexuan Zhong, David A. Wagner, Danqi Chen, Prateek Mittal · DOI

Retrieval-Augmented Generation (RAG) has emerged as a cornerstone for grounding Large Language Models (LLMs) in external, up-to-date knowledge. By retrieving relevant documents to inform a model's response, RAG mitigates hallucinations and provides a mechanism for factual updates. However, this dependency on external data introduces a critical vulnerability: retrieval corruption. If an attacker can inject even a single malicious passage into the retrieved set—via SEO poisoning, database injection, or indirect prompt injection—they can often hijack the LLM’s output.

This paper introduces RobustRAG, the first defense framework that provides certifiable robustness against such attacks. Unlike heuristic defenses that can be bypassed by adaptive adversaries, RobustRAG offers mathematical guarantees that a small number of corrupt passages cannot force the model into generating incorrect or harmful content.

The Vulnerability of Vanilla RAG

Standard RAG pipelines typically follow a "concatenate-then-generate" approach. All retrieved passages are bundled together into a single prompt for the LLM. This architecture creates an "Achilles' heel": the attention mechanism of the LLM allows a single malicious passage to "shout louder" than benign ones, overriding factual information. For instance, an attacker could inject a passage claiming "Mount Fuji is the highest mountain," causing the LLM to ignore correct passages about Mount Everest.

Comparison between the standard Vanilla RAG pipeline and the proposed RobustRAG pipeline, highlighting the isolate-then-aggregate strategy.

RobustRAG: Isolate-then-Aggregate

To address this, RobustRAG shifts to an isolate-then-aggregate strategy. The framework consists of two primary stages:

  1. Isolation: Instead of processing all passages at once, the system processes each retrieved passage individually through the LLM to generate "isolated responses." This prevents a malicious passage from using cross-passage attention to suppress or override the information contained in benign documents.
  2. Secure Aggregation: The system then combines these unstructured responses into a single final answer using one of two novel algorithms:
  3. Secure Keyword Aggregation: This method extracts keywords from all isolated responses and calculates their frequencies. By filtering out low-frequency keywords (likely originating from malicious or irrelevant sources), the system prompts the LLM to generate a final response using only the "vetted" high-frequency keywords.
  4. Secure Decoding Aggregation: This more granular approach aggregates the next-token probability distributions from each isolated passage at every step of the decoding process. By averaging these distributions, the influence of a few outliers is mathematically constrained.

Robustness Certification

The core innovation of RobustRAG is its ability to provide a formal proof of robustness. The authors calculate a "certified accuracy" ($\tau$), which serves as a lower bound on performance. This bound holds true even if an attacker has full knowledge of the defense and can inject $k'$ malicious passages in any order. This moves the field from a "cat-and-mouse" game of heuristic defenses toward provable security.

Experimental Evaluation

The authors evaluated RobustRAG across several knowledge-intensive tasks, including multiple-choice QA (RealtimeQA-MC), short-answer QA (Natural Questions), and long-form biography generation. The experiments utilized Mistral-7B, Llama2-7B, and GPT-3.5.

Performance of RobustRAG against state-of-the-art attacks (PIA and Poisoning) across different LLMs and datasets.

Key Results

  • Defeating Empirical Attacks: Against sophisticated attacks like PoisonedRAG and Prompt Injection, vanilla RAG pipelines often suffered attack success rates (ASR) exceeding 90%. As shown in the results table, RobustRAG reduced these success rates to near 0% in almost all tested scenarios.
  • High Certifiable Accuracy: RobustRAG achieved 69.0–71.0% certifiable accuracy on multiple-choice tasks, providing a reliable baseline even under worst-case corruption.
  • Minimal Clean Penalty: A significant challenge in robust systems is maintaining performance on "clean" data. RobustRAG typically stayed within 5-10% of vanilla RAG's accuracy when no attack was present, and in some instances, matched it entirely.

Conclusion and Future Directions

RobustRAG demonstrates that it is possible to build RAG systems that are not only effective but also provably secure against data corruption. While the "isolate-then-aggregate" approach increases computational costs—requiring $k$ LLM passes for $k$ passages—these passes can be parallelized.

Future work remains in extending these techniques to multi-hop reasoning, where answers must be synthesized across multiple documents, and in hardening the retrieval step itself to prevent malicious passages from entering the pipeline in the first place. Nevertheless, RobustRAG represents a major step toward trustworthy and resilient AI systems.

Summary updated

BibTeX
@misc{xiang2024certifiably,
  author = {Chong Xiang and Tong Wu and Zexuan Zhong and David A. Wagner and Danqi Chen and Prateek Mittal},
  title = {{Certifiably Robust RAG against Retrieval Corruption}},
  year = {2024},
  eprint = {2405.15556},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2405.15556},
}
Figure