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に貼り付けるだけ。AIがスキルを読んで指示に従います。
貼り付け用メッセージ
Claude Code、Codex、Cursorの場合:プロジェクトのフォルダで実行するとスキルがインストールされます。
SKILL.mdをダウンロードして、エージェントのスキル用フォルダに入れてください。
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-injectionandrag-document-exfiltrationplugins. - 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 |
…
よくある質問
「プロンプトインジェクション」とは何ですか?
通常の文章の中に隠された秘密の指示をAIに与え、本来の意図とは異なる動作をさせようとする攻撃のことです。
RAGとは何ですか?
「Retrieval-Augmented Generation(検索拡張生成)」の略で、AIが回答を生成する前にデータベース(文書)から情報を検索する手法です。これにより、回答がより正確で情報に基づいたものになります。
なぜthis重要なのですか?
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
人気
- GitHubのスター
- 35k
- ランキング
- #8397
- ライセンス
- Apache-2.0
- 更新日
- 2026/8/31
コメント
- …
このリポジトリの他のスキル
abusing-dpapi-for-credential-access
35k特定のタスク向けに用意された指示をAIエージェントに与え、より良く、より速く作業できるようにします。
abusing-shadow-credentials-for-privesc
35kAIエージェントに、明確で構成のしっかりした文章の書き方を教えます。
achieving-cmmc-level-2-compliance
35kエージェントがCMMC Level 2への準拠に向けた環境を整えられるようにします。セキュリティ要件を実装し、必要なドキュメントを管理します。
acquiring-disk-image-with-dd-and-dcfldd
35kエージェントがハードディスクの完全なコピーを作成できるようにします。調査中に情報が失われたり改変されたりしないようにするのに役立ちます。
似ているスキル
add-model-provider
394k安全なセットアップコマンドで新しいAIモデルプロバイダーをOpenClawに接続し、APIキーを平文で残さず、ライブテストを行うようエージェントを支援します。
acp-router
394kClaude CodeやCursorなどのコーディングアシスタントに、OpenClaw経由でタスクを渡し、その作業がそのツール内で行われるようエージェントを支援します。
browser-automation
394kログイン、タブ、応答しなくなったページからの復旧を含め、Webページを段階的に操作するようエージェントに教えます。