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가 답변을 만들기 전에 데이터베이스(문서)에서 정보를 검색해, 더 정확하고 근거 있는 답변을 만드는 기법입니다.
이것이 왜 중요한가요?
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
인기도
- GitHub 스타
- 35k
- 순위
- #8397
- 라이선스
- Apache-2.0
- 업데이트
- 2026. 8. 31.
댓글
- …
이 저장소의 다른 스킬
abusing-dpapi-for-credential-access
35kAI 에이전트에게 특정 작업을 위한 준비된 지침을 제공해, 더 잘하고 더 빠르게 처리하도록 합니다.
abusing-shadow-credentials-for-privesc
35kAI 에이전트가 명확하고 잘 구성된 텍스트를 쓰도록 가르칩니다.
achieving-cmmc-level-2-compliance
35kCMMC Level 2 규정 준수를 위한 환경을 준비하도록 돕습니다. 보안 요구 사항을 구현하고 필요한 문서를 관리합니다.
acquiring-disk-image-with-dd-and-dcfldd
35k에이전트가 하드 드라이브의 정확한 복사본을 만들도록 돕습니다. 조사 중 정보가 손실되거나 변경되지 않도록 하는 데 유용합니다.
비슷한 스킬
add-model-provider
394k에이전트가 안전한 설정 명령으로 새 AI 모델 제공자를 OpenClaw에 연결하고, API 키를 평문으로 두지 않으며, 실시간 테스트를 실행하도록 돕습니다.
acp-router
394k에이전트가 OpenClaw를 통해 Claude Code나 Cursor 같은 코딩 도우미에 작업을 전달해, 작업이 그 도구에서 실행되도록 돕습니다.
browser-automation
394k에이전트가 로그인, 탭, 페이지 응답이 멈췄을 때의 복구를 포함해 웹 페이지를 단계별로 조작하도록 가르칩니다.