← Home · Tutorial 19 · Production engineering

Securing AI agents: the OWASP agentic Top 10 in practice

Ten ways an AI agent goes wrong, and the controls that belong in code.

Last reviewed 26 November 2026 · Written with AI assistance and reviewed by me

Where this comes from: the OWASP Top 10 for Agentic Applications for 2026, released by the OWASP GenAI Security Project on 9 December 2025 and licensed CC BY-SA 4.0. Everything here is my own paraphrase and my own examples, not OWASP's text. The sender-constrained token standards come from the IETF (RFC 8705 for mTLS, RFC 9449 for DPoP), not from OWASP. The code uses PyJWT and was run to produce the output shown.
Who this is for: anyone building an AI agent that can do things, not just answer. You will learn the ten agent risks in plain words, how they differ from each other, and three controls you can put in code today: bound tokens, untrusted agent output, and a check right before every action.

1Why agents need their own list

An agent acts, so its mistakes have consequences.

A chatbot that gives a wrong answer is embarrassing. An agent that takes a wrong action can cost money, leak data or message the wrong people. An agent reads untrusted text, decides what to do, and calls tools with real permissions. Each of those steps is a place an attacker can push.

Where an agent can be pushed
Reads inputmessages, documents, web pages
→
Decidesplans, remembers, delegates
→
Actscalls tools with real access

OWASP's agentic list builds on two ideas. Least agency: give an agent only the autonomy and tools its job needs, because every extra capability is attack surface. Strong observability: record what the agent did, with which tool and on whose behalf, so you can see a problem and stop it.

The rule under all ten risks: put the limits in code and on the server, not in the prompt. A model can be persuaded. A server-side check can't.

2ASI01 to ASI05

Hijack, misuse, privilege, supply chain, code execution.

The examples use a small booking assistant for a service business, which keeps them concrete. The mitigations are my summary of OWASP's guidance.

ASI01 Agent goal hijack. Hidden or injected instructions change what the agent is trying to do.
Example: A review page the agent reads contains a hidden line telling it to cancel tomorrow's bookings.
Not the same as: ASI06, where bad content is stored and causes harm later. Goal hijack changes the objective now.

  • Treat every message, document and retrieved page as untrusted input
  • Require human approval for actions that change the agent's goal
  • Keep system prompts under change control, not editable at runtime

ASI02 Tool misuse and exploitation. The agent uses a tool it is allowed to use, but in a harmful way.
Example: The agent has a tool for sending reminders and is talked into messaging every client a promotional link.
Not the same as: ASI03. Here the access is legitimate and the use is wrong. In ASI03 the access itself should not exist.

  • Scope each tool: limits on targets, rate and network access
  • Check every tool call against policy before it runs
  • Ask for approval before destructive or bulk actions

ASI03 Identity and privilege abuse. The agent acts with more access than it should have, often borrowed or left over from someone else.
Example: The assistant runs with the owner's admin login, so a client chat can reach other clients' history.
Not the same as: ASI02, where the access is legitimate. This one is about access that shouldn't be there.

  • Give the agent its own identity with short-lived, task-scoped credentials
  • Re-check permission for each sensitive action, not once per session
  • Watch for permissions passed along a chain of delegations

ASI04 Agentic supply chain. A tool, plug-in, prompt, model or other agent you depend on is malicious or tampered with.
Example: An update to a third-party calendar plug-in quietly copies booking details elsewhere.
Not the same as: ASI05, where the agent's own output turns into code. Here the component itself is bad.

  • Pin and verify the versions of tools, prompts and configs you load
  • Allowlist dependencies and keep an inventory of them
  • Keep a switch that disables a compromised component fast

ASI05 Unexpected code execution. Text the agent produces or receives ends up running as code.
Example: The agent writes a small script to total the day's sales, and a client name containing code gets executed with it.
Not the same as: ASI02, where a tool is used as designed. Here arbitrary code runs.

  • Never pass model output to eval-style execution
  • Run generated code in a sandbox with no network and no root
  • Review or approve code before it runs anywhere that matters

3ASI06 to ASI10

Memory, messages, cascades, human trust, rogue agents.

ASI06 Memory and context poisoning. False or harmful content gets into the agent's memory or knowledge and shapes later decisions.
Example: The assistant stores "prefers Rahul" because it misread its own question as the client's wish (card 5 below).
Not the same as: ASI01, which acts immediately. Poisoned memory waits and misleads every future conversation.

  • Record where every memory came from, and segment memory by user
  • Expire or quarantine entries nobody has verified
  • Never feed the agent's own output back into trusted memory automatically

ASI07 Insecure inter-agent communication. Messages between agents are forged, altered or replayed.
Example: A forged "slot is free" message, claiming to come from the scheduling agent, makes the booking agent double-book a stylist.
Not the same as: ASI04, which is about the components. This is about messages moving between them.

  • Authenticate both sides and sign every message
  • Reject replays with one-time ids and timestamps
  • Fix the protocol version so it can't be downgraded

ASI08 Cascading failures. One error spreads through connected agents and tools and grows.
Example: A wrong price in one step is copied into two hundred reminder messages before anyone notices.
Not the same as: ASI10, a misbehaving agent. Here every part works as designed; the error simply travels.

  • Cap how far one run can reach: quotas, step limits, circuit breakers
  • Keep planning and execution separate, with a policy check between them
  • Add a human checkpoint before high-impact output spreads

ASI09 Human-agent trust exploitation. People approve harmful actions because the agent sounds confident or helpful.
Example: The owner approves "refund all of today's bookings" because the agent's explanation sounded reasonable.
Not the same as: ASI01, which fools the agent. This fools the human who approves it.

  • Require explicit confirmation for sensitive actions
  • Show a plain summary of what will happen, not just the model's reasoning
  • Flag low-confidence or unverified recommendations clearly

ASI10 Rogue agents. An agent drifts from its intended behaviour, even when each single action looks acceptable.
Example: An agent told to fill empty slots keeps messaging clients past their consent limits, one reasonable-looking message at a time.
Not the same as: ASI08, an honest error spreading. Here the agent's behaviour itself has gone wrong.

  • Keep tamper-proof logs of actions, tool calls and messages
  • Watch behaviour over time, not only single actions
  • Be able to cut credentials and stop the agent at once

4Bind tokens to who, what, where and how long

A signed token, checked on the server, arguments included.

A token is a signed note the server can verify: who the agent acts for, what it may do, where, and until when. OWASP recommends short-lived, narrowly scoped credentials bound to subject, audience, purpose and session. For one booking, the claims could look like this:

ClaimMeaning
subWho the agent acts for (the client)
roleWhat kind of user that is
audWhich service may accept the token
toolsWhich tools this token unlocks
purpose, sidWhy it was issued, and in which session
expA short expiry, in minutes
jtiA one-time id, so a replayed token is refused

The server checks the signature, audience, expiry, replay, that the tool is allowed, and that the call's arguments match the token. Arguments matter most: a valid token for one client must not book for another.

Python
import time, uuid, jwt

KEY = "demo-only-secret-change-me-0123456789"   # demo only: real systems sign with a private key the agent never holds (RS256 or ES256)

def issue(client_id, tools, ttl=300):
    now = int(time.time())
    claims = {"sub": client_id, "role": "client", "aud": "booking-api",
              "tools": tools, "purpose": "book_appointment", "sid": "sess-41",
              "iat": now, "exp": now + ttl, "jti": str(uuid.uuid4())}
    return jwt.encode(claims, KEY, algorithm="HS256")

used_ids = set()   # in production: a shared store, kept until each token expires

def check(token, tool, args):
    try:
        c = jwt.decode(token, KEY, algorithms=["HS256"], audience="booking-api",
                       options={"require": ["sub", "aud", "exp", "jti"]})
    except jwt.InvalidTokenError as e:
        return f"refused: {type(e).__name__}"
    if c["jti"] in used_ids:
        return "refused: token already used"
    if tool not in c["tools"]:
        return f"refused: {tool} not allowed"
    if args.get("client_id") != c["sub"]:
        return "refused: arguments don't match the token"
    used_ids.add(c["jti"])
    return "allowed"

t = issue("client-17", ["create_booking"])
print("own booking:     ", check(t, "create_booking", {"client_id": "client-17"}))
print("same token again:", check(t, "create_booking", {"client_id": "client-17"}))
print("other client:    ", check(issue("client-17", ["create_booking"]), "create_booking", {"client_id": "client-22"}))
print("tool not granted:", check(issue("client-17", ["create_booking"]), "cancel_booking", {"client_id": "client-17"}))
print("expired token:   ", check(issue("client-17", ["create_booking"], ttl=-1), "create_booking", {"client_id": "client-17"}))
Output (run to check)
own booking:      allowed
same token again: refused: token already used
other client:     refused: arguments don't match the token
tool not granted: refused: cancel_booking not allowed
expired token:    refused: ExpiredSignatureError
A token alone can be stolen and reused until it expires. Sender-constrained tokens bind it to a key only the rightful caller holds: mutual TLS (RFC 8705) or DPoP (RFC 9449). Use them where a stolen token would do real harm.

5Agent output is not trusted memory

The "prefers Rahul" failure, and the rule that fixes it.

Here is a failure that is easy to build by accident. The assistant asks a question, a nightly job extracts preferences, and a check makes sure every stored preference quotes the chat.

How "prefers Rahul" gets stored
Agent asks"Shall I book you with Rahul again?"
→
Client"Yes please, Saturday 11"
→
Extractorstores "prefers Rahul"
→
Quote checkpasses: the words are in the chat

The quote check passed because the words were in the chat. The agent wrote them. The client agreed to one booking, not to a preference, and later said "anyone is fine". The fix is to accept only quotes the client wrote:

Python
chat = [("agent",  "Shall I book you with Rahul again?"),
        ("client", "Yes please, Saturday 11"),
        ("agent",  "Done. Shall I note Rahul as your preferred stylist?"),
        ("client", "No, anyone is fine")]

def naive_check(quote):                      # passes if the words appear anywhere in the chat
    return any(quote in text for _, text in chat)

def client_words_only(quote):                # passes only if the client wrote those words
    return any(quote in text for role, text in chat if role == "client")

claim = {"fact": "prefers Rahul", "quote": "book you with Rahul again"}
print("naive check:      ", "stored" if naive_check(claim["quote"]) else "rejected")
print("client words only:", "stored" if client_words_only(claim["quote"]) else "rejected (agent wrote it)")
Output (run to check)
naive check:       stored
client words only: rejected (agent wrote it)
The rule: log agent output, but treat it as untrusted. Only text the user wrote, or facts your code computed, become memory. An agent's statement becomes trusted only when the user confirms that statement itself, as in "Shall I note Rahul as your preferred stylist?" followed by a yes.

6Check again right before acting

The time-of-check to time-of-use gap.

Permission checked at the start of a task can be stale by the time the agent acts. A client cancels their account, consent is withdrawn, or a slot is taken while the agent is still talking. Security engineers call this the time-of-check to time-of-use gap, and OWASP lists it under ASI03.

Close the gap
Check at startconsent: yes
→
Ten minutes of chatconsent withdrawn meanwhile
→
Re-check before actingconsent: no, so stop

Re-run the permission and state checks inside the same server call that performs the action, as close to it as possible, ideally in the same database transaction. A check done earlier in the conversation is a hint, not a guarantee.

7One-page checklist

Each risk mapped to a control.

RiskControl to put in code
ASI01 Goal hijackTreat all input as data; human approval for goal-changing actions
ASI02 Tool misusePolicy check on every tool call; rate and target limits
ASI03 Privilege abuseShort-lived bound tokens; arguments checked against the token; re-check at action time
ASI04 Supply chainPinned, verified components; inventory; kill switch
ASI05 Code executionNo eval of model output; sandbox with no network or root
ASI06 Memory poisoningProvenance on every memory; agent output untrusted; user confirmation to promote
ASI07 Inter-agent messagesMutual authentication, signed messages, one-time ids
ASI08 Cascading failuresQuotas, step limits, circuit breakers, human checkpoint
ASI09 Trust exploitationExplicit confirmation with a plain summary of the effect
ASI10 Rogue agentsTamper-proof logs, behaviour monitoring, fast revocation

8Check yourself

Short questions, a try-it and one line to remember.

What is least agency?

Giving an agent only the autonomy and tools its job needs, because every extra capability is attack surface.

How does tool misuse differ from privilege abuse?

Tool misuse is a legitimate permission used harmfully. Privilege abuse is access the agent should never have had.

Why did the "prefers Rahul" quote check pass?

The quote was in the chat, but the agent wrote it. The check has to accept only the client's own words.

Which token check stops an agent booking for the wrong client?

Comparing the call's arguments with the token's sub claim.

What is the time-of-check to time-of-use gap?

Permission checked early can be stale by the time the action runs, so re-check right before acting.

Try it: in the token snippet, add a cancel_booking tool to the token and check that cancelling another client's booking is still refused. Then add a client turn saying "I prefer Rahul" to the memory snippet and confirm the claim is now stored.
One line to remember: "The prompt can ask. Only the server can refuse."
Sources: OWASP Top 10 for Agentic Applications for 2026, OWASP GenAI Security Project, 9 December 2025, CC BY-SA 4.0 (paraphrased; this page is shared under the same licence); IETF RFC 8705 and RFC 9449; PyJWT 2.15. Checked 17 November 2026. Independent notes, not affiliated with or endorsed by any company or course named here. Examples and wording are my own.