Please document optional OAuth 2.0 authorization flow parameter "nonce"

Imagine the following attack for the OAuth 2.0 authorization flow:

  1. Attacker steals the authorization code from the redirect URI.
  2. Attacker forces his instance of the client to redeem the victim’s authorization code.
  3. If the attacker’s instance of the client is faster than the victim’s instance of the client in redeeming the authorization code, the attacker will get a valid login session within his instance of the client, but for the victim’s account.

This attack should especially get attention in the context of Twitch and live streaming, since many streamers are definitely not aware of this vulnerability: If people are logging in with Twitch on 3rd party sites while live streaming, an attacker that has automated this attacking process (e.g. by capturing the stream) can easily grab the authorization code from the visible browser address bar during the streamer’s login attempt, except …

… the OAuth 2.0 PKCE extension is used by the client, which prevents the attack in the following way:

  1. A hashed secret (using a cryptographic hash function) is send using the nonce parameter of the initial authorization request (leading to the Twitch login page).
  2. Later, the authorization server (that is used to redeem authorization codes) is sending back the same nonce together with the access token.

The back end implementation (that also securely stores the client secret and makes the call to this authorization server) can now verify whether the nonce sent back from the authorization server is indeed the hashed value of the specific secret.
An attacker that does not know the secret should now longer be able to force the back end to authorize him with the victim’s permissions.
Of course, the secret is bound to the authentication session and only visible to an attacker in its hashed form (the nonce) within the initial authentication request.

A few months ago someone suggested to support the OAuth 2.0 authroization flow PKCE extension.
I don’t know if the nonce usage above is exactly the same as PKCE, but it at least prevents attack scenarios like the one that I just described.

Currently, the documentation does not mention this nonce parameter being available for the OAuth 2.0 authorization flow. It should be added with a short description, similar to the other optional parameters like state or force_verify to make people aware of it.

You might wanna throw this on the UserVoice instead

1 Like

Thanks, I thought something like that was only available for front end (not developer) features.
Will do. Might still be helpful for some devs currently not aware of this attack who are trying to achieve maximum security for their services.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.