AI Agent Identity: On Whose Authority Did It Do That?

12 min read
AI Agent Identity: On Whose Authority Did It Do That?

An agent updated a record. Who did that?

The answer we usually find when we look is a service account, which is to say nobody. The agent holds a credential issued to the application, that credential can do everything the application can do, and the audit log records the application. Which user asked, what they were allowed to do, and whether the agent exceeded it are all unrecoverable, and they are exactly the three things anyone investigating will want.

The specifications solved this and named the two options. RFC 8693, the OAuth 2.0 token exchange standard, draws the distinction precisely. Under impersonation, "When principal A impersonates principal B, A is given all the rights that B has within some defined rights context": the agent becomes the user and nothing downstream can tell the difference. Under delegation, "principal A still has its own identity separate from B", acting for the subject rather than as it.

Handing an agent a service account is not even impersonation. It is a third thing: acting as the application, with no reference to the user at all.

The standards already express delegation in the token. RFC 8693 defines an act claim that "provides a means within a JWT to express that delegation has occurred", identifying the party to whom authority has been delegated, and a may_act claim that "makes a statement that one party is authorized to become the actor and act on behalf of another party". Where authority passes through several hands, the actor claims nest: "the outermost act claim represents the current actor while nested act claims represent prior actors."

And a rule that saves a great deal of argument later: for access control decisions, the consumer "MUST only consider the token's top-level claims and the party identified as the current actor". Prior actors in the chain are informational. The agent's authority is the current actor's, not the sum of everyone in the chain.

Three questions decide the design. On whose authority is the agent acting? What is the narrowest set of permissions that authority needs right now? And what does the audit log say when somebody asks six months later? Everything else follows.

How do you give an AI agent permissions?

Not with a service account. Exchange the user's token for a narrower one scoped to the specific resource and action, carried as a delegation rather than an impersonation so the agent keeps its own identity alongside the user's. Request least privilege, step up when a tool demands more, and record both subject and actor in every audit entry.

That is the shape. The rest of this post is what each part costs and where it goes wrong.

What token exchange actually looks like in a request

The mechanism is unglamorous and that is the good news: it is an existing OAuth grant, not a new protocol anyone has to invent.

The agent presents the user's token as the subject token, the thing whose authority is being passed along, and its own credential as the actor token, which RFC 8693 defines as "a security token that represents the identity of the acting party". The type of that actor token is declared alongside it, and the specification is strict in both directions: actor_token_type is REQUIRED when actor_token is present and "MUST NOT be included otherwise".

What comes back is narrower than what went in. A token scoped to one resource, with an act claim naming the agent and the subject still identifying the user. Both names survive, which is the entire point, and it is why the audit section later in this post is possible at all.

A diagram showing a user's authority exchanged into a narrower, resource-bound token carried by a named agent, with the audit entry recording both subject and actor.

Where authority passes through more than one agent, the claims nest, and the rule for reading them is worth memorising because it prevents a real class of mistake. "The outermost act claim represents the current actor while nested act claims represent prior actors," and for an access control decision the consumer "MUST only consider the token's top-level claims and the party identified as the current actor". A chain of three agents does not accumulate the permissions of all three. Prior actors are history, not authority.

There is a complementary claim for the other direction. may_act "makes a statement that one party is authorized to become the actor and act on behalf of another party", which lets an authorization server say in advance which agents are permitted to act for a given subject, rather than deciding it at exchange time. For a fleet of agents with different trust levels that is the difference between policy and code.

Scope down, then step up

The instinct is to request everything the agent might need at the start, because a mid-task authorisation failure is annoying. It is the wrong instinct and the Model Context Protocol specification says so in its own language.

Ask for the minimum, then let the server tell you what else it wants. The spec directs servers to include a scope parameter in the WWW-Authenticate header of a 401 so clients know what to request, "following the principle of least privilege and preventing clients from requesting excessive permissions". At runtime, a token with insufficient scope gets a 403 Forbidden carrying error="insufficient_scope" and the scopes needed for that operation.

The step-up has one rule that is easy to get wrong. When re-authorising, the client computes the union of what it previously requested and what the current challenge demands. Request only the challenged scope and you drop the permissions the agent was already using, and the next tool call fails for a reason that looks unrelated. The specification is explicit that scope accumulation is the client's responsibility.

There is a user-experience constraint hiding in here too. The spec advises servers to return every scope the current operation needs in a single challenge rather than one at a time, because incremental challenges force multiple authorisation round-trips for one operation. For an agent that means several consent screens in the middle of a task, which is where users abandon.

And a limit worth stating plainly: scopes are coarse. files:write does not mean "this file". Scope restricts the category of action; restricting the instance is the resource server's job, and that is your code, not your identity provider's. An agent authorised to write files can write any file the user can, unless something downstream of the token narrows it.

The confused deputy, named in the specification

The classic failure here is old enough to have a name, and the MCP security requirements list it among the attacks implementations must address, alongside token audience binding, token theft and mix-up.

A confused deputy is a component with more authority than its caller that can be talked into using that authority on the caller's behalf. The problem predates agents by decades and arrives with them in a sharper form, which is also the argument running through securing enterprise AI: the control has to sit outside the model, because the model is the component being confused. An agent is a deputy by construction: it holds credentials, it reads instructions, and the instructions arrive in content it does not control. This is the same mechanism behind prompt injection in agentic systems, seen from the identity side rather than the input side.

The specification's answer is to bind the token to a specific resource, and it is worth reading how hard it insists. MCP clients "MUST implement Resource Indicators for OAuth 2.0 as defined in RFC 8707", the resource parameter "MUST be included in both authorization requests and token requests" and "MUST identify the MCP server that the client intends to use the token with". Clients "MUST send this parameter regardless of whether authorization servers support it".

On the other side, servers "MUST validate that access tokens were issued specifically for them as the intended audience", clients "MUST NOT send tokens to the MCP server other than ones issued by the MCP server's authorization server", and then the line that settles a whole category of design discussion:

"MCP servers MUST NOT accept or transit any other tokens."

No passthrough. A server that takes the token it was given and forwards it to a third service has created exactly the confused deputy the rest of the specification is trying to prevent. If an agent needs to reach two systems, it needs two tokens, each bound to its own audience.

Can an agent act when the user is not there?

Sometimes, and it should be a deliberate decision rather than a side effect of how long a refresh token happens to live. An agent running overnight on a schedule has no user present to approve a step-up, so either the authority was granted in advance for a narrow, named purpose, or the agent stops and waits. Choose which before you build, because retrofitting a pause into a pipeline is harder than designing one in.

The specification treats this carefully. It notes that clients "MUST NOT assume refresh tokens will be issued", since the authorization server retains discretion, and that offline_access is a client concern rather than a resource requirement, which is why servers are told not to advertise it as a required scope. It also separates clients acting for a user, which should attempt a step-up, from clients acting on their own behalf through client credentials, which may simply abort.

Long-lived authority is the real risk in an autonomous agent, and it is not primarily a technical one. A credential granted for a task that was supposed to run for an afternoon, still valid eight months later, held by a process nobody owns any more, is the ordinary way this goes wrong. Expiry is a design parameter; set it against the task rather than against convenience, and the same discipline that governs a model's retirement date applies to a credential's.

Audit is the second half of authorisation

Authorisation decides what may happen. The audit log decides whether anyone can explain what did, and for an agent the ordinary log is not enough.

What an agent's audit entry has to record

  • Record the subject and the actor separately. This is the whole point of delegation surviving into the token: the entry says a named user authorised the action and a named agent performed it. A log that records only one of those answers half the question, and it is usually the half nobody is asking.
  • Record what the agent was told, not only what it did. An action that was correct given a malicious instruction looks identical in a conventional log to an action that was correct given a legitimate one. The retrieved content, the resolved prompt and the tool results are the evidence, which is why tracing for AI systems and authorisation audit end up being the same build rather than two.
  • Record the authority, not just the attempt. Which token, which scopes, which resource, and whether a step-up happened mid-task. When a question arrives about why an agent could do something, the answer is a scope grant, and that grant has to be findable.

This is also the evidence an auditor asks for. If you are working towards a management system standard, the ISO 42001 expectation that human oversight documented in a policy exists as an actual step applies directly: an approval that is not recorded did not happen.

An invitation to discuss identity and authorisation for an AI agent build with the Zyneto team.

A comparison of a service-account agent against a delegated agent, showing what each can answer when an action is questioned.

Does every agent need its own identity?

Yes, if more than one agent can act, and the reason is operational rather than philosophical. Two agents sharing one credential cannot be separated in a log, cannot be revoked independently, and cannot be scoped differently. The first incident makes all three of those urgent at once.

Give each agent a distinct client identity, with its own scopes and its own expiry, and let the user's authority flow through it by delegation. That way the question "which agent did this, acting for whom" has an answer that does not require reading application code, and switching one agent off does not switch the others off with it.

A related case that catches teams out is an agent driving an interface rather than an API. A computer-use agent operating a desktop session inherits whatever that session can reach, and no scope in any token narrows it, because the authorisation happened at login. If that is the architecture, the identity question moves to which session the agent gets, and the answer should not be somebody's own.

The exception is a single-purpose agent inside one application boundary with no autonomous action, where the application's identity genuinely is the actor. That case is real and it is rarer than it looks: the moment a second tool is added, the pairing problem from prompt injection arrives and separate identities start paying for themselves.

What the specification actually requires, and what it leaves to you

Worth being precise, because the requirement levels moved between revisions and people quote the old ones.

Authorization is OPTIONAL for MCP implementations. Where it is supported, HTTP transports should conform to the specification, and implementations using STDIO "SHOULD NOT follow this specification, and instead retrieve credentials from the environment". A local server reading a key from an environment variable is not non-compliant. It is the documented pattern for that transport.

Dynamic client registration has been demoted. It is now a MAY, described as "deprecated and retained for backwards compatibility" with authorization servers that do not support Client ID Metadata Documents, which are now the SHOULD. A codebase written against the earlier guidance is not wrong yet, and will be.

Issuer validation is tightening. Authorization servers SHOULD include the iss parameter in authorization responses per RFC 9207, and the specification says a future revision is expected to upgrade that to MUST, encouraging implementers to emit and validate it now. That is a free piece of forward planning.

And what the specification does not do: it does not decide which user may do what inside your product. Resource indicators bind a token to a server; scopes bind it to a category of action. Everything about which record, which tenant and which field remains your authorisation layer's job, enforced on the server, outside the model, as it was before agents existed. The constraints that apply when adding AI to a product that already has customers apply here with the volume turned up.

An invitation to scope delegated authority and audit for an agent build with the Zyneto team.

What this costs to get right

Less than the alternative, and the alternative is usually discovered during an incident.

The work is an authority model, a token exchange path, per-agent client identities with their own lifecycles, and an audit schema that carries subject, actor, authority and instruction. At our published rates of $40 to $100 an hour by role, blending to $60 to $70 for a mixed team, it is a bounded piece of work on a build that was already going to need an agent of some size around it. It is not a research project.

The expensive version is the retrofit. Adding delegation after an agent is live means touching every call site, re-issuing every credential, and backfilling an audit trail that cannot be backfilled, because the information was never recorded. The records from before the change will always answer "the application did it".

And it compounds with the security review you will have anyway. Much of this evidence is what a customer questionnaire or a SOC 2 engagement asks for, and the same per-agent identities and scope records that satisfy an auditor are what let an engineer answer a support question. Built once, read twice.

What we would build

The identity work first, before the second tool. One tool is an integration; two tools is an authority model, and the cost of adding one later is rewriting every call site.

A distinct client identity per agent, with its own scopes and expiry. Token exchange so the user's authority reaches the agent as delegation rather than as a borrowed login, with the actor claim preserved. Resource-bound tokens, one per audience, and no passthrough anywhere. Least privilege at the start with a working step-up path, including what happens when nobody is there to approve one. And an audit entry that names the subject, the actor, the authority and the instruction.

None of that is novel engineering. It is OAuth, which your team already knows, applied to a caller that reads its instructions from content somebody else wrote. The part that is genuinely new is the last clause, and it is the reason the shortcut is so tempting and so expensive: a service account was always a bad idea, and it becomes an incident the first time the thing holding it can be persuaded.

Frequently asked questions

It is the answer to "on whose authority did the agent do that". An agent is software, not a person, so it needs both its own identity and a way to carry the authority of the user it is acting for. OAuth 2.0 token exchange, RFC 8693, distinguishes impersonation, where the agent is given all the rights of the user and becomes indistinguishable from them, from delegation, where the agent keeps a separate identity while acting for the user.

Because it discards the user. A service account credential can do everything the application can do, regardless of what the requesting user was permitted, and the audit log records the application rather than the person. Three things become unrecoverable: who asked, what they were allowed to do, and whether the agent exceeded it. Those are the first three questions in any investigation, and a shared credential also cannot be revoked or scoped per agent.

RFC 8693 defines both. Under impersonation, the acting party is given all the rights of the party being impersonated within a rights context, and systems downstream cannot tell them apart. Under delegation, the acting party keeps its own identity separate from the subject's and acts for it, which is expressed in a JWT through the `act` claim. For agents, delegation is the one you want, because it preserves both names in the token and therefore in the log.

Least privilege first, then step up. The MCP specification directs servers to advertise required scopes in the `WWW-Authenticate` header of a 401 and to return `403` with `error="insufficient_scope"` plus the scopes needed when a token is too narrow at runtime. The client then re-authorises with the **union** of what it previously held and what the challenge demands, because requesting only the new scope silently drops permissions the agent was already relying on.

No. The specification states that MCP servers "MUST NOT accept or transit any other tokens", that servers must validate tokens were issued specifically for them as the intended audience, and that clients must not send tokens other than those issued by that server's authorization server. Clients must also include the RFC 8707 `resource` parameter in both authorization and token requests, regardless of whether the authorization server supports it. An agent reaching two systems needs two tokens.

Four things, where a conventional log records one. The subject, meaning the user whose authority was used. The actor, meaning which agent performed the action. The authority itself, meaning which token and scopes applied and whether a step-up occurred during the task. And the instruction the agent was acting on, including retrieved content and tool results, because an action taken on a malicious instruction is indistinguishable from a legitimate one unless the instruction is stored.

No. The specification states that authorization is OPTIONAL for MCP implementations. Where it is supported, HTTP-based transports should conform to it, while STDIO implementations should not and should retrieve credentials from the environment instead. Within that, specific requirements are strict: resource indicators are a MUST for clients, audience validation a MUST for servers, and dynamic client registration has been demoted to MAY and described as deprecated in favour of Client ID Metadata Documents.

Vikas Choudhary

Vikas Choudhary

Vikas has around fifteen years of experience building software and now builds generative AI systems at Zyneto. His work covers retrieval augmented generation, agentic AI, knowledge graphs, AI memory, and the evaluation and guardrails that decide whether any of it is safe to put in front of customers. He has shipped enterprise copilots, document AI, chatbots and predictive analytics for e-commerce, fintech and marketing teams, and works day to day in Python, JavaScript and SQL. He follows multimodal models, business process automation and enterprise AI security closely, and mentors engineers moving into AI. He writes about architecture, inference cost and the failure modes that only show up at production scale.

Zyneto builds custom software, AI and automation

Tell us what you are building and we will reply with a clear next step.

Phone

We reply to every enquiry within one business day.

WhatsApp
Email
Book a Meeting