OWASP has published an AI agent security cheat sheet that lays out how to lock down autonomous systems built on large language models. The AI agent security guidance targets software that can reason, plan, use tools, keep memory and act on its own, which opens risks beyond ordinary prompt injection.
The document lists the main threats first, then gives practical controls and code examples for each area.
The risks it names
The cheat sheet catalogs thirteen risk types. Some are familiar, others are specific to agents:
- Prompt injection, direct or hidden in websites, documents and emails
- Tool abuse and privilege escalation through overly permissive tools
- Data exfiltration through tool calls, API requests or outputs
- Memory poisoning that carries malicious data into later sessions or other users
- Goal hijacking, excessive autonomy and abuse of high-impact actions
- Manipulation of risk scores, model confidence or approval thresholds
- Cascading failures across multi-agent systems
- Malicious changes made through AI developer consoles
- Denial of wallet, where unbounded agent loops run up API and compute bills
- Sensitive data exposure and supply chain attacks on third-party tools
Give agents the least access they need
The first recommendation is least privilege. Agents should get only the tools their task needs, with permissions scoped per tool, such as read-only access to one folder. Internal and user-facing agents should use separate tool sets, and sensitive operations should require explicit authorization.
The guide contrasts a bad configuration, a shell tool that allows any command, with a good one: a file reader limited to a reports directory that blocks patterns like env files, keys and anything labeled secret.
Authorization has to live outside the agent. The execution component must check that an approval belongs to the current actor and the exact tool call, is still valid and hasn’t been used. It should check and consume that approval in one atomic step, so concurrent or repeated requests can’t reuse it. A simple user_confirmed flag isn’t enough. If the target or parameters change, the agent needs a new approval, and unknown tools should fail closed.
Treat everything external as untrusted
For input handling, the cheat sheet says to treat user messages, retrieved documents, API responses and emails as untrusted data. It suggests sanitizing content before it enters the agent’s context, drawing clear boundaries between instructions and data, filtering known injection patterns, and sometimes using a separate model call to validate or summarize untrusted content.
Lock down memory
Memory gets its own section because poisoned entries persist. Recommended steps include:
- Validate and sanitize data before storing it
- Isolate memory between users and sessions
- Set expiration and size limits
- Audit stored content for sensitive data
- Use cryptographic integrity checks on long-term memory
The example class caps memory at 100 items, limits each item to 5,000 characters, expires entries after 24 hours, redacts sensitive data, scans for injection attempts and stores a checksum with every entry.
Humans stay in the loop for risky actions
The guide wants explicit approval for high-impact or irreversible actions, previews before execution, autonomy limits tied to risk, and a way for users to interrupt and roll back. Its example ranks tools by risk: searching documents and reading files are low, writing files is medium, sending email and executing code are high, and deleting a database or transferring funds are critical. Only the two low-risk tools skip review, and any unmapped tool is treated as high risk.
For destructive, financial, administrative or publicly visible actions, a plain approval prompt isn’t enough. The agent can propose an action, but a policy service should independently check scope, privilege and approval state. Approval records should name the actor, tool, target, normalized parameters, timestamp and expiry. Critical steps such as payments, privilege changes, bulk deletion or production deployment call for step-up authentication.
Validate what comes out, and watch it
Outputs get the same scrutiny as inputs. The guide recommends schema-validated structured output, filtering for sensitive data, rate limits and scope limits. Its sample pipeline rejects tool calls outside an allowlist, blocks parameters that mention keys or passwords, and flags large payloads sent to webhooks.
On monitoring, teams should log every decision, tool call and outcome, track token use and cost per session, alert on security events and keep audit trails. For high-risk actions, logs should also record the risk classification, authorization outcome, approval identifier, result and policy version.
What teams should do first
Teams running agents in production can start with an audit of tool permissions, since over-permissioned tools sit behind several of the listed risks. Next, move approval checks out of the prompt and into the execution layer, and put limits on memory and loop counts to contain both poisoning and runaway costs. The OWASP cheat sheet is a free checklist for those reviews.
Source: cheatsheetseries.owasp.org