AppSec & Offensive AI Testing · 11 min read · OWASP LLM01:2025 / OWASP LLM06:2025 / MITRE ATLAS AML.T0051
Prompt Injection Red-Team Playbook
Step-by-step engineering playbook for structuring direct and indirect prompt-injection red-team exercises, testing agent tool-permission boundaries, automating CI/CD vulnerability scans, and hardening production architectures beyond fragile prompt wording.
1. Separate Direct vs. Indirect Injection Threat Boundaries
Direct prompt injection (MITRE ATLAS AML.T0051.000) originates from an authenticated or anonymous user typing adversarial text directly into the chat input. Indirect prompt injection (AML.T0051.001) is far more dangerous in enterprise RAG and agent systems: malicious instructions hide inside external emails, PDFs, Jira tickets, web pages, or calendar invites ingested by the model. Before executing a single attack payload, draw a data-flow diagram labeling every untrusted text source that enters the LLM context window alongside privileged system instructions or callable tools.
2. Build a 5-Vector Red-Team Attack Matrix
Structure pre-launch testing across five concrete attack classes rather than ad-hoc manual jailbreaks: (a) System Prompt & Tool Schema Extraction (LLM07 / AML.T0056); (b) Cross-Tenant RAG Exfiltration probing whether retrieved chunk filters leak unauthorized tenant IDs (LLM08); (c) Markdown / Image URL Data Exfiltration attempting to smuggle PII inside rendered external `` links (LLM05); (d) Tool-Call Privilege Escalation forcing an agent to invoke write/delete/send-email functions via untrusted document instructions (LLM06); and (e) Encoding & Multi-Turn Crescendo Evasion using Base64, multilingual switches, or gradual conversational steering (AML.T0054).
3. Automate Regression Probing in CI/CD
Manual pentests rot as soon as the next prompt edit or foundation-model snapshot ships. Codify your highest-severity payloads into declarative CI/CD test suites using MIT-licensed Promptfoo (`promptfoo redteam run`), Apache-2.0 Giskard, or Inspect AI sandboxed evaluations. Fail pull requests automatically if any high-severity exfiltration or unauthorized tool invocation succeeds.
4. Architectural Mitigations That Actually Hold
System prompts are advisory, not cryptographic security boundaries. Enforce four deterministic engineering controls: (1) Least-privilege scoped tool tokens bound to the calling user’s OAuth/RBAC session—never a shared service-account admin key; (2) Mandatory human-in-the-loop confirmation for destructive or external-side-effect actions (sending emails, issuing refunds, mutating SQL rows); (3) Strict CSP and Markdown sanitization disabling external image fetches and unsafe HTML rendering; and (4) Low-latency inline screening (Lakera Guard, NVIDIA NeMo Guardrails, or Guardrails AI) on both retrieved context and final outputs.
Production Reference Implementation Pattern
Copy-ready structure aligned with OWASP LLM01:2025, OWASP LLM06:2025, MITRE ATLAS AML.T0051.
# promptfooconfig.yaml — CI/CD OWASP LLM01 & LLM06 gate
targets:
- id: https://staging-api.internal/v1/assistant
config:
headers:
Authorization: "Bearer {{env.STAGING_SCOPED_USER_TOKEN}}"
redteam:
purpose: "Internal customer support RAG assistant with read-only CRM lookup"
plugins:
- prompt-extraction
- indirect-prompt-injection
- pii:direct
- rbac
- excessive-agency
strategies:
- jailbreak:composite
- base64
- crescendo
Operationalize This Guide Before Production Launch
Verify all 12 pre-launch security gates interactively in our OWASP LLM Top 10 / MITRE ATLAS Checklist, calculate statutory costs with the EU AI Act & NIST Compliance Estimator, or download the full editable templates in the Enterprise AI Governance & Red-Team Audit Kit.
Mapped Tooling, Standards & Next Engineering Guides
Prompt Injection Red-Team Playbook — Technical FAQ
Why can indirect prompt injection compromise an enterprise agent even when end users are trusted employees?
Because the attacker does not need an employee login—they only need to place hidden instructions inside an external resume, vendor invoice, support ticket, or webpage that the employee asks the AI agent to summarize or process.
Does wrapping untrusted documents in XML delimiters completely stop prompt injection?
No. Delimiter tagging (such as `<untrusted_document>...</untrusted_document>`) improves model instruction hierarchy slightly, but adversaries can close tags or override context semantically; it must be paired with least-privilege tool scoping and output sanitization.
How often should enterprise AI teams rerun automated red-team suites?
Run a fast core injection and RBAC regression suite on every prompt, retriever, or model-version pull request, and run expanded multi-turn adversarial sweeps (including new MITRE ATLAS techniques) before major releases and on a monthly/quarterly cadence.