How to Threat Model an AI Agent
Threat model an AI agent — tools, permissions, external content, credentials, high-impact actions, human approval, and runtime monitoring.
An AI agent threat model extends chat and RAG risk with action: tools that send email, modify databases, browse the web, call MCP servers, and chain side effects across multiple turns. The model proposes plans; your runtime must enforce what actually executes.
This guide threat-models agent architectures — tools, permissions, external content, credentials, high-impact actions, human approval, and runtime monitoring. Start with what is AI agent security for vocabulary. For chat-only features, use threat model an LLM application first.
Agent vs chat-only threat surface
| Dimension | Chat-only | AI agent |
|---|---|---|
| Primary harm | Bad text | Bad text plus unauthorized actions |
| Trust boundaries | Input → model → output | Input → model → tool runtime → external systems |
| Injection impact | Misleading answers | Data exfil, writes, purchases, emails |
| Monitoring focus | Moderation verdicts | Tool decisions + guard metadata |
Agents compound OWASP LLM06: Excessive Agency with LLM01 injection — manipulation plus capability.
Agent architecture diagram
User task
↓
Agent orchestrator (your code)
↓
LLM proposes: text and/or tool calls
↓
┌──────────────────────────────────────┐
│ Pre-execution gates │
│ • input / injection scan on context │
│ • Agent Action Guard on tool proposal │
│ • human approval (optional) │
└──────────────────────────────────────┘
↓ allow
Tool runtime (APIs, DB, MCP, browser)
↓
Tool result (untrusted) → scan → back to LLM
The orchestrator is the authorization authority. The model is an untrusted planner.
Assets specific to agents
| Asset | Agent-specific risk |
|---|---|
| Tool credentials | Scoped too broadly → one compromise affects all tools |
| MCP server connections | Centralized tool wiring, centralized failure |
| Write paths (DB, email, tickets) | Irreversible or customer-visible harm |
| Browser sessions | Cookie theft, internal page access |
| Long-running session state | Attack accumulates across turns |
| Human approval queues | Social engineering of reviewers |
Trust boundaries for agents
| Source | Trust | Screen before |
|---|---|---|
| User message | Untrusted | LLM call |
| RAG / web fetch | Untrusted | LLM call + after tool return |
| Tool JSON responses | Untrusted | Re-prompting model |
| Model tool arguments | Untrusted | Execution |
| System prompt | Trusted (yours) | Minimize secrets embedded |
Tool output injection is LLM01 via the return path — not only user chat.
Threat model worksheet (agent template)
| ID | Threat | Entry | Impact | Controls | Gaps | Mitigation | Test |
|---|---|---|---|---|---|---|---|
| A1 | Injection → destructive tool call | User chat | Data loss | Action guard | No delete policy | Block delete without approval | Propose delete via injection fixture |
| A2 | Injection → email exfil | User + RAG | PII leak | Action guard + PII scan | Open send_email | Restrict recipients to allowlist | Exfil prompt in staging |
| A3 | Over-privileged MCP tool | Model plan | Lateral movement | Least privilege | Shared admin token | Split read/write MCP servers | Attempt admin tool in prod manifest |
| A4 | Tool output injection | Web fetch tool | Policy bypass | Scan tool output | Raw HTML in result | Injection scan + truncate | Poisoned page in test env |
| A5 | Secrets in tool args | Chat history in args | Credential leak | PII scan + action guard | No scan on args | Block secrets in combined context | Paste sk-test_ in session |
| A6 | Unbounded tool loop | Agent retry logic | Cost / DoS | Turn + tool budgets | No cap | Max 10 tools/turn | Loop injection test |
| A7 | Missing human approval | High-value transfer | Financial loss | Approval workflow | Auto-execute writes | Review queue for amount > X | Large transfer scenario |
| A8 | Cross-tenant tool scope | Wrong tenant_id in args | Data breach | Server-side scope | Trust model args | Inject tenant from session | Cross-tenant tool test |
| A9 | MCP prompt injection | MCP tool result | Tool chain abuse | MCP hardening + scan | Unbounded tool list | MCP security | Malicious MCP response fixture |
| A10 | Long-session drift | 50-turn session | Gradual policy erosion | Per-turn input scan | Scan turn 1 only | Full context scan each turn | Multi-turn attack script |
Extend the table for your tool inventory. One row per tool × abuse pattern is often clearer than generic rows.
Tool inventory exercise
List every tool the agent can call:
| Tool | Actions | Credentials | Read/Write | Blast radius |
|---|---|---|---|---|
database | query, update | RW DB user | Both | High on update |
send_email | send | SMTP API | Write | Medium |
web_fetch | get | None | Read | Medium (injection) |
mcp_tickets | search, create | MCP token | Both | Medium |
For each write action, define:
- Allowed without approval?
- Required arguments schema?
- Tenant scope source (session, not model)?
- Action Guard
policy_id?
See AI agent permissions and least privilege for agents.
Pre-execution control flow
Every proposed tool call should pass:
async function executeToolProposal(proposal: ToolProposal, ctx: SessionContext) {
const guard = await callUnifiedGuard({
checks: ["agent_action"],
agent_action: {
tool_name: proposal.tool,
action: proposal.action,
arguments: proposal.args,
context: summarizeContext(ctx), // no secrets
policy_id: ctx.policyId
}
});
if (guard.decision === "block") {
logAgentEvent({ decision: "block", request_id: guard.request_id });
return { error: "action_blocked" };
}
if (guard.decision === "review") {
await approvalQueue.enqueue(proposal, guard.request_id);
return { status: "pending_approval" };
}
return runTool(proposal, ctx);
}
Pair with Agent Action Guard. Text guards do not replace action policy.
Human-in-the-loop placement
Route to humans when:
- Financial or legal commitments
- Destructive operations (delete, purge, mass update)
- Ambiguous
reviewverdicts from action or output guards - First-time tool use for a tenant tier
Human-in-the-loop agent actions — block unsafe content from reaching reviewers.
External content and browsing agents
Agents that browse inherit web page prompt injection:
- Fetch through sanitizing proxies
- Cap response size; strip active HTML
- Scan extracted text before re-prompting
- Do not let the model choose arbitrary URLs without allowlists (secure agent web browsing)
Credentials and secrets
- Never pass raw API keys in tool arguments assembled from chat
- Use short-lived tokens scoped per tool
- Action guard should block when secrets appear in
contextor serialized args - Rotate credentials if a session logged
unsafeon secrets scan
Runtime monitoring for agents
Log metadata per tool attempt (agent runtime monitoring):
{
"event": "agent_tool_guard",
"session_id": "sess_abc",
"tool_name": "database",
"action": "update",
"decision": "review",
"matched_rule": "Writes require approval",
"guard_request_id": "req_guard_xyz",
"execution": "queued"
}
Correlate with injection scan request_id on tool outputs.
MCP-specific threats
If tools arrive via Model Context Protocol:
- Harden MCP servers at deployment boundary
- Enforce tool permissions in host, not in model
- Screen MCP prompt injection on results
MCP standardizes wiring — not policy.
Testing agent threat mitigations
| Test | Validates |
|---|---|
Injection proposes delete | A1 action block |
| Exfil email to external domain | A2 recipient policy |
| 20 sequential tool calls | A6 budget |
| Poisoned web page in fetch | A4 output scan |
| Cross-tenant ID in tool args | A8 server scope |
Automate defensive fixtures — AI security test suite. Periodic red team exercises for novel chains.
Prioritization matrix
Before enabling write tools in production:
- Action Guard on every proposal (A1, A2)
- Tenant scope from session (A8)
- Tool output injection scan (A4)
- Human approval for destructive/high-value (A7)
Before enabling browse/fetch:
- URL allowlists + response scan (A4, A9)
Related checklists
Summary
Threat model AI agents by inventorying tools and credentials, marking untrusted content at every re-prompt, enforcing pre-execution action policy with Agent Action Guard, scanning tool outputs for injection, routing high-impact operations to human approval, and monitoring with metadata-only logs. Injection that merely annoys in chat can cause incidents when agents have write access — design the orchestrator as the enforcement point.
Mitigate agent threats with Action Guard · AI agent security checklist
Frequently asked questions
How is AI agent threat modeling different from chat-only LLMs?
Agents add tool execution, credentials, external content return paths, multi-turn state, and human approval workflows. The primary harm shifts from bad text to unauthorized actions — injection can trigger writes, emails, or data exfil through tools.
Where must agent authorization be enforced?
In your orchestration layer synchronously before tool execution — after the model proposes a call and before any side effect. The model is an untrusted planner; Agent Action Guard advises; your runtime blocks or allows.
What is tool output injection in agent threat models?
Untrusted text in API, web fetch, or MCP responses re-enters the prompt and can manipulate subsequent tool calls. Treat tool results like user input: scan, frame as untrusted data, and validate actions independently of model reasoning.
Which agent threats need human approval?
High-impact or irreversible operations — financial transfers, mass updates, deletes, external email to non-allowlisted domains, and ambiguous review verdicts from action or output guards.
What should agent security logs capture?
Metadata per tool attempt: session_id, tenant_id, tool_name, action, guard decision, matched_rule, guard request_id, latency, and execution outcome — not full arguments, tool payloads, or chat bodies.
Related reading
- What Is AI Agent Security?
AI agent security covers tool permissions, action policies, untrusted content ingestion, and human oversight for autonom…
- How to Threat Model an LLM Application
Threat model an LLM application — assets, entry points, trust boundaries, data flows, controls, and testing with a pract…
- AI Agent Security Checklist
A production checklist for AI agent security — identity, credentials, tools, permissions, untrusted content, external co…