Skip to content
Skillpedia
Agents35k · #6234

testing-prompt-injection-in-rag-pipelines

Has your agent test AI systems against prompt injection. It looks for ways to trick the system through retrieved data. Useful for ensuring chatbots and Q&A systems are secure.

What it does

This tool helps test the security of AI systems that answer questions based on documents. It looks for ways to trick the system into revealing information or acting unexpectedly by exploiting how it retrieves and uses documents.

When to use it

  • ✓When security-testing an AI chatbot before it goes live.
  • ✓To check if protections against malicious instructions are working.
  • ✓When you want to ensure confidential documents won't be exposed.

Example of what to ask your AI

“Test the security of our internal chatbot to see if it can be tricked into revealing information from other departments.”

Want more? Open the sections below.

How to use

The easiest way: copy the message below and paste it into Claude, ChatGPT, Cursor or any AI. It reads the skill and follows the instructions.

Skill link

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

Ready-to-paste message

Use this skill to help me: https://github.com/mukul975/Anthropic-Cybersecurity-Skills/blob/main/skills/testing-prompt-injection-in-rag-pipelines/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
How it works

The tool uses other tools (garak, Promptfoo, PyRIT) to send 'secret instructions' disguised as documents. It checks if the AI system executes them or ignores them.

Installation

Easiest way: copy the skill link and paste it into Claude, ChatGPT or Cursor asking it to follow the instructions.

In the terminal (Claude Code, Codex, Cursor), in your project folder:

npx skills add mukul975/Anthropic-Cybersecurity-Skills --skill testing-prompt-injection-in-rag-pipelines

Or download just the file:

curl -L https://raw.githubusercontent.com/mukul975/Anthropic-Cybersecurity-Skills/main/skills/testing-prompt-injection-in-rag-pipelines/SKILL.md -o SKILL.md
Technical content (original SKILL.md)

Original text by the author, straight from 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

…

FAQ

What is 'prompt injection'?

It's when someone tries to give a secret instruction to the AI, hidden within normal text, to make it act differently than intended.

What is RAG?

RAG stands for 'Retrieval-Augmented Generation'. It's a technique where an AI retrieves information from a database (documents) before generating an answer, making the responses more accurate and informed.

Why is this important?

AI systems can be used to access important information. Testing the security ensures they cannot be used to steal data or perform unwanted actions.

Details

Original description by the author

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

Popularity

GitHub stars
35k
Ranking position
#6234
License
Apache-2.0
Updated
8/31/2026

Is this skill useful?

0

Sign in to vote.

Comments

  • …

More skills from this repository

Similar skills