Cloud Security Wire
AWS Azure GCP RSS
AWS Hardening Guide low

Amazon Cognito Token Exchange for AI Agents: Delegation vs Impersonation and What Resource Servers Must Check

AWS added RFC 8693 token exchange to Amazon Cognito on 24 November 2026. What AWS says it does, why delegation (with an act claim) is the safer choice for agents, and untested hardening suggestions for resource servers.

By Cloud Security Wire · ·
#AWS#Amazon Cognito#OAuth 2.0#RFC 8693#token exchange#AI agents#MCP#AgentCore#least privilege

On 24 November 2026 the AWS Security Blog published “Delegate user access to AI agents with Amazon Cognito token exchange”. It describes support in Amazon Cognito for OAuth 2.0 token exchange (RFC 8693), so a service can swap a user’s access token for a new token that is narrower and is meant for a specific downstream audience. This is a product announcement, not a vulnerability report. We summarise what AWS says, then add suggestions of our own. Our suggestions are labelled and have not been tested in a live account.

The problem

When an AI agent or MCP server acts for a signed-in user, the simplest design forwards the user’s token. That hands the downstream service a token with the user’s full scopes, and it hides which service really made the call. Per AWS, the MCP authorization specification does not allow a server to pass through the token it received (we did not open the specification ourselves), so the agent needs another way to get credentials for the next hop. Token exchange is that mechanism.

What AWS says Cognito does

  • Two entry points. The /oauth2/token endpoint with grant type urn:ietf:params:oauth:grant-type:token-exchange, or the GetDerivedToken API.
  • Two modes. Delegation and impersonation, each enabled per app client with its own flag: ALLOW_TOKEN_EXCHANGE_DELEGATION and ALLOW_TOKEN_EXCHANGE_IMPERSONATION.
  • Delegation adds an act (actor) claim, identifying the party acting for the user, taken from an actor token. Impersonation issues a token without an act claim.
  • Validation and limits. Cognito validates the subject token’s signature, expiry and revocation status. Scopes can only be narrowed. The issued token does not outlive the subject token, and no refresh token is returned.
  • Pre token generation trigger. A Lambda trigger fires with the trigger source TokenGeneration_TokenExchange. AWS says it can remove scopes but cannot add them.
  • AgentCore Identity. AWS shows a credential provider configured with onBehalfOfTokenExchangeConfig, grant type TOKEN_EXCHANGE, and machine-to-machine actor token content.

Why the act claim matters

AWS says an impersonated token represents the user: its client_id claim identifies the app client that performed the exchange, but it has no act claim. So the downstream service can still see which app client exchanged the token, but the token does not carry a separate actor. With delegation, the resource server sees both who the user is (sub) and who is acting (act). In AWS’s shared-intermediary pattern the act claim names the intermediary (an MCP server or AgentCore Gateway), not each individual agent. In AWS’s second example the agent requests the exchange itself, so act names the agent, and AWS pairs this with per-agent app clients.

Our assessment: for AI agents, enable only delegation on the app clients that agents use, because an explicit actor in the token is easier to audit than inferring it from client_id. Turn the impersonation flag on only where you have a written reason.

What the resource server must check (per AWS)

AWS says the resource server should verify the JWT: signature, issuer, expiry, audience and scopes. For delegated requests it should also validate act: accept the token only when act.client_id identifies a trusted service and matches the token’s client_id. Cognito narrowing scopes does not replace these checks. A resource server that skips the audience or act test can accept a token that was never meant for it.

Hardening suggestions (ours, untested)

  1. Separate app clients. Give each agent or intermediary its own app client rather than sharing one, so that act.client_id is meaningful in logs.
  2. Allow-list actors. In the resource server, keep an explicit list of acceptable act.client_id values and reject anything else, including tokens with no act claim where you expect delegation.
  3. Pin audience. Request a specific audience on every exchange and reject tokens whose aud does not equal your service.
  4. Use the trigger defensively. Use the pre token generation trigger to remove scopes the downstream service does not need, for example write scopes for a read-only tool. Remember it can only remove.
  5. Log both identities. Write sub and act into your access logs so a review can answer “which user, via which service”.
  6. Keep subject tokens short-lived. Since the exchanged token cannot outlive its subject token, the subject token’s lifetime is the ceiling for every derived token.

What we could not confirm

  • We have not tested token exchange, the Lambda trigger or GetDerivedToken ourselves.
  • We did not open RFC 8693 or the MCP specification; their content here is as AWS describes it.
  • AWS’s What’s New post (12 November 2026) says the feature is available on the Essentials and Plus plans in all regions where Cognito is available. Pricing and quotas are not covered here; check the AWS documentation.

References

← All Analysis Subscribe via RSS