AI & LLM Security
Purpose
Enable Claude to assess the security of AI/LLM-powered applications — chatbots, RAG pipelines, autonomous agents, and tool-using systems. Claude maps findings to the OWASP Top 10 for LLM Applications (2025) and the MITRE ATLAS adversarial-ML knowledge base, builds reproducible attack cases, and recommends concrete mitigations (input/output guardrails, least-privilege tool scopes, content provenance).
Authorization Required: Only test AI systems you own or are explicitly authorized to assess. Prompt-injection and data-exfiltration testing against third-party AI services may violate their terms of service and local law. Confirm written scope before proceeding.
Activation Triggers
This skill activates when the user asks about:
- Prompt injection (direct or indirect), jailbreaks, or system-prompt extraction
- OWASP LLM Top 10, MITRE ATLAS, or AI/ML threat modeling
- Securing a RAG pipeline, vector database, or retrieval layer
- LLM agent / tool-use / function-calling security and confused-deputy risks
- Guardrail, content-filter, or model output validation design
- Sensitive-information disclosure or training-data leakage from a model
- Model / ML supply chain security (model files,
pickle, model registries)
- AI red teaming, jailbreak corpora, or automated adversarial prompt generation
- Securing MCP (Model Context Protocol) servers and tool integrations
Prerequisites
pip install requests pyyaml rich
Optional enhanced capabilities:
garak — LLM vulnerability scanner (NVIDIA)
promptfoo — prompt/red-team evaluation harness
- API key for the target LLM endpoint (test environment only)
modelscan / picklescan — ML model file safety scanning
Core Capabilities
1. Threat Modeling (OWASP LLM Top 10 — 2025)
When asked to threat-model an AI application, map the system against each category and record exposure:
| ID |
Risk |
What to look for |
| LLM01 |
Prompt Injection |
Untrusted text reaching the prompt (direct & indirect via RAG/web/email) |
| LLM02 |
Sensitive Information Disclosure |
PII/secrets in prompts, outputs, or training data; system-prompt leakage |
| LLM03 |
Supply Chain |
Untrusted models, LoRA adapters, datasets, plugins, pickle deserialization |
| LLM04 |
Data & Model Poisoning |
Tainted training/fine-tune/RAG data; backdoors |
| LLM05 |
Improper Output Handling |
LLM output passed unsanitized to SQL, shell, browser (XSS), or eval |
| LLM06 |
Excessive Agency |
Over-broad tool scopes, autonomous side effects, no human-in-the-loop |
| LLM07 |
System Prompt Leakage |
Secrets/authz logic embedded in the system prompt |
| LLM08 |
Vector & Embedding Weaknesses |
RAG access-control bypass, embedding inversion, cross-tenant leakage |
| LLM09 |
Misinformation |
Hallucinations relied on for security/safety decisions |
| LLM10 |
Unbounded Consumption |
Cost/DoS via token floods, model extraction, wallet-drain |
Produce a per-category table: Exposure (Yes/No/Partial) → Evidence → Severity → Mitigation.
2. Prompt Injection & Jailbreak Testing
Direct injection — user input that overrides instructions. Test families:
- Instruction override ("ignore previous instructions and …")
- Role-play / persona escape (DAN-style, hypothetical framing)
- Encoding/obfuscation (Base64, ROT13, leetspeak, homoglyphs, zero-width chars)
- Token smuggling and prompt-boundary confusion (fake delimiters, fake system tags)
- Many-shot jailbreaking (long context of faux dialogue priming compliance)
- Crescendo / multi-turn gradual escalation
Indirect injection — payload arrives via retrieved/processed content (web page, PDF, email, RAG doc, tool output). This is the highest-impact class for agents. Test that retrieved text cannot issue commands, exfiltrate context, or trigger tools.
For every test record: payload, channel (direct/indirect), goal (override / exfiltrate / tool-abuse), and result (blocked / partial / success). Use scripts/prompt_injection_tester.py to run a corpus and score outcomes.
Refusal-quality note: a single refusal is not a pass. Re-test the same goal across ≥3 phrasings and obfuscations before marking a control effective.
3. RAG & Vector Store Security
When reviewing a RAG pipeline:
- Access control at retrieval — confirm the vector query is filtered by the caller's permissions, not just the app's. Test cross-tenant / cross-user document leakage.
- Indirect injection surface — treat every ingested document as attacker-controlled; verify retrieved chunks are clearly delimited and never executed as instructions.
- Embedding inversion / membership — sensitive source text may be partially reconstructable from embeddings; flag PII stored unencrypted in the vector DB.
- Chunk poisoning — a single malicious document can dominate retrieval; check ranking/dedup and source allow-listing.
- Citation integrity — outputs should cite retrieved sources so injected claims are traceable.
4. Agent & Tool-Use (Function Calling / MCP) Security
The agent is a confused deputy: it holds privileges the user may not. Review:
- Least-privilege tools — each tool scoped to the minimum action; no broad
execute_shell/http_request to arbitrary hosts
- Human-in-the-loop gates on irreversible/outbound actions (payments, email send, file delete, deploy)
- Argument validation — tool args are model-generated and untrusted; validate/allow-list server-side
- Injection → tool chain — verify retrieved/indirect content cannot drive tool calls (e.g., a web page telling the agent to email its memory out)
- MCP server hardening — authenticate clients, scope resources, rate-limit, log every tool invocation; never expose secrets via resource reads
- Memory poisoning — persistent agent memory can be seeded with malicious instructions that fire on later turns
5. Model & ML Supply Chain
- Scan model artifacts for unsafe deserialization —
pickle/.pt/.bin can execute code on load. Prefer safetensors. Run scripts/model_supply_chain.py or modelscan.
- Verify model provenance, hashes, and signatures; pin versions from trusted registries.
- Review fine-tune/LoRA adapters and datasets for poisoning and licensing.
- Treat third-party plugins/MCP servers as untrusted dependencies (review + pin).
6. Output Handling & Guardrails
- Never pass raw LLM output into
eval, SQL, shell, or innerHTML. Encode/parameterize at the sink (LLM05).
- Layered guardrails: input filter → policy in system prompt → output classifier → sink-specific sanitization. Defense in depth, since any single layer is bypassable.
- Validate structured output against a strict schema; reject on parse failure.
- Apply egress controls so an injected agent cannot reach attacker URLs.
Output Standards
Produce a structured AI security assessment:
# AI/LLM Security Assessment — [Application]
Date: [Date] | Scope: [Endpoints/Models] | Model: [name/version] | Analyst: [Name]
## Executive Summary
[2-3 sentences: overall posture, highest risks]
## OWASP LLM Top 10 Coverage
| ID | Risk | Exposure | Severity | Evidence |
|----|------|----------|----------|----------|
| LLM01 | Prompt Injection | Yes | High | [repro] |
...
## Confirmed Findings
### [F-01] Indirect Prompt Injection via RAG → Tool Abuse (Critical)
- ATLAS: AML.T0051 / OWASP LLM01+LLM06
- Repro: [payload, channel, steps]
- Impact: [data exfil / unauthorized action]
- Mitigation: [least-privilege tool scope + retrieved-content isolation + HITL]
## Guardrail Bypass Matrix
| Goal | Direct | Encoded | Multi-turn | Indirect | Result |
## Recommendations (Prioritized)
1. ...
Script Reference
prompt_injection_tester.py
# Run the built-in injection/jailbreak corpus against an endpoint
python scripts/prompt_injection_tester.py --url https://app.test/api/chat --field message --output results.json
# Use a custom payload corpus and a refusal-detection keyword set
python scripts/prompt_injection_tester.py --url ... --corpus payloads.txt --judge-keywords refusals.txt
model_supply_chain.py
# Scan a model directory/file for unsafe pickle opcodes and risky imports
python scripts/model_supply_chain.py --path ./models/model.pt
python scripts/model_supply_chain.py --path ./models/ --recursive --output scan.json
Skill Integration
| Next Step |
Condition |
Target Skill |
| Web/API vuln testing of the app shell |
App exposes web/API surface |
→ Skill 09 |
| Cloud/infra hosting the model |
Model served on AWS/Azure/GCP/K8s |
→ Skill 10 |
| Detection rules for prompt-injection attempts |
Need SIEM coverage |
→ Skill 12 |
| Dependency/model-package CVEs |
ML libs in use |
→ Skill 02 |
| Red team narrative incorporating AI abuse |
Full engagement |
→ Skill 14 |
References
1---2name: ai-llm-security3description: LLM and AI application security testing — prompt injection, jailbreak resistance, OWASP LLM Top 10 (2025), RAG and agent/tool-use security, model supply chain, and AI red teaming for authorized assessments4---56# AI & LLM Security78## Purpose910Enable Claude to assess the security of AI/LLM-powered applications — chatbots, RAG pipelines, autonomous agents, and tool-using systems. Claude maps findings to the **OWASP Top 10 for LLM Applications (2025)** and the **MITRE ATLAS** adversarial-ML knowledge base, builds reproducible attack cases, and recommends concrete mitigations (input/output guardrails, least-privilege tool scopes, content provenance).1112> **Authorization Required**: Only test AI systems you own or are explicitly authorized to assess. Prompt-injection and data-exfiltration testing against third-party AI services may violate their terms of service and local law. Confirm written scope before proceeding.1314---1516## Activation Triggers1718This skill activates when the user asks about:19- Prompt injection (direct or indirect), jailbreaks, or system-prompt extraction20- OWASP LLM Top 10, MITRE ATLAS, or AI/ML threat modeling21- Securing a RAG pipeline, vector database, or retrieval layer22- LLM agent / tool-use / function-calling security and confused-deputy risks23- Guardrail, content-filter, or model output validation design24- Sensitive-information disclosure or training-data leakage from a model25- Model / ML supply chain security (model files, `pickle`, model registries)26- AI red teaming, jailbreak corpora, or automated adversarial prompt generation27- Securing MCP (Model Context Protocol) servers and tool integrations2829---3031## Prerequisites3233```bash34pip install requests pyyaml rich35```3637**Optional enhanced capabilities:**38- `garak` — LLM vulnerability scanner (NVIDIA)39- `promptfoo` — prompt/red-team evaluation harness40- API key for the target LLM endpoint (test environment only)41- `modelscan` / `picklescan` — ML model file safety scanning4243---4445## Core Capabilities4647### 1. Threat Modeling (OWASP LLM Top 10 — 2025)4849When asked to threat-model an AI application, map the system against each category and record exposure:5051| ID | Risk | What to look for |52|----|------|------------------|53| LLM01 | Prompt Injection | Untrusted text reaching the prompt (direct & indirect via RAG/web/email) |54| LLM02 | Sensitive Information Disclosure | PII/secrets in prompts, outputs, or training data; system-prompt leakage |55| LLM03 | Supply Chain | Untrusted models, LoRA adapters, datasets, plugins, `pickle` deserialization |56| LLM04 | Data & Model Poisoning | Tainted training/fine-tune/RAG data; backdoors |57| LLM05 | Improper Output Handling | LLM output passed unsanitized to SQL, shell, browser (XSS), or `eval` |58| LLM06 | Excessive Agency | Over-broad tool scopes, autonomous side effects, no human-in-the-loop |59| LLM07 | System Prompt Leakage | Secrets/authz logic embedded in the system prompt |60| LLM08 | Vector & Embedding Weaknesses | RAG access-control bypass, embedding inversion, cross-tenant leakage |61| LLM09 | Misinformation | Hallucinations relied on for security/safety decisions |62| LLM10 | Unbounded Consumption | Cost/DoS via token floods, model extraction, wallet-drain |6364Produce a per-category table: **Exposure (Yes/No/Partial) → Evidence → Severity → Mitigation**.6566### 2. Prompt Injection & Jailbreak Testing6768**Direct injection** — user input that overrides instructions. Test families:69- Instruction override ("ignore previous instructions and …")70- Role-play / persona escape (DAN-style, hypothetical framing)71- Encoding/obfuscation (Base64, ROT13, leetspeak, homoglyphs, zero-width chars)72- Token smuggling and prompt-boundary confusion (fake delimiters, fake system tags)73- Many-shot jailbreaking (long context of faux dialogue priming compliance)74- Crescendo / multi-turn gradual escalation7576**Indirect injection** — payload arrives via retrieved/processed content (web page, PDF, email, RAG doc, tool output). This is the highest-impact class for agents. Test that retrieved text **cannot** issue commands, exfiltrate context, or trigger tools.7778For every test record: payload, channel (direct/indirect), goal (override / exfiltrate / tool-abuse), and result (blocked / partial / success). Use `scripts/prompt_injection_tester.py` to run a corpus and score outcomes.7980**Refusal-quality note:** a single refusal is not a pass. Re-test the same goal across ≥3 phrasings and obfuscations before marking a control effective.8182### 3. RAG & Vector Store Security8384When reviewing a RAG pipeline:851. **Access control at retrieval** — confirm the vector query is filtered by the *caller's* permissions, not just the app's. Test cross-tenant / cross-user document leakage.862. **Indirect injection surface** — treat every ingested document as attacker-controlled; verify retrieved chunks are clearly delimited and never executed as instructions.873. **Embedding inversion / membership** — sensitive source text may be partially reconstructable from embeddings; flag PII stored unencrypted in the vector DB.884. **Chunk poisoning** — a single malicious document can dominate retrieval; check ranking/dedup and source allow-listing.895. **Citation integrity** — outputs should cite retrieved sources so injected claims are traceable.9091### 4. Agent & Tool-Use (Function Calling / MCP) Security9293The agent is a **confused deputy**: it holds privileges the user may not. Review:94- **Least-privilege tools** — each tool scoped to the minimum action; no broad `execute_shell`/`http_request` to arbitrary hosts95- **Human-in-the-loop gates** on irreversible/outbound actions (payments, email send, file delete, deploy)96- **Argument validation** — tool args are model-generated and untrusted; validate/allow-list server-side97- **Injection → tool chain** — verify retrieved/indirect content cannot drive tool calls (e.g., a web page telling the agent to email its memory out)98- **MCP server hardening** — authenticate clients, scope resources, rate-limit, log every tool invocation; never expose secrets via resource reads99- **Memory poisoning** — persistent agent memory can be seeded with malicious instructions that fire on later turns100101### 5. Model & ML Supply Chain102103- Scan model artifacts for unsafe deserialization — **`pickle`/`.pt`/`.bin` can execute code on load**. Prefer `safetensors`. Run `scripts/model_supply_chain.py` or `modelscan`.104- Verify model provenance, hashes, and signatures; pin versions from trusted registries.105- Review fine-tune/LoRA adapters and datasets for poisoning and licensing.106- Treat third-party plugins/MCP servers as untrusted dependencies (review + pin).107108### 6. Output Handling & Guardrails109110- **Never** pass raw LLM output into `eval`, SQL, shell, or innerHTML. Encode/parameterize at the sink (LLM05).111- Layered guardrails: input filter → policy in system prompt → output classifier → sink-specific sanitization. Defense in depth, since any single layer is bypassable.112- Validate structured output against a strict schema; reject on parse failure.113- Apply egress controls so an injected agent cannot reach attacker URLs.114115---116117## Output Standards118119Produce a structured AI security assessment:120121```markdown122# AI/LLM Security Assessment — [Application]123Date: [Date] | Scope: [Endpoints/Models] | Model: [name/version] | Analyst: [Name]124125## Executive Summary126[2-3 sentences: overall posture, highest risks]127128## OWASP LLM Top 10 Coverage129| ID | Risk | Exposure | Severity | Evidence |130|----|------|----------|----------|----------|131| LLM01 | Prompt Injection | Yes | High | [repro] |132...133134## Confirmed Findings135### [F-01] Indirect Prompt Injection via RAG → Tool Abuse (Critical)136- ATLAS: AML.T0051 / OWASP LLM01+LLM06137- Repro: [payload, channel, steps]138- Impact: [data exfil / unauthorized action]139- Mitigation: [least-privilege tool scope + retrieved-content isolation + HITL]140141## Guardrail Bypass Matrix142| Goal | Direct | Encoded | Multi-turn | Indirect | Result |143144## Recommendations (Prioritized)1451. ...146```147148---149150## Script Reference151152### `prompt_injection_tester.py`153```bash154# Run the built-in injection/jailbreak corpus against an endpoint155python scripts/prompt_injection_tester.py --url https://app.test/api/chat --field message --output results.json156157# Use a custom payload corpus and a refusal-detection keyword set158python scripts/prompt_injection_tester.py --url ... --corpus payloads.txt --judge-keywords refusals.txt159```160161### `model_supply_chain.py`162```bash163# Scan a model directory/file for unsafe pickle opcodes and risky imports164python scripts/model_supply_chain.py --path ./models/model.pt165python scripts/model_supply_chain.py --path ./models/ --recursive --output scan.json166```167168---169170## Skill Integration171172| Next Step | Condition | Target Skill |173|-----------|-----------|--------------|174| Web/API vuln testing of the app shell | App exposes web/API surface | → Skill 09 |175| Cloud/infra hosting the model | Model served on AWS/Azure/GCP/K8s | → Skill 10 |176| Detection rules for prompt-injection attempts | Need SIEM coverage | → Skill 12 |177| Dependency/model-package CVEs | ML libs in use | → Skill 02 |178| Red team narrative incorporating AI abuse | Full engagement | → Skill 14 |179180---181182## References183184- [OWASP Top 10 for LLM Applications (2025)](https://genai.owasp.org/llm-top-10/)185- [MITRE ATLAS — Adversarial Threat Landscape for AI Systems](https://atlas.mitre.org/)186- [NIST AI Risk Management Framework (AI RMF 1.0) + Generative AI Profile](https://www.nist.gov/itl/ai-risk-management-framework)187- [OWASP Agentic AI — Threats and Mitigations](https://genai.owasp.org/)188- [Google SAIF — Secure AI Framework](https://saif.google/)189- [NVIDIA garak — LLM vulnerability scanner](https://github.com/NVIDIA/garak)