Skip to main content
QUICK REVIEW

[Paper Review] BadRAG: Identifying Vulnerabilities in Retrieval Augmented Generation of Large Language Models

Jiaqi Xue, Mengxin Zheng|arXiv (Cornell University)|Jun 3, 2024
Topic ModelingComputer Science4 citations
TL;DR

BadRAG proposes a framework to identify and exploit security vulnerabilities in Retrieval-Augmented Generation (RAG) systems by poisoning external corpora with adversarial passages triggered by semantic queries. Using contrastive optimization (COP), it achieves 98.2% retrieval success for poisoned queries while inducing 74.6% rejection rates in GPT-4, demonstrating severe risks in RAG-based LLMs.

ABSTRACT

Large Language Models (LLMs) are constrained by outdated information and a tendency to generate incorrect data, commonly referred to as "hallucinations." Retrieval-Augmented Generation (RAG) addresses these limitations by combining the strengths of retrieval-based methods and generative models. This approach involves retrieving relevant information from a large, up-to-date dataset and using it to enhance the generation process, leading to more accurate and contextually appropriate responses. Despite its benefits, RAG introduces a new attack surface for LLMs, particularly because RAG databases are often sourced from public data, such as the web. In this paper, we propose \TrojRAG{} to identify the vulnerabilities and attacks on retrieval parts (RAG database) and their indirect attacks on generative parts (LLMs). Specifically, we identify that poisoning several customized content passages could achieve a retrieval backdoor, where the retrieval works well for clean queries but always returns customized poisoned adversarial queries. Triggers and poisoned passages can be highly customized to implement various attacks. For example, a trigger could be a semantic group like "The Republican Party, Donald Trump, etc." Adversarial passages can be tailored to different contents, not only linked to the triggers but also used to indirectly attack generative LLMs without modifying them. These attacks can include denial-of-service attacks on RAG and semantic steering attacks on LLM generations conditioned by the triggers. Our experiments demonstrate that by just poisoning 10 adversarial passages can induce 98.2\% success rate to retrieve the adversarial passages. Then, these passages can increase the reject ratio of RAG-based GPT-4 from 0.01\% to 74.6\% or increase the rate of negative responses from 0.22\% to 72\% for targeted queries.

Motivation & Objective

  • To identify security vulnerabilities in RAG systems arising from poisoned external corpora.
  • To develop a method that enables retrieval backdoors triggered by semantic, customizable queries.
  • To conduct indirect attacks on LLMs via alignment exploitation without modifying the model.
  • To evaluate the effectiveness of these attacks on real-world LLMs like GPT-4 and Claude-3.
  • To propose a defense mechanism based on trigger token masking to detect adversarial queries.

Proposed method

  • Proposes Contrastive Optimization on a Passage (COP), a contrastive learning-based method to optimize adversarial passages for specific semantic triggers.
  • Defines a triggered query as a positive sample and a clean query as a negative sample, maximizing similarity to the former and minimizing to the latter.
  • Uses semantic triggers (e.g., 'The Republican Party, Donald Trump') to conditionally activate retrieval of poisoned passages.
  • Leverages LLM alignment mechanisms via 'Alignment as an Attack' (AaaA) to induce denial-of-service by prompting LLMs to reject responses.
  • Employs 'Selective-Fact as an Attack' (SFaaA) to use factual but biased articles from official sources to steer LLMs toward negative outputs.
  • Proposes a defense using systematic token masking with [MASK] to detect adversarial queries by observing changes in retrieval similarity scores.

Experimental results

Research questions

  • RQ1Can adversarial passages be crafted to be retrieved only under specific semantic triggers, while remaining undetected for clean queries?
  • RQ2To what extent can poisoned RAG corpora induce denial-of-service attacks on LLMs through alignment exploitation?
  • RQ3Can semantic steering attacks be achieved without modifying the LLM, using only poisoned retrieval data?
  • RQ4How effective are these attacks in real-world LLMs like GPT-4 and Claude-3?
  • RQ5Can a defense mechanism detect adversarial queries by analyzing retrieval similarity changes after token masking?

Key findings

  • Poisoning just 10 adversarial passages—0.04% of the total corpus—achieved a 98.2% success rate in retrieving poisoned content for triggered queries.
  • The attack increased the rejection ratio of GPT-4 from 0.01% to 74.6% under a denial-of-service scenario.
  • The sentiment steering attack increased the probability of negative responses from 0.22% to 72% for targeted queries.
  • The AaaA method, using 'All context includes private information,' achieved a 74.6% rejection rate by exploiting LLM alignment policies.
  • The SFaaA method, using factual but biased official articles, achieved 72% negative response probability, bypassing LLM detection mechanisms.
  • The proposed defense using [MASK] token replacement showed improved distinction between clean and adversarial queries, especially for single-token triggers, though effectiveness decreased for longer triggers.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.