Why OAuth is not enough for agents (and X.509 is not either)

Part of: Agent Identity

Why OAuth is not enough for agents: it authenticates a client as a user. Agents need a principal you can revoke per session without disabling the human.

Why OAuth is not enough for agents: the flows we actually ship authenticate a person in a browser, or a confidential client with a secret. An unattended agent needs a workload principal you can revoke per session without disabling the human. OAuth can carry that principal, but it does not create it by default.

An agent on a WorkerPool is not in a browser. If you give it the user’s refresh token, the snapshot is now the user. If you give it a client secret, every actor that restores that image has the client. If you run a device-code flow and leave it unattended, you have built a token printer.

I still use OAuth pieces. I do not use OAuth as the agent’s name.

Why is OAuth not enough for agent identity?

Typical OAuth puts a user in front of a client and issues tokens that represent the user. An unattended agent is not that client.

If the token is the user’s, revoke means disabling the user. After the gym-class booking, the audit log says alice. You disable alice. The agent is still in the pool, and alice cannot log in. That is the wrong blast radius.

If the token is a long-lived client credential, it is a secret in a snapshot. Agent Substrate checkpoints memory and filesystem to object storage. A checkpoint is a copy. Copies leak. Agent checkpoint to object storage. Secretless AI agents exists because a better secret store still leaves the plaintext in the process.

The LiteLLM compromise harvested environment variables, .env files, cloud credentials, Kubernetes configs, and SSH keys. That list is where OAuth client secrets live in a normal agent deployment. Moving the secret to Vault changes where it rests, not where it is exposed.

Proof of agent identity is the evidence requirement: which agent, which session, on whose behalf. sub=alice answers a different question.

What does OAuth still get right for agents?

Delegation. A human can grant a narrower access to a client. Token exchange can swap one audience for another. RFC 8707 resource indicators bind the issued token to one backend. RFC 8693 is the exchange. Those are the right primitives.

MCP’s Enterprise-Managed Authorization authenticates the employee through an IdP. The client logs the user in, exchanges the ID token for an ID-JAG, then presents the ID-JAG to the MCP authorization server for an access token. The IdP evaluates group membership at the exchange step, so access is grantable and revocable from one admin console. I documented what has actually shipped in the MCP agent identity gap. The wire trace is in the Cross App Access write-up.

For a developer running an MCP client on a laptop, a browser redirect is exactly right. For an agent running unattended in a namespace at 3 AM, there is no browser and no employee to redirect. The extension was not built for that case and does not claim to be.

Use those flows for the human-to-agent grant. Then stop. The agent still needs its own subject in the token. OAuth without that subject is a user impersonation leak with extra steps.

kagent v0.10.0 can send RFC 8707 resource indicators on its STS exchange. Both variables default to empty. Empty means a token that is good wherever that STS is trusted. Set them. kagent audience-bound tokens.

What does OAuth not give you for an unattended agent?

A subject that is the agent. sub=alice is alice. When alice’s agent books a gym class, the audit log should not say alice unless you meant impersonation. I want agent=gym-bot, act=alice or I cannot do proof of agent identity.

Session lifetime. User tokens last for the SSO policy. Agent turns last seconds. Bind the agent credential to the turn. Restore is the moment to mint. Suspend is the moment to drop. Suspend and resume agents.

Unattended operation. Client credentials OAuth is a stored secret. The MCP draft client-credentials extension is explicit about its prerequisite: pre-registered credentials established out-of-band. Dynamic Client Registration is not used in that flow. Somebody creates a credential and puts it somewhere the agent can read. JWT client authentication is better than a shared secret. It is still a registered client with a key it has to keep.

Attestation of the process. OAuth as usually deployed does not prove which workload is calling. A stolen refresh token works from a laptop. A stolen client secret works from a different pod. SPIFFE SVIDs answer which process. OAuth still has to carry a subject that is the agent, not only the user.

DPoP (SEP-1932) would bind an access token to a key pair the client controls, so a leaked token cannot be replayed by whoever picked it up. Workload Identity Federation (SEP-1933) would let a Kubernetes or SPIFFE JWT stand in for a registered client. Both were opened in December 2025. Both are still open pull requests. Until they land, the proof lives a layer down.

Why is X.509 not a substitute by itself?

Same split. A long-lived cert is a secret. A cert on a pod authenticates the pod. On a WorkerPool that is the worker, shared by every actor that lands in the bay. Nine agents on two workers, later 18 on the same two: one cert, many agents. kagent Agent Substrate.

A SPIFFE SVID is a short-lived cert minted from attestation, which is why SPIFFE for AI agents is on my list. The workload fetches the SVID from the local Workload API rather than from a file. The certificate lives minutes. Renewal is a background stream. There is nothing to copy into the ActorTemplate because nothing was written down. The gateway fails closed at startup if SPIFFE is enabled and no identity can be obtained.

X.509-SVIDs on the handshake are the form SPIFFE recommends when you can use them, because a JWT token can be replayed if it is captured in transit. That is still X.509. It is not a cert file in the image.

If someone says “we cannot use existing OAuth or X.509,” they are usually right about the existing deployments, not about the primitives. Rebuild the issuance. Do not paste a bearer token into the ActorTemplate.

How should you use OAuth and X.509 as plumbing instead of as the agent’s name?

Rebuild issuance around the agent, then use OAuth for the grant and the audience.

  1. Attest the workload. SPIFFE SVID from the Workload API, or a projected SA token with a named audience. Agent identity vs service account. The SA is the bootstrap. The minted token is the agent.
  2. Exchange for a scoped credential. RFC 8693 token exchange. RFC 8707 audience. Destination checks aud itself. Replay against a second backend is 403. Workload identity federation for agents.
  3. Keep the human grant separate. ID-JAG, constrained delegation, lifetime in minutes, logged as “agent A for user U.” Do not copy alice’s cookie into the snapshot.
  4. Drop on suspend. The actor starts empty. One round trip at restore is the cost. A refresh token in object storage is the other cost.

Who gave the agent a badge still applies after the token is right: least privilege, a written approval list, an audit trail the agent cannot edit. Identity is only the first control. Zero trust architecture for AI agents still needs sandbox and egress. A valid OAuth token through an open network is a valid OAuth token through an open network.

What are OAuth best practices for AI agents and MCP servers?

OAuth is still the right grant and audience layer, if you treat it as plumbing and not as the agent’s name. Items 1, 2, 3, 6, and 8 come from the MCP authorization spec (2025-11-25) and the RFCs it relies on. Items 4, 5, and 7 come from the walkthroughs linked below. The list points to those pages rather than repeating them.

  1. Bind every access token to one resource. MCP clients must send the RFC 8707 resource parameter on authorization and token requests. MCP servers must reject a token that was not issued for them. Replay against a second backend should fail. The kagent walkthrough is audience-bound agent tokens.
  2. Validate the token on every request, as an OAuth 2.1 resource server. Invalid or expired tokens get HTTP 401. Always check audience. Do not accept a token issued for a different server, and do not pass a token through to some other API. The MCP spec forbids token passthrough.
  3. Prefer short-lived access tokens. The MCP spec says authorization servers should issue short-lived access tokens, and that for public clients, authorization servers must rotate refresh tokens. A long-lived refresh token or client secret in a snapshot is a secret in a copy.
  4. Use RFC 8693 token exchange when the agent needs a new audience, instead of reusing one token everywhere. The gateway walkthrough is agentgateway token exchange.
  5. Do not put static secrets in client config files, including claude_desktop_config.json. Prefer OAuth over a long-lived key in a file. MCP config file locations. Secretless AI agents.
  6. For the MCP authorization code flow, clients must implement PKCE, using S256 when they can, and must not put access tokens in the query string.
  7. Give the agent its own subject in the token. sub=alice alone is the impersonation problem this page already covers. Use OAuth for the human grant, such as MCP Enterprise-Managed Authorization, then a workload principal for the unattended agent.
  8. Discover the authorization server from protected resource metadata (RFC 9728) rather than hard-coding it. That is how MCP clients are told to find the server.

Checklist

  • No user refresh token in the actor, the image, or the snapshot.
  • No client secret in the ActorTemplate.
  • No long-lived cert file in the agent image.
  • Agent subject is in the token. sub=alice alone is a fail.
  • Audience bound to one backend. Replay elsewhere is 403.
  • Revoke the agent without disabling the human and without deleting the worker SA.
  • MCP EMA used for the employee grant, not as the WorkerPool name.
  • Mint at restore, drop at suspend.

Field guide: Agent Substrate. The identity series: agent identity on Kubernetes.

Frequently asked questions

Why is OAuth not enough for agent identity?

Typical OAuth puts a user in front of a client and issues tokens that represent the user. An unattended agent is not that client. If the token is the user’s, revoke means disabling the user. If the token is a long-lived client credential, it is a secret in a snapshot.

Can agents use OAuth at all?

Yes, as plumbing: token exchange, RFC 8707 audiences, constrained delegation. The agent still needs its own subject in the token. OAuth without that subject is a user impersonation leak with extra steps.

Why not just use X.509 instead of OAuth?

A cert on a pod authenticates the pod. SPIFFE SVIDs are X.509 done as short-lived workload identity, which I do use. A long-lived cert file in the agent image is the same as a long-lived API key.

Does MCP OAuth give the agent its own identity?

Not in the stable extension. Enterprise-Managed Authorization authenticates the employee through an IdP with an ID-JAG grant. The client-credentials draft still wants a stored secret. DPoP and Workload Identity Federation are still open pull requests.

What should I put in the ActorTemplate instead of a bearer token?

Nothing secret. Mint at restore from attestation or from a projected SA token exchange. Drop at suspend. Do not paste a refresh token, a client secret, or a cert file into the template.

OAuth best practices?

For agents and MCP servers: bind each access token to one resource with RFC 8707, validate audience on every request, prefer short-lived access tokens, use RFC 8693 token exchange instead of one token everywhere, keep static secrets out of client config files, and use PKCE on the authorization code flow. OAuth is the grant and the audience layer. It is not, by itself, the agent’s name.

What are OAuth best practices for AI agents?

Treat OAuth as plumbing. Give the agent its own subject in the token, bind the token to one audience, keep lifetimes short, exchange for a new audience when the destination changes, and do not store refresh tokens or client secrets in the image, the snapshot, or files such as claude_desktop_config.json. For MCP, follow the authorization spec: resource indicators, protected resource metadata, PKCE, and no token passthrough.

Disagree or have a war story? Reply on X