8000 [DRAFT] Set and check nonce during authentication sequence. by creechy · Pull Request #840 · unitycatalog/unitycatalog · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

[DRAFT] Set and check nonce during authentication sequence. #840

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

creechy
Copy link
Collaborator
@creechy creechy commented Jan 9, 2025

PR Checklist

  • A description of the changes is added to the description of this PR.
  • If there is a related issue, make sure it is linked to this PR.
  • If you've fixed a bug or added code that should be tested, add tests!
  • If you've added or modified a feature, documentation in docs is updated

Description of changes

This fixes a potential replay attack by setting a nonce value and validating the nonce is returned in the id-token.

@creechy
Copy link
Collaborator Author
creechy commented Jan 9, 2025

@dan1elt0m - proposed enhancement to add nonce validation

@dan1elt0m
Copy link

LGTM

@ognis1205
Copy link
Contributor
ognis1205 commented Jan 9, 2025

If I understand correctly, the nonce is intended to link the client (the relying party in OIDC terms) session with the issued ID token. In this context, where the CLI application functions as the client, and considering that the same CLI application is not executed after the ID Token is issued (meaning there is virtually no opportunity for an attacker to perform a replay attack), it seems that verifying the nonce may not add significant value. Additionally, in OAuth, the nonce is not a required parameter for authorization flows.

I believe the primary concern here may not be a replay attack but rather an authorization code interception, MITM, and CSRF. Would it be more appropriate to consider implementing an authorization flow with PKCE instead of using a nonce? 🤔

@dan1elt0m
Copy link

Nonce provides replay protection and according to Google's openid-connect documentation, the nonce is required for both the server (auth code flow) and the implicit flow. IIRC, in the auth code flow it prevents hackers from injecting their auth response into the redirect URI of the server.

@ognis1205
Copy link
Contributor
ognis1205 commented Jan 10, 2025

The "client" mentioned above was intended to function as a client for the resource server. Strictly speaking, this CLI application (AuthCli) is not a client of the resource server, in other words, the series of processes following this authorization flow, which utilizes an access token, acts as the client to the resource server; however, since the nonce lifespan aligns with the session of AuthCli, I referred to it as a client. I understand that the nonce is associated with the client session to prevent replay attacks, but I believe it is highly unlikely for a malicious user to launch a replay attack on AuthCli. For similar reasons, I believe that validating the state value (which does not appear to be implemented in the current setup) may not be particularly meaningful here.

Although I am uncertain about the rationale behind Google's documentation specifying nonce as required, the OIDC specifications referenced in the same documentation appear to indicate that nonce is optional in the authorization code flow. In this CLI application case, PKCE + state seems to provide sufficient security. That said, I do not have a strong objection to this draft.

Reference

@creechy
Copy link
Collaborator Author
creechy commented Jan 10, 2025

@ognis1205 @dan1elt0m I can see both your points. I don't think there is any particular not to do this, however optional and unlikely a replay attack could be.

@ognis1205
Copy link
Contributor
ognis1205 commented Jan 20, 2025

As mentioned in the comment here, if we continue using the current implementation of the Authorization Code Flow in AuthCli, I believe credentials such as tokens should also be handled via the back channel.

However, if we replace it with the Authorization Code Flow with PKCE (PKCE Flow) and remove the client_secret from the request, the CLI could be considered a public native application, which would conform to standard security implementations (Even in this case, I think it would be necessary to introduce a separate property rather than reusing the server property).

That said, in Google's OIDC implementation, the client_secret seems to be treated as a required field, even if it is PKCE Flow, so the ideal approach would be to switch to the PKCE Flow while clearly documenting this point.

Additionally, since the UI implementation for both Google and Okta clients is equivalent to the Authorization Code Flow with PKCE, adopting this approach would enhance consistency across the system as a whole.

Google OIDC Configuration Enpoint
Google OIDC Documentation
Google OAuth2.0 Token Exchange Apigee

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
0