跳到正文
Skillpedia
智能体35k · #8397

testing-prompt-injection-in-rag-pipelines

它能做什么

这个工具可以测试那些基于文档回答问题的 AI 系统的安全性。它会寻找办法,利用系统检索和使用文档的方式,诱使系统泄露信息或做出异常行为。

适用场景

  • ✓在 AI 聊天机器人上线前进行安全测试时。
  • ✓检查防范恶意指令的措施是否有效时。
  • ✓想确保机密文档不会被泄露时。

技能链接

https://github.com/mukul975/Anthropic-Cybersecurity-Skills/blob/main/skills/testing-prompt-injection-in-rag-pipelines/SKILL.md

复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。

使用方法

最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/mukul975/Anthropic-Cybersecurity-Skills/blob/main/skills/testing-prompt-injection-in-rag-pipelines/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 AI

“测试我们内部聊天机器人的安全性,看它会不会被诱骗泄露其他部门的信息。”

每周 5 个新技能,1 分钟读完。

工作原理

这个工具借助 garak、Promptfoo、PyRIT 等工具,把伪装成文档的“秘密指令”发送给系统,然后检查 AI 系统是会执行这些指令还是忽略它们。

技术内容(原始 SKILL.md)

作者在 GitHub 上的英文原文。

Testing Prompt Injection in RAG Pipelines

Authorized-use-only notice: This skill describes offensive testing techniques against Retrieval-Augmented Generation (RAG) systems. Run these probes only against applications you own or have explicit written authorization to test. Adversarial inputs that exfiltrate documents or hijack a model can cause real harm to production systems and downstream users. Always test in a non-production environment first and follow your engagement rules of engagement (RoE).

Overview

Retrieval-Augmented Generation (RAG) pipelines combine a large language model (LLM) with a retrieval layer (a vector store such as FAISS, Chroma, Pinecone, Milvus, or pgvector) so the model can answer questions over private documents. The retrieval layer is an injection surface: any text that the retriever returns is concatenated into the model's context window and is treated by the model as authoritative. An attacker who can influence the document corpus (a poisoned PDF, a malicious wiki edit, a planted support ticket, a crafted email) can plant instructions that the model will follow when that chunk is retrieved. This is indirect prompt injection delivered through the retrieval channel, and it maps to MITRE ATLAS AML.T0051 (LLM Prompt Injection) and OWASP LLM01:2025 Prompt Injection.

Beyond text-level injection, RAG pipelines are vulnerable at the embedding layer. An attacker who understands the embedding model can craft text that lands near high-value queries in vector space ("embedding manipulation" / retrieval poisoning), guaranteeing that the malicious chunk is retrieved for a target query even when it is not semantically relevant to a human. This skill walks through systematically probing both surfaces using NVIDIA garak, Promptfoo red-team plugins, and Microsoft PyRIT, with verified, runnable commands from each tool's documentation.

When to Use

  • When security-testing a RAG chatbot, internal knowledge assistant, or document-Q&A product before or after release.
  • When validating that retrieval guardrails (input/output filtering, context sandboxing) actually block injected instructions.
  • During an AI red-team engagement scoped to test the LLM application layer (OWASP LLM Top 10 coverage).
  • When you ingest user-controllable or third-party content into a vector store and need to prove the blast radius of a poisoned document.
  • As a regression gate in CI/CD: re-run the probe suite on every prompt-template or retriever change.

Prerequisites

  • Python 3.10-3.13 and a virtual environment.
  • Network access to the target RAG application (HTTP API, or a local harness you control).
  • Authorization / signed RoE for the target.
  • Install the tooling:
python -m venv .venv && source .venv/bin/activate   # Windows: .venv\Scripts\activate

# NVIDIA garak — LLM vulnerability scanner
python -m pip install -U garak

# Microsoft PyRIT — Python Risk Identification Tool (Python 3.10-3.13)
pip install pyrit

# Promptfoo — declarative red-team / eval CLI (Node.js 18+)
npm install -g promptfoo
# or run ad hoc with: npx promptfoo@latest
  • For local embedding-poisoning experiments: pip install sentence-transformers faiss-cpu numpy.

Objectives

  • Enumerate the retrieval surface of the target RAG pipeline and identify where untrusted content enters the corpus.
  • Run automated injection probes with garak (promptinject, latentinjection, leakreplay) and capture pass/fail rates.
  • Author Promptfoo red-team configs using the indirect-prompt-injection and rag-document-exfiltration plugins.
  • Drive multi-turn injection campaigns with PyRIT orchestrators against the target endpoint.
  • Demonstrate embedding-space retrieval poisoning so a benign-looking query reliably retrieves an attacker chunk.
  • Produce evidence (transcripts, retrieved chunks, scorer output) and map each finding to OWASP LLM01 and ATLAS AML.T0051.

MITRE ATT&CK Mapping

This skill is anchored in MITRE ATLAS (the AI-specific companion to ATT&CK). Names below are the official ATLAS technique names.

ID Official Name Relevance
AML.T0051 LLM Prompt Injection Core technique — instructions injected via retrieved context override system intent
AML.T0051.001 LLM Prompt Injection: Indirect Injection delivered through documents the RAG retriever ingests, not direct user input

…

常见问题

什么是“提示词注入”(prompt injection)?

就是有人把一条秘密指令藏在普通文本中,试图让 AI 执行与预期不符的操作。

什么是 RAG?

RAG 全称是“检索增强生成”(Retrieval-Augmented Generation)。它是一种技术,AI 在生成回答之前先从数据库(文档)中检索信息,使回答更加准确、更有依据。

为什么这很重要?

AI 系统可能被用来访问重要信息。测试其安全性,可以确保它们不会被用来窃取数据或执行不必要的操作。

详情

作者的原始描述

Probes Retrieval-Augmented Generation pipelines for indirect prompt injection via poisoned retrieved documents and embedding-space manipulation, using NVIDIA garak, Promptfoo red-team plugins, and Microsoft PyRIT against vector stores like FAISS, Chroma, Pinecone, or pgvector. Use when security-testing a RAG chatbot or document-Q&A system, validating retrieval guardrails, or gating CI/CD on prompt

repo: mukul975/Anthropic-Cybersecurity-Skills

热度

GitHub 星标
35k
排名
#8397
许可证
Apache-2.0
更新时间
2026/8/31

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能