testing-prompt-injection-in-rag-pipelines
Fungsinya
Alat ini membantu menguji keamanan sistem AI yang menjawab pertanyaan berdasarkan dokumen. Alat ini mencari cara untuk mengelabui sistem agar membocorkan informasi atau bertindak tidak sesuai harapan dengan memanfaatkan cara sistem mengambil dan menggunakan dokumen.
Kapan dipakai
- โSaat menguji keamanan chatbot AI sebelum dirilis.
- โUntuk memeriksa apakah perlindungan terhadap instruksi berbahaya berfungsi dengan baik.
- โSaat Anda ingin memastikan dokumen rahasia tidak terekspos.
Link skill
https://github.com/mukul975/Anthropic-Cybersecurity-Skills/blob/main/skills/testing-prompt-injection-in-rag-pipelines/SKILL.mdSalin lalu tempelkan ke AI Anda (Claude, ChatGPT, atau Cursor) dan minta AI mengikuti instruksinya.
Cara pakai
Cara paling mudah: salin pesan ini dan tempelkan ke AI Anda. AI akan membaca skill dan mengikuti instruksinya.
Pesan siap tempel
Untuk Claude Code, Codex, atau Cursor: jalankan di folder proyek, lalu skill langsung terpasang.
Unduh SKILL.md lalu taruh di folder skill agen Anda.
Contoh permintaan ke AI
โUji keamanan chatbot internal kami untuk melihat apakah bisa dikelabui agar membocorkan informasi dari departemen lain.โ
5 skill baru setiap minggu. 1 menit baca.
Cara kerjanya
Alat ini memanfaatkan tool lain (garak, Promptfoo, PyRIT) untuk mengirim 'instruksi rahasia' yang disamarkan sebagai dokumen. Alat ini memeriksa apakah sistem AI menjalankan instruksi tersebut atau mengabaikannya.
Konten teknis (SKILL.md asli)
Teks asli dari pembuat, dalam bahasa Inggris, langsung dari 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 |
โฆ
Pertanyaan umum
Apa itu 'prompt injection'?
Ini terjadi ketika seseorang mencoba memberikan instruksi rahasia kepada AI, yang disembunyikan di dalam teks biasa, agar AI bertindak berbeda dari yang seharusnya.
Apa itu RAG?
RAG singkatan dari 'Retrieval-Augmented Generation'. Ini adalah teknik di mana AI mengambil informasi dari database (dokumen) sebelum menghasilkan jawaban, sehingga jawabannya lebih akurat dan berwawasan.
Mengapa ini penting?
Sistem AI bisa digunakan untuk mengakses informasi penting. Menguji keamanannya memastikan sistem tersebut tidak bisa dimanfaatkan untuk mencuri data atau melakukan tindakan yang tidak diinginkan.
Detail
Deskripsi asli dari pembuat
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
Popularitas
- Bintang GitHub
- 35k
- Peringkat
- #8397
- Lisensi
- Apache-2.0
- Diperbarui
- 31/8/2026
Komentar
- โฆ
Skill lain dari repositori ini
abusing-dpapi-for-credential-access
35kMemberi agent AI Anda instruksi siap pakai untuk tugas tertentu, sehingga hasilnya lebih baik dan pengerjaannya lebih cepat.
abusing-shadow-credentials-for-privesc
35kMengajarkan agent AI Anda menulis teks yang jelas dan terstruktur dengan baik.
achieving-cmmc-level-2-compliance
35kMembantu agent Anda menyiapkan lingkungan untuk kepatuhan CMMC Level 2. Skill ini menerapkan persyaratan keamanan dan mengelola dokumentasi yang diperlukan.
acquiring-disk-image-with-dd-and-dcfldd
35kMembantu agent Anda membuat salinan persis dari hard drive. Berguna untuk memastikan tidak ada informasi yang hilang atau berubah selama investigasi.
Skill serupa
add-model-provider
394kMemungkinkan agent Anda menghubungkan penyedia model AI baru ke OpenClaw dengan perintah pengaturan yang aman, menjaga kunci API tetap di luar teks biasa, dan menjalankan uji langsung.
acp-router
394kMembantu agent Anda mengirim tugas ke asisten pemrograman seperti Claude Code atau Cursor lewat OpenClaw, sehingga pekerjaan dijalankan di alat tersebut.
browser-automation
394kMengajari agent Anda mengendalikan halaman web langkah demi langkah, termasuk login, tab, dan pemulihan saat halaman berhenti merespons.