Practical guide · Agent engineering

AI agent security: a practical threat model and checklist

An agent combines a probabilistic decision maker with data, memory, tools, credentials, and side effects. Secure the deterministic boundaries around that loop. Treat model output as a proposal, give each operation the minimum authority it needs, verify policy in trusted code, and collect enough evidence to stop and investigate a bad run.

Published November 27, 2026 · 15 minute read

The short answer

Start with one workflow and draw every trust boundary from user identity to final side effect. Mark all text from users, files, web pages, retrieval, memory, MCP servers, tool descriptions, and tool results as untrusted. Keep authorization, tenant scope, policy, spending limits, and approval decisions outside the model. Split broad tools into narrow operations, isolate code and browser execution, issue short-lived credentials, and deny network or file access that the task does not need. Record normalized calls and outcomes outside the agent's control. Test denied paths and rehearse revocation before production.

Map trust boundaries before choosing controls

A useful threat model follows a real task, such as issuing a refund, editing a repository, booking travel, or researching a customer. List the authenticated principal, session, model, system instructions, retrieved content, memory, tools, MCP clients and servers, credentials, data stores, approval service, execution environment, external destinations, and audit store. For each boundary, write down who controls its input and what the next component is allowed to believe.

NIST's Generative AI Profile recommends threat modeling, red teaming, incident disclosure, and monitoring across the system lifecycle. OWASP's Top 10 for LLM applications is a useful coverage map, but the deployed workflow decides which failures are costly.

BoundaryQuestion to answerEvidence
Identity and tenantWhich trusted service establishes the principal and scope?Auth context passed by the application, never copied from the prompt.
Content and memoryWhich fields can contain hostile or stale instructions?Origin, owner, timestamp, permissions, and retention class.
Tools and servicesWhat can this operation read, change, send, buy, or delete?Typed schema, server policy, scoped credential, and receipt.
ExecutionWhat file, process, network, and resource access exists?Enforced sandbox policy plus denial-test results.
Human reviewWhich exact action is the reviewer approving?Bound arguments, policy version, identity, expiry, and one-time decision.

Treat prompt injection as untrusted input

Prompt injection can arrive directly from a user or indirectly through a page, email, document, image, repository file, memory record, tool result, or connected service. OWASP's 2026 prompt-injection guidance treats these inputs as a system risk because successful injection can change decisions, disclose information, or trigger tools.

Do not rely on a stronger system prompt to settle the boundary. The OWASP prevention cheat sheet combines input handling, least privilege, output validation, monitoring, and human review. Preserve content provenance, separate data from trusted instructions in the application, restrict what retrieved content can influence, and validate every proposed action against current state and policy.

  • Never let prompt text supply authenticated identity, tenant scope, role, or approval state.
  • Allowlist the tools and data sources available to each task type.
  • Bound retrieved bytes, tool-result size, recursion, calls, time, and spend.
  • Validate structured output semantically before another component acts on it.
  • Test instructions hidden in retrieved pages, attachments, metadata, tool output, and persistent memory.

Give every tool the least authority it needs

A model should choose among narrow operations rather than receive a general shell, database client, mailbox, or browser profile. Anthropic's tool implementation guidance stresses clear tool definitions and detailed errors. Security also requires server-side authorization, state checks, bounded results, and credentials scoped to the operation.

For MCP connections, follow the protocol's security best practices. Validate redirect URIs, prevent token passthrough and confused-deputy paths, avoid session IDs as authorization, and apply access control at every server that owns protected data or actions.

  1. Split read, draft, preview, publish, delete, and permission-changing operations.
  2. Inject identity and selected-record context from trusted application state.
  3. Constrain types, enums, amounts, destinations, paths, and record counts in the schema.
  4. Recheck authorization and business policy immediately before the side effect.
  5. Use idempotency keys and store a receipt for external writes.
  6. Return compact results with stable IDs, provenance, and explicit errors.

Use the detailed agent tool-design workflow to write these contracts and selection tests.

Bind approvals to the exact action

A generic Continue button does not prove informed consent. Show the reviewer the operation, normalized arguments, affected records, destination, expected effect, policy reason, and preview. Bind the decision to that immutable payload, reviewer identity, policy version, and expiry. If any argument or current-state assumption changes, request a new decision. Consume an approval once and keep rejection as a first-class outcome.

Microsoft's computer-use safety guidance recommends isolated environments, allowlists, and human review for high-impact actions. Apply the same rule to API tools. Approval reduces risk only when a trusted executor revalidates the exact request after the decision.

The approval-gate guide covers risk classes, pause and resume behavior, expiry, rejection, replay prevention, and audit records.

Contain execution and protect secrets

Run code, shell, browser, and file-changing work in a disposable environment with explicit filesystem, process, network, and resource policies. Mount only the task-owned files. Start with no outbound network access and allowlist exact destinations when a dependency cannot be vendored or proxied. Set ceilings for wall time, CPU, memory, disk, processes, downloads, model calls, and spend.

Use short-lived, task-scoped credentials for test or staging accounts. Keep secrets out of prompts, retrieved documents, source files, command-line arguments, model-visible environment dumps, and tool results. Redact logs without destroying the IDs needed to reconstruct a run. Store the audit trail beyond the agent's write permissions.

OpenAI's safety best practices recommends adversarial testing, human review, constrained inputs and outputs, and user reporting. For coding workflows, follow Learnetto's sandboxing guide and test that denied access actually fails closed.

Detect, respond, and learn from failures

Give every run a stable ID and connect the request, model turns, retrieval, memory access, tool calls, policy decisions, approvals, side effects, receipts, and final outcome. Alert on forbidden-tool attempts, repeated denials, cross-tenant lookups, unexpected destinations, approval mismatches, new high-risk tool sequences, runaway loops, secret-like output, and missing receipts.

  1. Stop new runs and disable the affected tool, MCP server, credential, or integration.
  2. Revoke credentials and approvals, preserve immutable traces, and identify completed side effects.
  3. Notify owners of affected data and systems using the existing incident process.
  4. Reproduce the failure in an isolated fixture and fix the enforcement point outside the model where possible.
  5. Add the case to the normal regression suite and verify rollback, cleanup, and recovery.

Use agent observability for the trace contract and red teaming to turn threat hypotheses into bounded tests.

AI agent security review checklist

ControlPass evidenceFail condition
Trust-boundary mapOwners, inputs, permissions, and side effects are documented.A component trusts content with unknown origin or authority.
Identity and tenant scopeTrusted code injects and enforces current principal context.Prompt text can select identity, role, or tenant.
Prompt-injection containmentDirect and indirect cases cannot change permission or policy.Retrieved content can trigger a protected action.
Least-privilege toolsSchemas, credentials, and result bounds match one operation.A broad tool exposes unrelated reads or writes.
Approval bindingDecision binds arguments, identity, policy, expiry, and one use.Arguments can change after review or approval can replay.
Execution isolationDenied file, network, process, and resource tests pass.Isolation silently degrades or shares production state.
Secret handlingShort-lived credentials avoid model-visible channels.Secrets appear in prompts, files, output, arguments, or logs.
Safe side effectsWrites are revalidated, idempotent, and receipted.A timeout or replay can duplicate an effect.
Independent audit trailThe agent cannot alter security evidence.The acting process can delete or rewrite its own record.
Incident responseRevocation, containment, evidence, notification, and recovery are rehearsed.Owners cannot stop the tool or identify completed actions.

Build the security evidence

Start with the most consequential workflow, complete the checklist, and convert each fail condition into a test. Continue with the production AI engineering learning path, then create a task-specific agent test set. A policy document becomes useful when the release gate can show which denied paths were exercised and which side effects were reconciled.