View a markdown version of this page

Understand session binding - AWS Identity and Access Management

Understand session binding

Note

This is prerelease documentation for a service in preview release. It is subject to change.

Session binding is a security step that is unique to the brokered authorization code grant. It confirms that the identity that completes the consent is the same identity that started the flow. This topic explains why the step exists and what your application must implement.

Why session binding exists

In a browser-based OAuth flow, a browser starts the flow, and standard protections such as PKCE and the state parameter bind the authorization code to that browser. In the brokered flow, a server-side API call starts the flow instead of a browser. Because no initiating browser session exists at the broker, PKCE and the state parameter alone cannot bind the code to the consenting person.

Without an additional check, an attacker could start a flow, send the resulting authorization URL to a victim, and have the victim consent. The attacker would then receive a token that represents the victim. This is a confused-deputy attack, where a trusted component is tricked into acting for the wrong identity. For background on confused-deputy attacks, see The confused deputy problem.

Session binding closes this gap. It reconciles the identity that started the flow with the identity that completes it. Credential Broker carries the identity that completes the flow in your application's own login session, through the redirect to your session binding URL. If the two identities do not match, Credential Broker denies the request and discards the token.

What you must implement

To use the authorization code grant safely, implement a handler for your session binding URL. This handler receives the browser after the broker processes the identity provider's callback. In this handler, do the following:

  • Require that the request runs behind your application's own authenticated login session, so that the request carries the same end-user identity that started the flow.

  • Call CompleteOAuthSessionBinding with the session handle, over a session that carries that end-user identity.

  • Validate the custom state value that you passed when you started the flow, to protect against cross-site request forgery.

Use only a session binding URL that is in the allowed list on the credential provider. Credential Broker rejects any other URL. For more information, see Complete setup for the authorization code grant.