• 2 Posts
  • 3 Comments
Joined 2 years ago
cake
Cake day: June 6th, 2023

help-circle
  • That’s bad.

    OAuth supports several types of flows. If I’m not mistaken (I’ve learned a bit more about OAuth since yesterday) you’re describing the Authorization Code Flow – as documented in RFC 6749 (The OAuth 2.0 Authorization Framework), Section 4.1 (Authorization Code Grant):

    That RFC defines many other types of flows that do not require sharing the access keys with a third party, such as the Client Credentials Flow, as documented in RFC 6749 Section 4.4 (Client Credentials Grant):

    The only reason you’d want to use the Authorization Code Flow is if the third party needs your access token for some reason, or if you want to hide the access key from the user agent.

    The problem here is that Stripe is using the wrong flow (the third party doesn’t need the access token, as they claim they never save it anyway). And if keyCloak only supports that one flow, that’s would be a problem too (in this case).


  • Upon further reading of RFC 6749, it appears that OAuth does require this – sometimes.

    It depends on the OAuth Flow. In this case, Stripe uses the “Authorization Code” Grant.

    This is documented in Stripe’s OAuth reference documentation here:

    curl https://connect.stripe.com/oauth/token \
      -u sk_test_MgvkTWK1jRG3olSRx9B7Mmxo: \
      -d “code”=”ac_123456789” \
      -d “grant_type”=”authorization_code”
    

    Authorization Code Grants are defined in RFC 6749 (The OAuth 2.0 Authorization Framework), Section 4.1 (Authorization Code Grant):

    To better understand why the OAuth Authorization Code Grant requires sharing the access token with a thrid party server, I found this article (Common OAuth Vulnerabilities) by Doyensec very elucidating:

    It says that the Authorization Code Flow is supposed to be used when you don’t want to share the tokens with the user agent.

    The Authorization Code Flow is one of the most widely used OAuth flows in web applications. Unlike the Implicit Flow, which requests the Access Token directly to the Authorization Server, the Authorization Code Flow introduces an intermediary step. In this process, the User Agent first retrieves an Authorization Code, which the application then exchanges, along with the Client Credentials, for an Access Token. This additional step ensures that only the Client Application has access to the Access Token, preventing the User Agent from ever seeing it.

    But this doesn’t make sense for this use-case. It appears Stripe is needlessly putting us at risk by choosing the Authorization Code Grant.