> For the complete documentation index, see [llms.txt](https://elwood.gitbook.io/foundation-model-sec/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://elwood.gitbook.io/foundation-model-sec/llm-attack/phantom-general-trigger-attacks-on-retrieval-augmented-language-generation.md).

# Phantom: General Trigger Attacks on Retrieval Augmented Language Generation

<figure><img src="/files/XiODo5I2W7J38pTmkuha" alt=""><figcaption></figcaption></figure>

#### 1. 研究背景

检索增强生成（Retrieval Augmented Generation, RAG）是一种技术，它通过结合大型语言模型（LLMs）和外部知识数据库来提升聊天机器人应用中的性能。RAG系统通过检索知识数据库中与查询最相关的文档，并将这些文档作为上下文提供给LLM生成器，以减少虚构内容，提高输出的时效性，并提供个性化输出。然而，RAG系统的普及引入了新的安全风险，特别是知识数据库本身的信任问题。恶意用户可能通过在数据库中注入精心设计的恶意文档来操纵RAG系统，进而影响LLM生成器的输出。

<figure><img src="/files/imQo74jEg8MyO06gBEqe" alt=""><figcaption></figcaption></figure>

#### 2. 过去方案和缺点

现有的研究主要集中在对抗LLMs的梯度基础攻击上，如贪婪坐标梯度（Greedy Coordinate Gradient, GCG）方法。然而，针对RAG系统的具体攻击还较新，且主要集中在检索器上，没有针对生成器的对抗目标。此外，先前的工作没有提出一种通用的攻击框架来统一各种对抗目标，也没有考虑到通过单个恶意文档来实现攻击。

#### 3. 本文方案和步骤

本文提出了Phantom，一个针对RAG增强LLMs的两步攻击框架。第一步是制作一个恶意文档，该文档被设计为仅在受害者的查询中存在对抗性触发器时被RAG系统检索到。第二步是在恶意文档中特别制作一个对抗性字符串，以触发LLM生成器中的各种对抗性攻击。

#### 4. 本文创新点与贡献

* 提出了Phantom，这是首个针对RAG系统的触发器攻击框架。
* 设计了一个两阶段的攻击过程，能够在不同的LLM架构上实现拒绝服务、声誉损害、隐私侵犯和有害行为等多种对抗目标。
* 展示了Phantom攻击框架在不同对抗目标下对多个LLM架构（包括Gemma、Vicuna和Llama）的有效性。

#### 5. 本文实验

实验使用了MS MARCO问答数据集和Natural Question（NQ）数据集进行评估。使用了多种常用的检索器和生成器模型，包括Contriever、DPR以及Vicuna、Llama 3和Gemma等LLMs。实验结果表明，Phantom攻击在不同模型上对于拒绝服务和偏见观点等目标具有较高的成功率。

#### 6. 实验结论

Phantom攻击框架证明了其在不同LLM组合和对抗目标上的广泛适用性。实验结果显示，即使是对抗性文档的微小变化也足以操纵RAG系统，实现攻击者的对抗目标。

#### 7. 全文结论

Phantom提供了一种新的视角，展示了如何通过在RAG知识数据库中注入单个恶意文档来控制LLM生成器的输出。这项工作不仅揭示了RAG系统可能面临的安全风险，也为开发者提供了应对这类攻击的见解。

#### 阅读总结

本文提出的Phantom攻击框架针对RAG系统展示了一种新的安全威胁。通过精心设计的恶意文档和特定的触发器，攻击者能够在不同的LLM生成器上实现多种对抗性目标。这项研究不仅在技术上具有创新性，同时也对RAG系统的安全性提出了重要的警示，为未来的安全防护提供了有价值的参考。


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://elwood.gitbook.io/foundation-model-sec/llm-attack/phantom-general-trigger-attacks-on-retrieval-augmented-language-generation.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
