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/tokenendpoint with grant typeurn:ietf:params:oauth:grant-type:token-exchange, or theGetDerivedTokenAPI. - Two modes. Delegation and impersonation, each enabled per app client with its own flag:
ALLOW_TOKEN_EXCHANGE_DELEGATIONandALLOW_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 anactclaim. - 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 typeTOKEN_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)
- Separate app clients. Give each agent or intermediary its own app client rather than sharing one, so that
act.client_idis meaningful in logs. - Allow-list actors. In the resource server, keep an explicit list of acceptable
act.client_idvalues and reject anything else, including tokens with noactclaim where you expect delegation. - Pin audience. Request a specific
audienceon every exchange and reject tokens whoseauddoes not equal your service. - 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.
- Log both identities. Write
subandactinto your access logs so a review can answer “which user, via which service”. - 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
GetDerivedTokenourselves. - 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.