Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Sec Ai Llm?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/57blocks-sec-ai-llm-security-plugin)
---
name: "sec-ai-llm"
description: "Security knowledge pack for LLM / agents / RAG / MCP. Load when the project depends on openai, @anthropic-ai/sdk, anthropic, langchain, langgraph, llamaindex, ai (Vercel AI SDK), @modelcontextprotocol/sdk, mcp, crewai, autogen, transformers, pinecone/weaviate/qdrant/chroma/pgvector, ollama/vllm/ray/mlflow/gradio, or when code builds prompts, defines tools/function calling, implements agents, RAG, MCP servers or clients, browser/computer-use agents, agent-to-agent calls, realtime voice, model serving or fine-tuning pipelines. Covers prompt injection, tool privilege escalation, output injection, RAG isolation, delegated access, AI infrastructure, cost, and model supply chain."
---
# sec-ai-llm: LLM, agent, RAG and MCP security checklist
## Scope
Application code that calls large language models: chat/assistants, function calling and agent loops, RAG ingestion and retrieval, memory, MCP servers/clients, third-party agent skills, and AI features embedded in Web/Web3 products.
## Read first
- Severity definitions: [severity.md](../sec-core/severity.md). "LLM prompt injection can trigger tool calls with side effects" is **P1** by default; raise to **P0** when it can move funds, read/write other users' data, or execute arbitrary code. **Private key/funds issues are at least P1**.
- **Severity calibration for local tools/MCP**: for argument injection and path traversal in a local stdio MCP server or local tool (AI-12, AI-15, and server-internal exec in AI-22), if exploitation requires **both** preconditions "prompt injection successfully drives the model" and "the host/client auto-approves that tool call (auto-approve, YOLO mode)", default to **two levels below the item's default, minimum P2** (P0→P2, P1→P2), and state both preconditions in the severity rationale; when only one precondition is needed (e.g. the host calls without approval by default, or the attacker can call the tool directly without injection), downgrade one level. When the server is remotely reachable, unauthenticated, or there is a zero-interaction injection source (you can show the agent will automatically read untrusted external web pages/issues/email etc. and call the tool in the same turn), **do not downgrade**; keep the item's default. Repository/document content returned by the server does not by itself count as a zero-interaction injection source.
- **Configuration preconditions and vendor statements**: issues that only hold under operator misconfiguration, such as authentication fail-open or allow-by-default (e.g. calling `next()` directly when `JWT_SECRET` is missing, while deployment docs/example config require setting it), and SSRF-class issues the vendor explicitly declares out of scope in code or security policy, default to P2; use the item's default only when the default configuration (default install, skills/tools enabled by default) is affected, and cite the default-configuration evidence in the severity rationale.
- **Text-to-SQL is not itself a vulnerability**: when the product feature is "let the model run queries", "the model can run arbitrary SQL" is not P1 in itself; rate by the database account's permission scope: read-only, limited to data visible to the current tenant/user → P3 hardening; read-only but able to read the whole database or other users' data → P2 (P1 if triggerable anonymously or via zero-interaction injection); write/DDL permissions or cross-tenant → AI-13 default. Injection where model input is concatenated into SQL identifiers/parameters (e.g. `table_name` concatenation) is a separate root cause, rated separately, and is not downgraded because "arbitrary SQL is already possible".
- **Dependency CVE lists**: a dependency CVE list (raw osv-scanner output) without proof of reachability to the specific vulnerable function is not a P1 finding; classify as P2/P3 per WEB-55 (e.g. HTTP framework CVEs on a stdio server are usually unreachable).
- General Web issues are not repeated here; reference [sec-web](../sec-web/SKILL.md) directly: IDOR/tenancy WEB-02/03, XSS WEB-29/30, CSP WEB-31, frontend secrets WEB-33, SQL WEB-20/21, commands WEB-23, SSTI WEB-24, dynamic execution WEB-25, SSRF WEB-37, path traversal WEB-38, uploads WEB-39, deserialization WEB-41, hardcoded secrets WEB-42, rate limiting WEB-54 (LLM endpoints named explicitly), dependencies WEB-55, PII in logs WEB-56.
- AI agents holding wallets or sending transactions: also load [sec-wallet-dapp](../sec-wallet-dapp/SKILL.md) (WAL-04 hot wallet, WAL-10 limits, WAL-31 simulation, WAL-48 withdrawal risk controls, WAL-51 signing service policy, WAL-53 session keys).
- Secure agent/tool design patterns and MCP hardening checklist: [refs/agent-tool-design.md](refs/agent-tool-design.md); indirect injection test cases and how to run them: [refs/test-prompts.md](refs/test-prompts.md).
## Four general principles
1. **Model output is untrusted data**, on par with user input: validate/encode it per the sink's rules before it reaches HTML, SQL, shell, paths, URLs, `eval` or transaction parameters.
2. **The model is not a security boundary**: enforce authorization, amounts, recipients, tenant filters and confirmation binding with deterministic code at the tool entry point; "do not do X" in the system prompt is only a suggestion.
3. **Credentials follow the user**: tools run with the identity and scope of "the current requesting user", not with a service-level master credential; an agent that reads untrusted content must not also hold high-risk write capabilities (see Rule of Two in refs).
4. **Everything has a cap**: steps, tokens, spend, concurrency, tool output size, memory writes, metered per user and tenant.
---
## Checklist
The 77 items live in `refs/items-*.md`, so a task reads only the part it needs. This index gives each item's ID, title and default level.
- Writing or changing code, or `sec-check`: read the files covering what the change touches.
- Full audit: sec-audit assigns item IDs to each perspective; read only those items.
- Looking up one item: open the file named here and read from its `### AI-NN` heading to the next `###` heading.
**[refs/items-injection.md](refs/items-injection.md)**
- AI-01 User input enters the system role, or the role field can be forged by the client · default P1
- AI-02 Indirect injection: untrusted content and side-effecting capabilities in the same context · default P1 (P0 when it can transfer funds, send other users' data out, or execute code)
- AI-03 Model output used for authorization, risk control or security decisions · default P0 (when it decides access/funds) / P2 (advisory only)
- AI-04 Secrets, internal addresses or authorization rules in the system prompt · default P1 (P0 for production API keys/database credentials)
- AI-05 Instructions and data not separated; injection defended only by prompts or blocklists · default P2 (missing defense in depth)
- AI-06 Hidden text and multimodal carriers not normalized · default P2 (rate as AI-02 when combined with AI-02)
- AI-07 Persistent memory poisoning and lost provenance · default P1
**[refs/items-tools.md](refs/items-tools.md)**
- AI-08 Overly broad tools: generic shell / arbitrary HTTP / raw SQL / whole-disk files · default P1
- AI-09 Agent acts for users with service-level credentials (confused deputy / IDOR) · default P0
- AI-10 Side-effecting operations without human confirmation · default P1 (P0 for funds/on-chain transactions)
- AI-11 Confirmation not bound to execution · default P1
- AI-12 Path traversal in tool arguments · default P0 (arbitrary read/write)
- AI-13 Text-to-SQL / query tool injection and privilege escalation · default P0
- AI-14 URL tool arguments: SSRF and outbound access · default P1 (P0 when cloud metadata/internal admin planes are reachable)
- AI-15 Tool arguments reach shell / commands · default P0
- AI-16 Loose tool schema, or schema and handler disagree · default P2 (rate per the corresponding item when it leads to privilege escalation/out-of-bounds access)
- AI-17 Agent loop without step, time or spend caps · default P2 (P1 when the loop has paid side effects)
- AI-18 Executing model-generated code without isolation · default P0
- AI-19 Agent can rewrite its own configuration, permissions or persistence · default P1
- AI-20 MCP tool poisoning, description changes (rug pull) and metadata treated as policy · default P1
- AI-21 Remote MCP server: no authentication, token passthrough, state handles not bound to the user · default P0
- AI-22 Local MCP: launch command injection, unauthenticated localhost port · default P1
- AI-23 Multi-agent / sub-agent trust inheritance · default P1
**[refs/items-output-data.md](refs/items-output-data.md)**
- AI-24 Model output rendered as HTML · default P1 (stored/shareable conversations; P2 when the sink appears only in output of skills/plugins that are off by default)
- AI-25 Data exfiltration via Markdown images/links · default P2 (P1 when there is a zero-interaction injection source and the context contains credentials or other users' data)
- AI-26 Model output reaches eval / SQL / shell / templates · default P0
- AI-27 Model output used as file path, redirect or request target · default P1
- AI-28 Structured output not validated · default P2 (rate per AI-03/AI-53 when fields decide permissions/amounts)
- AI-29 Generated code auto-executed, committed or deployed · default P1
- AI-30 High-risk conclusions taken directly from the model (hallucination and overreliance) · default P2
- AI-31 Vector retrieval without tenant/document-level ACL filtering · default P0
- AI-32 Knowledge base poisoning: low-trust sources can write to the shared corpus · default P1
- AI-33 Ingesting untrusted files and URLs: parsers, loaders and SSRF · default P1
- AI-34 Treating embedding vectors as non-sensitive data · default P2 (P1 when they contain PII/confidential documents)
- AI-35 Vector database itself exposed or unauthenticated · default P0 (when it holds user data)
- AI-36 Forgeable citations and sources · default P2
- AI-37 PII/confidential data sent to third-party models without assessing retention and training · default P2 (P1 when it violates explicit contractual/regulatory requirements)
- AI-38 Full prompts/responses in logs and observability platforms · default P2 (P1 when containing secrets/credentials)
- AI-39 Cross-session/cross-user context leakage · default P0
- AI-40 Conversation share links and export · default P1
- AI-41 Excessive context: data the user may not see placed into the context · default P1
**[refs/items-cost-supply.md](refs/items-cost-supply.md)**
- AI-42 Model API keys in frontend, mobile or client code · default P0
- AI-43 No per-user rate and spend caps (denial of wallet) · default P1
- AI-44 No length caps on input, output and tool results · default P2
- AI-45 Model, provider and baseURL configuration can be tampered with or downgraded · default P2 (P1 when traffic and keys can be redirected to a third party)
- AI-46 Streaming endpoint abuse · default P2
- AI-47 Unsafe model/index loading: pickle and remote code · default P0
- AI-48 Model and dataset sources not pinned · default P2
- AI-49 Prompt template injection (Jinja / format strings) · default P0 (when RCE is possible) / P2 (prompt rewriting only)
- AI-50 Third-party agent skills, plugins and MCP servers not reviewed · default P1 (P0 when known malicious or containing exfiltration logic)
- AI-51 Dangerous framework components or vulnerable AI SDK versions · default P1 (P0 for reachable RCE CVEs)
**[refs/items-web3.md](refs/items-web3.md)**
- AI-52 AI agent directly holds private keys or the main funds wallet · default P0
- AI-53 LLM decides amounts, recipient addresses, contracts or calldata · default P0
- AI-54 Using an LLM as a price, oracle or on-chain decision source · default P1
- AI-55 On-chain and social data as injection carriers into trading-capable agents · default P1
**[refs/items-infra.md](refs/items-infra.md)**
- AI-56 Unauthenticated model server or ML orchestrator exposed · default P1 (P0 when it reaches code execution, model/file write or user data)
- AI-57 Low-code / agent workflow platform: code nodes, flow export and HTTP nodes · default P0
- AI-58 Inference or distributed transport deserializes network bytes · default P0
- AI-59 Model, artifact and dataset pull clients trust the registry · default P1 (P0 for arbitrary file write or RCE)
- AI-60 Inference API enables model extraction or membership inference · default P2 (P1 for proprietary/fine-tuned models or models trained on sensitive data)
- AI-61 Coding-agent and repository config auto-execution · default P1 (P0 for zero-click RCE)
- AI-77 Building, containerizing or deploying an imported model/artifact bundle trusts its manifest · default P1 (P0 when bundle content runs code on the build host itself or reaches build/cloud deploy credentials)
**[refs/items-ecosystem.md](refs/items-ecosystem.md)**
- AI-62 MCP server-initiated requests: sampling, elicitation and roots · default P1
- AI-63 Computer-use and browser agents act inside the user's sessions · default P1 (P0 when it can move funds, change account security settings or send messages as the user)
- AI-64 Agent-to-agent protocols (A2A and similar): identity and task trust · default P1
- AI-65 Delegated access: tokens an agent holds for users · default P1 (P0 when a token is shared across users or tenants)
- AI-66 Training, fine-tuning and evaluation pipelines take untrusted data · default P2 (P1 when the result is deployed to production users)
- AI-67 Provider-side object IDs used as access tokens · default P1 (P0 when IDs reach other tenants' files or conversations at scale)
- AI-68 Realtime and voice sessions: ephemeral credentials and in-session actions · default P2 (P1 when ephemeral keys can be minted without authentication or carry tool access)
**[refs/items-runtime.md](refs/items-runtime.md)**
- AI-69 Messaging-channel and device-pairing ingress for chat-driven agents · default P1 (P0 when it reaches exec/file tools)
- AI-70 Command allowlist and approval policy bypass · default P0
- AI-71 Agent sandbox weaknesses · default P0
- AI-72 LLM gateway / key broker admin plane · default P0
- AI-73 MCP/OAuth client discovery and token handling · default P1
- AI-74 Framework serialization injection · default P1 (P0 when it reaches code execution or secret loading)
- AI-75 Agent actions not attributable; no kill switch · default P2 (P1 for funds/admin tools)
- AI-76 Security/operations agents without a hard target scope · default P1
---
## Self-check workflow (after writing or changing AI-related code, before committing)
1. **Draw four maps**: execution identity (whose credentials), capabilities (each tool's side effects), sources that can write into context/memory, output destinations (UI, logs, tools, on-chain).
2. **Untrusted sources**: list all external content entering the model context (AI-02, 06, 07, 32, 55) and mark which write tools share a turn with it.
3. **Tool entry points**: does each tool take identity from the context and do resource-level authorization (AI-09), have a strict schema (AI-16), validate arguments per sink (AI-12–15), and require bound confirmation for high-impact actions (AI-10, 11).
4. **Output sinks**: where model output ends up in HTML/markdown, SQL, shell, paths, URLs or transaction parameters (AI-24–28, 53).
5. **RAG and sessions**: retrieval carries server-side tenant/ACL filters (AI-31); session and cache keys include the user (AI-39).
6. **Secrets and logs**: no secrets in prompts (AI-04), keys not on the client (AI-42), logs/traces redacted (AI-38).
7. **Caps**: steps, tokens, spend, concurrency, tool output size (AI-17, 43, 44, 46).
8. **Supply chain**: model loading method (AI-47), version pinning (AI-48), third-party skill/MCP scans (AI-50), dangerous components (AI-51), build/containerize of imported bundles (AI-77).
9. **Run tools and tests**: `semgrep --config p/ai-best-practices` + the scan commands in the README; add the cases from [test-prompts](refs/test-prompts.md) to automated tests.
10. **Conclusion**: fix P0/P1 before delivery; for anything that cannot be fixed, document location, exploit path and impact, and have a person sign off on accepting the risk.
### Noise reduction: usually do **not** report (unless there is a concrete exploit path)
- Only "can be jailbroken into saying inappropriate content/the system prompt" without crossing a data or permission boundary (content safety issues are described separately as product risk and not rated as security vulnerabilities).
- Things the user explicitly asked the agent to do using permissions they already have (not a confused deputy).
- Best-practice warnings about missing moderation APIs/safety settings/system prompts (semgrep `*-missing-moderation`, `*-missing-system-prompt`, etc.) with no reachable impact → P3.
- "XSS" where model output is rendered via plain-text interpolation.
- Experimental scripts used only by local developers with no credentials and no network.
- Example `JWT_SECRET`/placeholder secrets in `.env.example`, README or docs: deployment hardening (P3; suggest refusing known example values at startup); report P1/P0 per WEB-10 only when code falls back to that value at runtime (`process.env.JWT_SECRET || 'changeme'`) or authentication fails open when the secret is missing (calls `next()` directly).
- Dependency CVE lists without proven reachability, issues in local stdio MCP that require prompt injection first (and host auto-approval), fail-open that depends on operator misconfiguration, SSRF the vendor declares out of scope, and text-to-SQL by design: handle per the severity calibration in "Read first" rather than reporting at the item's default P0/P1.
(Noise-reduction principles rewritten from cloudflare/security-audit-skill@c1c8a8c1 AI-AND-LLM.md "Core discipline", "Validation rules" and the false-positive filtering approach of anthropics/claude-code-security-review@0c6a49f1.)
---
## Audit perspectives
For a full audit, make one pass per perspective (can be split across sub-agents in parallel); each perspective outputs "checked list + findings". P0/P1 findings must state `file:line`, attacker, affected principal, execution identity, concrete action and impact; mark anything that depends on external model/deployment behavior not observable locally as "needs-verification".
The index in "Checklist" says which file holds each item. When the target holds wallets or sends transactions, AI-52–55 apply to every perspective.
### 1. Trust boundaries and injection
- Enumerate every source entering the context (users, documents, web pages, email, tool results, memory, sub-agents, on-chain data, images), and for each answer: who can write it, in whose session it is read, which capabilities exist in the same turn.
- Check prompt assembly: role origin, concatenation method, provenance tags, hidden-character handling, secrets in the system prompt.
- Run at least one end-to-end indirect injection test with the payloads from [test-prompts](refs/test-prompts.md).
- Repo-shipped agent config and rule files (AI-61) count as injection sources when the target is a coding agent or MCP client.
- Items: AI-01–07, AI-32, AI-55, AI-61, AI-63, AI-64.
### 2. Tools and permissions
- Trace backwards from every side-effecting tool: handler → argument validation → confirmation binding → dispatcher → model context → retrieval/ingestion.
- Build a "tool × execution identity × resource scope" matrix; compare direct call, retry, resume, batch and sub-agent paths, and take the weakest.
- MCP: authentication, audience, handle binding, local listeners, launch commands, description hashes and version pinning; client OAuth callbacks and deep links (AI-61).
- AI infrastructure: bind addresses and auth of model servers and orchestrators, code-executing workflow routes, transport deserialization (AI-56–58).
- Items: AI-08–23, AI-50, AI-52, AI-56–58, AI-61–65, AI-68–73, AI-75, AI-76.
### 3. Output and data flow
- Trace every completion/tool-call result to its sinks (DOM, markdown, SQL, shell, files, URLs, redirects, transactions, database writes).
- RAG: two-tenant + revocation tests; memory and session ownership; cache keys; share links.
- Privacy: list of fields sent to the model, logs and traces, provider data settings (mark out-of-repo items as needs-verification).
- Items: AI-24–31, AI-33–41, AI-53, AI-54, AI-67, AI-74.
### 4. Cost and supply chain
- Every entry point that calls a model: authentication, rate limiting, budget, `max_tokens`, steps, concurrency, cancel on disconnect, model allowlist.
- Models and data: loading method, `trust_remote_code`, revision, provenance; third-party skill/MCP scan results; AI SDK dependency CVEs and dangerous components.
- Registry/hub/dataset clients: every filename source, response size caps, token realm binding, digest coverage (AI-59); extraction exposure of the inference API (AI-60).
- Build and deploy of imported bundles: every manifest field traced to every generated Dockerfile, template and deploy script; template sandboxing; path containment in the build context (AI-77).
- Items: AI-17, AI-42–51, AI-56, AI-59, AI-60, AI-66, AI-68, AI-72, AI-74, AI-77.
### Mandatory appendix tables (AI apps)
When auditing an AI application, write both tables to the report-internal appendices; a missing table means the audit is not complete. Every row ends as a finding or a dismissed entry with a reason, as in sec-audit Step 3.
1. **Agent capability matrix**: one row per tool/action (including MCP tools, code nodes, callback routes that connect or spawn). Columns: side effect (read / write / outbound / exec / funds); executing identity and credential; confirmation (none / model-asked / UI) and whether it is bound to execution (AI-11); injection sources reachable in the same context; trigger (user / zero-click / scheduled / webhook); lethal-trifecta verdict: private data + untrusted content + outbound channel all present → candidate finding.
| Tool/action | Side effect | Identity/credential | Confirmation (bound?) | Injection sources in context | Trigger | Trifecta |
|---|---|---|---|---|---|---|
2. **Model-output sink table**: one row per model output or tool result → sink (DOM, markdown, SQL, shell, file path, URL/redirect, transaction, DB write, terminal/ANSI, CSV/spreadsheet) → validation applied (file:line) → verdict.
| Output/tool result | Sink | Validation | Verdict |
|---|---|---|---|
### Application-type pages
Load every page matching the target (a target can match several; extension and node managers for AI tools count as agent platforms) and record each of its attack patterns as applicable / not applicable (reason) / SEC-xxx, per sec-audit Step 3:
- Chat and RAG apps: [refs/app-chat-rag.md](refs/app-chat-rag.md)
- Low-code / agent workflow platforms: [refs/app-agent-platform.md](refs/app-agent-platform.md)
- MCP servers: [refs/app-mcp-server.md](refs/app-mcp-server.md)
- MCP clients, inspectors and bridges: [refs/app-mcp-client.md](refs/app-mcp-client.md)
- Coding agents and IDE assistants: [refs/app-coding-agent.md](refs/app-coding-agent.md)
- Model serving and ML infrastructure: [refs/app-model-serving.md](refs/app-model-serving.md)
- Security and operations agents: [refs/app-security-agent.md](refs/app-security-agent.md)
---
## Further reading
- Secure agent design patterns and MCP hardening: [refs/agent-tool-design.md](refs/agent-tool-design.md); injection test cases: [refs/test-prompts.md](refs/test-prompts.md)
- OWASP Top 10 for LLM Applications 2025 (CC-BY-SA, referenced only): https://genai.owasp.org/llm-top-10/
- OWASP Top 10 for Agentic Applications (CC-BY-SA, referenced only): https://genai.owasp.org/
- MITRE ATLAS: https://atlas.mitre.org/
- MCP Security Best Practices: https://modelcontextprotocol.io/docs/tutorials/security/security_best_practices
- MCP Authorization: https://modelcontextprotocol.io/specification/latest/basic/authorization
- NVIDIA SkillSpector: https://github.com/NVIDIA/SkillSpector
- promptfoo red team plugin list: https://www.promptfoo.dev/docs/red-team/plugins/
- NVIDIA garak: https://github.com/NVIDIA/garak
- Tencent AI-Infra-Guard (AI component vulnerability index, MCP rules): https://github.com/Tencent/AI-Infra-Guard
- GitHub Advisory Database: https://github.com/advisories