AI Agents
·IdenticAPI

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

DimensionChat-onlyAI agent
Primary harmBad textBad text plus unauthorized actions
Trust boundariesInput → model → outputInput → model → tool runtime → external systems
Injection impactMisleading answersData exfil, writes, purchases, emails
Monitoring focusModeration verdictsTool 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

AssetAgent-specific risk
Tool credentialsScoped too broadly → one compromise affects all tools
MCP server connectionsCentralized tool wiring, centralized failure
Write paths (DB, email, tickets)Irreversible or customer-visible harm
Browser sessionsCookie theft, internal page access
Long-running session stateAttack accumulates across turns
Human approval queuesSocial engineering of reviewers

Trust boundaries for agents

SourceTrustScreen before
User messageUntrustedLLM call
RAG / web fetchUntrustedLLM call + after tool return
Tool JSON responsesUntrustedRe-prompting model
Model tool argumentsUntrustedExecution
System promptTrusted (yours)Minimize secrets embedded

Tool output injection is LLM01 via the return path — not only user chat.

Threat model worksheet (agent template)

IDThreatEntryImpactControlsGapsMitigationTest
A1Injection → destructive tool callUser chatData lossAction guardNo delete policyBlock delete without approvalPropose delete via injection fixture
A2Injection → email exfilUser + RAGPII leakAction guard + PII scanOpen send_emailRestrict recipients to allowlistExfil prompt in staging
A3Over-privileged MCP toolModel planLateral movementLeast privilegeShared admin tokenSplit read/write MCP serversAttempt admin tool in prod manifest
A4Tool output injectionWeb fetch toolPolicy bypassScan tool outputRaw HTML in resultInjection scan + truncatePoisoned page in test env
A5Secrets in tool argsChat history in argsCredential leakPII scan + action guardNo scan on argsBlock secrets in combined contextPaste sk-test_ in session
A6Unbounded tool loopAgent retry logicCost / DoSTurn + tool budgetsNo capMax 10 tools/turnLoop injection test
A7Missing human approvalHigh-value transferFinancial lossApproval workflowAuto-execute writesReview queue for amount > XLarge transfer scenario
A8Cross-tenant tool scopeWrong tenant_id in argsData breachServer-side scopeTrust model argsInject tenant from sessionCross-tenant tool test
A9MCP prompt injectionMCP tool resultTool chain abuseMCP hardening + scanUnbounded tool listMCP securityMalicious MCP response fixture
A10Long-session drift50-turn sessionGradual policy erosionPer-turn input scanScan turn 1 onlyFull context scan each turnMulti-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:

ToolActionsCredentialsRead/WriteBlast radius
databasequery, updateRW DB userBothHigh on update
send_emailsendSMTP APIWriteMedium
web_fetchgetNoneReadMedium (injection)
mcp_ticketssearch, createMCP tokenBothMedium

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 review verdicts 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 context or serialized args
  • Rotate credentials if a session logged unsafe on 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:

MCP standardizes wiring — not policy.

Testing agent threat mitigations

TestValidates
Injection proposes deleteA1 action block
Exfil email to external domainA2 recipient policy
20 sequential tool callsA6 budget
Poisoned web page in fetchA4 output scan
Cross-tenant ID in tool argsA8 server scope

Automate defensive fixtures — AI security test suite. Periodic red team exercises for novel chains.

Prioritization matrix

Before enabling write tools in production:

  1. Action Guard on every proposal (A1, A2)
  2. Tenant scope from session (A8)
  3. Tool output injection scan (A4)
  4. Human approval for destructive/high-value (A7)

Before enabling browse/fetch:

  1. URL allowlists + response scan (A4, A9)

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