Skip to content
All writing

NOTES & IDEAS

An Authenticated AI Agent Can Still Perform an Unauthorized Action

Checking a valid login does not prove that an order cancellation is authorized. Put ownership checks and action approval at the tool boundary.

AI AgentsSecurityAuthorization

An AI assistant can read order history and cancel orders. How should the application prevent it from accessing another customer's order or cancelling something the user never asked to cancel?

My first reply focused on authenticating each request. That is necessary, but it leaves an important gap: a request can come from the right signed-in user and still ask for the wrong action.

The example below is a proposed design for an imaginary order service, not a claim about a system I shipped.

Identity is the beginning

Authentication establishes who is making a request. Authorization decides whether that identity may perform a particular operation on a particular resource.

The OWASP Authorization Cheat Sheet recommends checking permissions on every request, using minimum necessary privileges, and denying access when permission has not been established.

For an order tool, I would separate three questions:

  1. Which authenticated account is using the assistant?
  2. Does that account have permission over this order?
  3. Has this specific cancellation been approved?

A login token can help answer the first question. It cannot, by itself, answer the other two.

Why prompt injection changes the threat

Suppose the assistant reads a delivery note that contains instructions disguised as order data. If that text influences the next tool call, the model might request a cancellation.

The API request could still carry a valid authenticated session. Rejecting anonymous callers would not stop it.

OWASP's prompt-injection guidance describes tool manipulation and recommends validating proposed calls against permissions and session context outside the model.

The delivery note is information about the order. It should not become authority to change the order.

Put the decision next to the action

Here is the boundary I would design:

Authenticated session
  -> Load order within the caller's tenant and ownership scope
  -> Verify the caller may cancel it
  -> Check current order state and business rules
  -> Verify approval bound to this exact cancellation
  -> Apply the change in a transaction
  -> Record the outcome without logging secrets

The model can propose the order identifier and explain what it wants to do. The server must establish the caller's identity from trusted session context and enforce ownership checks. It should not accept a model-supplied owner identifier as proof.

Those choices follow the general principle of server-side authorization in the OWASP authorization guidance.

Bind approval to a concrete operation

In this proposed design, the user sees the exact order and the consequence of cancelling it. The server stores an approval record tied to that user, order, operation, and a short validity period.

At execution time, the tool checks that record. Text generated by the model saying “the user approved” would not satisfy the check. A change to the target order would require a new decision.

This is one illustrative way to implement action-specific approval. OWASP recommends approval for high-risk actions, while treating model output as untrusted at downstream boundaries. See its secure implementation guidance.

Test the boundary

I would test a guessed foreign order ID, an injected delivery note, an expired approval, a changed order target, and a legitimate approved cancellation. These are proposed cases, not test results.

The distinction I want to remember is simple: a trusted login identifies the caller. The tool still has to establish ownership, permission, and intent for the action it is about to take.