Certifiably Robust RAG against Retrieval Corruption Attacks

Chong Xiang, Tong Wu, Zexuan Zhong, David Wagner, Danqi Chen, Prateek Mittal · Submission to ICLR 2025 · Rejected

TL;DR

RobustRAG is the first defense framework against retrieval corruption attacks in Retrieval-Augmented Generation (RAG) that provides mathematical certifiable robustness. By adopting an "isolate-then-aggregate" architecture, it ensures that even an adaptive attacker with complete knowledge of the system cannot derail model outputs by injecting malicious passages.

What Problem Does This Paper Address?

Retrieval-augmented language models integrate external documents to answer user queries with up-to-date knowledge. However, RAG pipelines are acutely vulnerable to retrieval corruption attacks—such as data poisoning (e.g., PoisonedRAG) or indirect prompt injection—where an attacker injects a few malicious passages into the knowledge base or search engine results to manipulate the model's output.

Because standard RAG concatenates all retrieved passages into a single prompt, even a single malicious passage can hijack the generation. Furthermore, heuristic defenses (like rewriting queries or filtering) often fail against adaptive adversaries. The authors address the challenge of securing RAG pipelines with provable, worst-case robustness guarantees against an attacker who can inject arbitrary text into retrieved contexts.

Methods

RobustRAG uses an isolate-then-aggregate framework:

  1. Passage Isolation: The top-$k$ retrieved passages are split into $m = \lceil k / \omega \rceil$ disjoint groups (each of size $\omega$). Because passages are isolated, an attacker injecting $k'$ malicious documents can corrupt at most $m' \le k'$ groups, leaving the remaining $m - m'$ groups benign.
  2. Secure Aggregation: To combine isolated, unstructured text outputs without letting corrupted groups dominate, RobustRAG introduces two complementary algorithms:
  3. Secure Keyword Aggregation (Algorithm 1): Extracts unique keywords/phrases from each isolated response (ignoring abstentions like "I don't know"). Keywords surviving a dynamic count threshold $\mu = \min(\alpha \cdot n, \beta)$ are sorted and fed back into the LLM as expert suggestions to formulate the final answer.
  4. Secure Decoding Aggregation (Algorithm 2): For white-box models where next-token distributions are accessible, it sums next-token probability vectors across isolated passage groups at each decoding step. If the probability gap between the top two tokens exceeds a threshold $\eta$, the top token is chosen; otherwise, it falls back to a base token predicted without retrieval.
  5. Provable Robustness Certification: The authors prove that the space of possible adversarial outputs under arbitrary injections can be mapped to a finite set $\mathcal{R}$ (via keyword combinatorial bounding or bounded branching trees during decoding), yielding a guaranteed lower bound on performance ($\tau$-certifiable robustness).
Retrieved Passages [p1, p2, p3, p4, p5, p6]
       │
       ▼ (Passage Isolation, ω=2)
  [p1, p2]      [p3, p4]      [p5, p6]
     │              │             │
     ▼              ▼             ▼
 Isolated       Isolated      Corrupted
 Response 1     Response 2    Response 3
     │              │             │
     └──────────────┼─────────────┘
                    ▼
       Secure Aggregation (Keyword / Decoding)
                    ▼
          Certified Robust Output

Datasets

The authors evaluated RobustRAG across open-domain QA and long-form text generation benchmarks:

  • RealtimeQA-MC (RQA-MC): Multiple-choice open-domain QA.
  • RealtimeQA (RQA): Short-answer open-domain QA without predefined choices.
  • Natural Questions (NQ): Short-answer QA using the Open NQ subset.
  • Biography Generation (Bio): Long-form factual generation evaluated using an LLM-as-a-judge setup (GPT-3.5 rating factual accuracy against Wikipedia summaries).

Passages were retrieved live via Google Search API, mimicking real-world scenarios with noisy or adversarial web indexing. Tested backbone LLMs include Mistral-7B-Instruct, Llama-2-7B-Chat, and GPT-3.5-turbo.

Key Insights and Ideas

  • Containing the Blast Radius: Isolating passages bounds adversarial influence to at most $m'$ groups, converting an unconstrained injection problem into a bounded aggregation problem.
  • Taming Unstructured Text: Unlike classification tasks where label sets are small and fixed, free-form text lacks fixed output classes. Counting unique keywords prevents an adversary from inflating keyword frequency within a single corrupted response.
  • No-Retrieval Fallbacks Provide Inherent Immunity: In decoding aggregation, defaulting to the model's parametric knowledge whenever retrieval groups disagree ($\le \eta$) completely insulates tokens from retrieval poisoning.

Key Results

  • Certifiable Robustness ($k=10, k'=1$):
  • RobustRAG achieves 69.0%–71.0% certified accuracy on RQA-MC, 31.0%–38.0% on RQA, and 26.0%–36.0% on NQ (compared to 0.0% certified accuracy for vanilla RAG across all tasks).
  • On long-form Bio generation, it achieves a certified LLM-judge score of 38.8–51.2 (out of 100).
  • Clean Utility: RobustRAG retains strong clean performance, often within 1%–7% of vanilla RAG, and significantly outperforms generation without retrieval. Setting group size $\omega=3$ completely closes the clean accuracy gap.
  • Empirical Attack Resistance: Against Prompt Injection (PIA) and PoisonedRAG, RobustRAG slashes attack success rates (ASR) from >90% down to $\le 15\%$ (often reaching 0% on long-form bio).
  • Latency: Inference is 1.16× to 3.65× slower than vanilla RAG, which can be further optimized via prefix KV caching.

Limitations and Future Work

  • Multi-Hop / Dispersed Evidence: Because passages are partitioned into small groups, answers requiring cross-passage reasoning across documents placed in different groups cannot be synthesized effectively.
  • High Corruption Ratios: When corrupted passages equal or exceed benign passages ($m' \ge m - m'$), certified robustness drops to zero.
  • API Model Constraints: Decoding aggregation requires next-token probability distributions, making it computationally or financially prohibitive on closed, pay-per-token APIs (like GPT-4).
  • Certification Runtime: While inference takes under an hour, robustness certification for long text generation can take 10–24 hours due to combinatorial branching analysis.

Summary updated

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