|
| 1 | + |
| 2 | + |
| 3 | +# AI Security Testing Playbook |
| 4 | + |
| 5 | +[](LICENSE) |
| 6 | +[](CONTRIBUTING.md) |
| 7 | +[](SECURITY.md) |
| 8 | + |
| 9 | +A practical, defensive playbook for **testing and securing LLM-powered apps** (chatbots, RAG systems, agentic tools, code assistants) in **authorized environments**. |
| 10 | + |
| 11 | +This repository focuses on: |
| 12 | +- **How to test** AI systems for common security failures |
| 13 | +- **What to log + measure** |
| 14 | +- **How to mitigate** issues with practical patterns |
| 15 | +- **Hands-on labs** you can run locally |
| 16 | + |
| 17 | +> ⚠️ Ethics & Scope: This repo is for security testing on systems you own or have explicit permission to test. See **[docs/scope-and-ethics.md](docs/scope-and-ethics.md)**. |
| 18 | +
|
| 19 | +--- |
| 20 | + |
| 21 | +## Quick links |
| 22 | + |
| 23 | +- **Playbooks** → [playbooks/](playbooks/) |
| 24 | +- **Checklists** → [checklists/](checklists/) |
| 25 | +- **Mitigation patterns** → [patterns/mitigation-patterns.md](patterns/mitigation-patterns.md) |
| 26 | +- **Local lab** → [labs/prompt-injection-toy-app/](labs/prompt-injection-toy-app/) |
| 27 | +- **Threat modeling** → [docs/threat-modeling.md](docs/threat-modeling.md) |
| 28 | + |
| 29 | +--- |
| 30 | + |
| 31 | +## The Top 10 LLM App Security Risks (practical) |
| 32 | + |
| 33 | +1. **Prompt injection** (direct + indirect via docs) |
| 34 | +2. **Tool abuse** (unsafe actions, privilege misuse) |
| 35 | +3. **Tool-output injection** (model trusts tool output as instructions) |
| 36 | +4. **RAG overexposure** (retrieves sensitive docs / too-broad scope) |
| 37 | +5. **RAG poisoning** (malicious documents / source spoofing) |
| 38 | +6. **Sensitive data leakage** (system prompts, memory, logs) |
| 39 | +7. **Authz gaps** (model can access data the user shouldn’t) |
| 40 | +8. **Insecure AI-generated code** (weak crypto, injection, auth flaws) |
| 41 | +9. **Unsafe defaults in production** (no rate limits, no monitoring) |
| 42 | +10. **Evaluation blind spots** (no regression tests for security failures) |
| 43 | + |
| 44 | +Use the checklists here to systematically test each category. |
| 45 | + |
| 46 | +--- |
| 47 | + |
| 48 | +## Reference architecture (where attacks happen) |
| 49 | + |
| 50 | +```text |
| 51 | + Untrusted Inputs |
| 52 | + (user, files, URLs, tool outputs) |
| 53 | + | |
| 54 | + v |
| 55 | + +-------------+ |
| 56 | + | LLM APP | <-- prompt assembly, policy, routing |
| 57 | + +-------------+ |
| 58 | + | | | |
| 59 | + | | +--> RAG (retrieval + docs) |
| 60 | + | +--------> Tools (APIs / actions) |
| 61 | + +--------------> Response (user) |
| 62 | +``` |
| 63 | + |
| 64 | +Key idea: **treat anything untrusted as data**, and strictly control how it reaches prompts and tools. |
| 65 | + |
| 66 | +--- |
| 67 | + |
| 68 | +## What’s inside |
| 69 | + |
| 70 | +### Playbooks |
| 71 | +- Prompt Injection: [playbooks/prompt-injection.md](playbooks/prompt-injection.md) |
| 72 | +- Jailbreaks: [playbooks/jailbreaks.md](playbooks/jailbreaks.md) |
| 73 | +- Data Leakage: [playbooks/data-leakage.md](playbooks/data-leakage.md) |
| 74 | +- Tool / Agent Security: [playbooks/tool-use-security.md](playbooks/tool-use-security.md) |
| 75 | +- RAG Security: [playbooks/rag-security.md](playbooks/rag-security.md) |
| 76 | +- Code Generation Security: [playbooks/code-generation-security.md](playbooks/code-generation-security.md) |
| 77 | +- Incident Response: [playbooks/incident-response.md](playbooks/incident-response.md) |
| 78 | + |
| 79 | +### Checklists |
| 80 | +- AI Red Teaming Checklist: [checklists/ai-red-teaming-checklist.md](checklists/ai-red-teaming-checklist.md) |
| 81 | +- LLM App Security Review: [checklists/llm-app-security-review.md](checklists/llm-app-security-review.md) |
| 82 | +- Secure Prompting Review: [checklists/secure-prompting-review.md](checklists/secure-prompting-review.md) |
| 83 | + |
| 84 | +### Patterns & Metrics |
| 85 | +- Attack Taxonomy: [patterns/attack-taxonomy.md](patterns/attack-taxonomy.md) |
| 86 | +- Mitigation Patterns: [patterns/mitigation-patterns.md](patterns/mitigation-patterns.md) |
| 87 | +- Eval Metrics: [patterns/eval-metrics.md](patterns/eval-metrics.md) |
| 88 | +- Logging & Monitoring: [patterns/logging-and-monitoring.md](patterns/logging-and-monitoring.md) |
| 89 | + |
| 90 | +### Labs (local) |
| 91 | +- Prompt Injection Toy App: [labs/prompt-injection-toy-app/README.md](labs/prompt-injection-toy-app/README.md) |
| 92 | +- RAG Poisoning Simulator: [labs/rag-poisoning-simulator/README.md](labs/rag-poisoning-simulator/README.md) |
| 93 | +- Tool Output Injection Simulator: [labs/tool-output-injection-simulator/README.md](labs/tool-output-injection-simulator/README.md) |
| 94 | + |
| 95 | +--- |
| 96 | + |
| 97 | +## Quickstart |
| 98 | + |
| 99 | +1) Read the guardrails: |
| 100 | +- [docs/scope-and-ethics.md](docs/scope-and-ethics.md) |
| 101 | + |
| 102 | +2) Run a lab locally: |
| 103 | +- [labs/prompt-injection-toy-app/README.md](labs/prompt-injection-toy-app/README.md) |
| 104 | + |
| 105 | +3) Use a checklist during reviews: |
| 106 | +- [checklists/llm-app-security-review.md](checklists/llm-app-security-review.md) |
| 107 | + |
| 108 | +--- |
| 109 | + |
| 110 | +## Optional: GitHub Pages docs (MkDocs) |
| 111 | +This repo includes an **MkDocs** config so you can publish docs via GitHub Pages easily: |
| 112 | +- `mkdocs.yml` |
| 113 | +- `docs/index.md` |
| 114 | + |
| 115 | +To build locally: |
| 116 | +```bash |
| 117 | +pip install -r docs-requirements.txt |
| 118 | +mkdocs serve |
| 119 | +``` |
| 120 | + |
| 121 | +--- |
| 122 | + |
| 123 | +## Contributing |
| 124 | +PRs welcome. Please read: |
| 125 | +- [CONTRIBUTING.md](CONTRIBUTING.md) |
| 126 | +- [SECURITY.md](SECURITY.md) |
| 127 | + |
| 128 | +--- |
| 129 | + |
| 130 | +## License |
| 131 | +MIT — see [LICENSE](LICENSE). |
| 132 | + |
| 133 | + |
| 134 | +## Prompt Injection Attack Examples |
| 135 | +See: examples/prompt-injection-attacks.md |
0 commit comments