Stack Builders logo
Stack Builders team
Stack Builders team
Nov-16-2026
Nov-16-2026
9 min read
Subscribe to blog
Email
A prompt injection demonstration from our Quito Lambda session reveals why AI agents need task-specific permissions. Learn how short-lived authorization tokens, scoped access, and server-side controls can prevent unauthorized actions, even when an agent follows malicious instructions.

An AI agent moves an incident from Open to Investigating, exactly as requested. Then it closes two unrelated incidents because a note inside the ticket told it to.

The requested task succeeded. The authorization design failed.

That scenario was at the center of our September 30th Quito Lambda session, Identity for agents: Authorization in the era of Agentic AI. Jonathan Puglla, a software engineer at Stack Builders, used a local incident-management demonstration to explore a practical question: how do we let an agent act on our behalf without giving it authority over everything we can access?

The useful distinction emerged when the demonstration ran again with narrower permissions. The agent still attempted the additional changes. This time, the server denied them.

For teams designing AI agent authorization, that is a concrete place to start: define what the task permits, then enforce that boundary outside the model.

The gap between signing in and authorizing a task

Authentication establishes who is making a request. Authorization determines what that identity may do.

With an agent, there are several identities to account for: the person requesting work, the application coordinating it, and the agent performing it. Treating every request as simply “the user did this” loses information about how an action happened and which authority it should carry.

Consider someone asking an agent to investigate one incident. That person might have permission to close every incident in the system. Their current request does not require the agent to inherit that entire capability.

The distinction matters because agents consume content while working. A ticket description, email, or document may contain text that tries to redirect their behavior. If the agent follows those instructions, the permissions available at execution time determine how much it can change.

The session connected this to the confused deputy problem: a component with legitimate authority is induced to use that authority for someone else's purpose. Here, the ticket supplies the misleading instructions, and the agent brings the credentials needed to act on them.

The idea is older than AI. In a 1988 paper, Norm Hardy described a compiler that could write to files in its own directory, which also held the billing file. A user named the billing file as the place to save debugging output, and the compiler overwrote it using its own authority. Prompt injection has the same shape: the agent is the deputy, and a ticket or email supplies the misleading instruction. OWASP lists related risks in its Top 10 for Agentic Applications 2026, including Agent Goal Hijack (ASI01) and Identity & Privilege Abuse (ASI03).

One legitimate request and two unwanted changes

The demonstration began with a user, Alice, asking an agent to change the status of incident 1042, which described a database refusing new connections. The intended operation was straightforward: move that incident from Open to Investigating.

Inside its description was an additional note addressed to autonomous assistants. It claimed that incidents 1 and 7 were duplicates and instructed the agent to close them immediately.

That note was the prompt injection. It arrived as content the agent needed to read, then attempted to become an instruction governing what the agent should do.

In the first run, the application accepted a static API key with unrestricted permissions in the demo. The agent read incident 1042, made the requested update, and continued with the injected instructions. It closed incident 1, concerning a payment gateway timeout, and incident 7, concerning a data export problem.

All three updates were accepted. Checking only whether incident 1042 reached Investigating would have missed the failure.

This was a local teaching demonstration, not a production design. The application and authorization flow were simulated, but the token was a real JSON Web Token (JWT) created with the jose library. The demo does not measure how often prompt injection succeeds across models.

Make the delegation specific enough to enforce

For the second run, the application issued a short-lived token carrying information about the user, application, acting agent, and permitted work. Alice signed in to the incident app, which asked an authorization endpoint for a token covering only this task. A redirect returned a code, and the app exchanged it for the token. The endpoint was a local mock, but a provider such as Okta or Microsoft could play that role. Its lifetime was five minutes, and its authority was restricted to reading and updating the status of incident 1042. This matches the guidance in the OAuth Token Exchange standard (RFC 8693, section 5) to limit delegated rights with a narrow scope and a short lifetime.

On the server, an authorization check compared the incident being accessed with the incident permitted by the token. Requests outside that boundary were rejected and logged. The check ran in the server's own code, outside the model, so it did not depend on the agent following instructions.

The agent updated incident 1042 successfully. When it attempted the injected changes to incidents 1 and 7, the server returned HTTP 403 responses. Incident 1 remained Investigating; incident 7 remained Open. Side by side, the two runs looked like this:

API Key Run Token Run
User Unknown Alice
Application Unknown The incident app (orchestrator)
Agent Unknown The acting agent
Permissions Anything Read and update status incident on 1042 only
Expiry Never 5 minutes
Audit Can’t tell who or which agent acted Two denials (403), logged

The agent still tried to follow the injected instructions. The server stopped those attempts from changing unrelated records.

An API key can expire and can be limited to read or write, but it cannot say who asked, through which application, via which agent, or for which single incident. The token can. The decisive property was the server's enforcement of narrower authority. A token containing a restriction is useful only when the receiving service validates it and applies that restriction to the requested operation.

Separate the user from the acting agent

The demo's token included sub for the person, client_id for the application, act for the acting agent, and authorization_details describing the permitted work. Keeping these concepts separate makes delegation easier to inspect: whose authority is involved, which application is using it, and which actor operated.

As additional standards context beyond the session, OAuth 2.0 Token Exchange already describes delegation and an act claim for identifying the acting party. OAuth 2.0 Rich Authorization Requests defines authorization_details for carrying fine-grained authorization data in OAuth messages. These provide building blocks; they do not make the demo a complete agent authorization standard.

Applications still need to define what a permitted operation means. Permission to update a ticket's status, for example, may be broader than permission to make one particular transition. The demonstrated boundary isolated a ticket; teams applying the pattern should also decide which transitions are allowed within it. For example, a team might allow a move from Open to Investigating but require human approval to move a ticket to Closed.

An agent identifier is also only as useful as the trusted process establishing it. A name supplied by an agent cannot, on its own, prove that agent's identity. In RFC 8693, the authorization server validates the actor's token before it issues a token naming that actor, so the claim is trustworthy because the issuer vouches for it, not because the agent says so.

Where MCP authorization fits

The session also discussed the Model Context Protocol, or MCP, which lets AI applications connect to tools and data sources. Connecting to a protected tool and restricting the task it can perform are related engineering responsibilities. As the session framed it, MCP connects an agent to tools, while delegation adds on whose behalf the agent acts and for what purpose.

For context beyond the demonstration, the MCP authorization specification defines an OAuth-based authorization flow for HTTP transports. It includes requirements for token audience validation and privilege restriction. For example, MCP clients must tell the authorization server which MCP server a token is for, and each MCP server must reject tokens that were not issued for it.

Those foundations do not automatically encode the meaning of Alice's request. The application must still translate the task into enforceable permissions, and the protected service must check each operation against them.

In this example, permission to connect to the incident service would have been too broad. The useful boundary was permission to operate on incident 1042.

Test the actions that should fail

During the demonstration, Jonathan asked the room what looked odd about the result. The audience's answer was the central limitation: the scoped token had not removed prompt injection; it had blocked the unauthorized consequences shown in the example. In the Q&A, an attendee asked whether injection can be blocked directly, or whether a restriction might be missed in a large system. Jonathan's answer was that no complete solution exists today.

That observation suggests a practical approach to AI agent security testing:

  • Define the permitted resource, operations, and lifetime before execution.
  • Put misleading instructions in content the agent must read, then check the attempted tool calls.
  • Verify that unrelated resources remain unchanged, even when the requested task succeeds.
  • Preserve enough audit context to connect allowed and denied requests to the user, application, and agent.

These are recommendations based on the demo, not tests run during the session. They also leave an important residual risk: an agent can still make a harmful choice within its authorized scope. Narrow delegation reduces the reach of a mistake; sensitive actions may require additional validation or human approval. Identity providers offer standard mechanisms for this, such as step-up authentication (RFC 9470), which asks for a stronger or more recent sign-in, and Client-Initiated Backchannel Authentication (CIBA), which can ask a person to approve a request on a separate device.

Start with one bounded workflow. Specify what it may change, decide what must remain untouched, and test both outcomes. The incident demo shows why a denied request can be as meaningful as a successful one.

Watch the Quito Lambda recording (in Spanish) for the walkthrough. For a related perspective on defining scope and validating AI-assisted work, explore our article on modernizing legacy software with spec-driven development.

Subscribe to blog
Email