Please document optional OAuth 2.0 authorization flow parameter "nonce"
Imagine the following attack for the OAuth 2.0 authorization flow:
- Attacker steals the authorization code from the redirect URI.
- Attacker forces his instance of the client to redeem the victim's authorization code.
- 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:
- 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).
- 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. [1]
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. [2] 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.
This user voice is a clone of this thread in the forum. [3]
[1] https://discuss.dev.twitch.tv/t/pkce-extension-for-oauth-authorization-code-flow/19575
[2] https://dev.twitch.tv/docs/authentication/getting-tokens-oauth#oauth-authorization-code-flow
[3] https://discuss.dev.twitch.tv/t/please-document-optional-oauth-2-0-authorization-flow-parameter-nonce/23357
-
[Deleted User] commented
Twitch is the home of shared live experiences. Developers impact how streamers and viewers experience games, pop culture, and conversations at scale.
https://minimilitiamodapk.com/ -
GenideGaming commented
For anyone reading this, the nonce described in the Oauth standard is not used for PKCE. The nonce is used to prevent replay attacks when using OpenIdConnect. [1]
There is a separate uservoice request for PKCE support. [2]
I highly suggest we go forward with PKCE support as it prevents the described attack method in this post. [3]
Current best practices from IEFT say "Public clients MUST use PKCE" and "For confidential clients, the use of PKCE [RFC7636] is RECOMMENDED". [4]
The attack vector described is also the reason why implicit auth should be deprecated in favor of PKCE Authorization Code Flow. [5][1] https://openid.net/specs/openid-connect-core-1_0.html#CodeFlowSteps
[2] https://twitch.uservoice.com/forums/310213-developers/suggestions/39785686-add-pkce-support-to-the-oauth2-0-authorization-cod
[3] https://datatracker.ietf.org/doc/html/draft-ietf-oauth-security-topics#section-2.1
[4] https://datatracker.ietf.org/doc/html/draft-ietf-oauth-security-topics#section-2.1.1
[5] https://datatracker.ietf.org/doc/html/draft-ietf-oauth-security-topics#section-2.1.2