-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
OAuth2: add a nonce to the state parameter #35919
Conversation
Signed-off-by: Huabing Zhao <[email protected]>
Signed-off-by: Huabing Zhao <[email protected]>
Signed-off-by: Huabing Zhao <[email protected]>
Signed-off-by: Huabing Zhao <[email protected]>
Signed-off-by: Huabing Zhao <[email protected]>
Signed-off-by: Huabing Zhao <[email protected]>
Signed-off-by: Huabing Zhao <[email protected]>
Signed-off-by: Huabing Zhao <[email protected]>
Signed-off-by: Huabing Zhao <[email protected]>
Signed-off-by: Huabing Zhao <[email protected]>
Signed-off-by: Huabing Zhao <[email protected]>
Signed-off-by: Huabing Zhao <[email protected]>
Signed-off-by: Huabing Zhao <[email protected]>
CC @envoyproxy/api-shepherds: Your approval is needed for changes made to |
Signed-off-by: Huabing Zhao <[email protected]>
Signed-off-by: Huabing Zhao <[email protected]>
Signed-off-by: Huabing Zhao <[email protected]>
Signed-off-by: Huabing Zhao <[email protected]>
Signed-off-by: Huabing Zhao <[email protected]>
Signed-off-by: Huabing Zhao <[email protected]>
Signed-off-by: Huabing Zhao <[email protected]>
Signed-off-by: Huabing Zhao <[email protected]>
Signed-off-by: Huabing Zhao <[email protected]>
Signed-off-by: Huabing Zhao <[email protected]>
Signed-off-by: Huabing Zhao <[email protected]>
Signed-off-by: Huabing Zhao <[email protected]>
Signed-off-by: Huabing Zhao <[email protected]>
@zhaohuabing would you be able to fix the example first? |
@phlax |
hmm - was just looking - i guess my main concern is that the PR lands and breaks both repos not sure if resolution is trivial - ie assuming the nonce is not predictable - might require some hackery on the |
Yes, the nonce is not predictable. But we can change the verification to just check the presence of the state, not the value of the nonce, like what we currently do to the auth code. If this approach is acceptable, I will raise a PR to the example repository to fix the example accordingly. |
could you raise the PR now, so its ready to go? this will also need to be resolved for the fix to work - #35954 |
Signed-off-by: Huabing Zhao <[email protected]>
CC @envoyproxy/dependency-shepherds: Your approval is needed for changes made to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the contribution. A comment is added. I am not familiar to oauth2. So, may be we need to defer this code review to others. Or I need to take more time to read the oauth2 first.
/wait
|
||
// Cookie name to hold the nonce value. Defaults to ``OauthNonce``. | ||
string oauth_nonce = 6 | ||
[(validate.rules).string = {well_known_regex: HTTP_HEADER_NAME ignore_empty: true}]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if there a way to disable this new feature? Or is this has any possible side effect?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Enabling this by default enhances the security posture of the OAuth2 filter. This practice is also recommended by the OAuth2 spec: https://datatracker.ietf.org/doc/html/rfc6819#section-5.3.5. So my preference is that we enable this since this release and don't provide an option to disable it unless there is a particular reason asking for it.
There are no side effects, as the nonce is transparent to both the end users and the applications.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
got it. Thanks.
Signed-off-by: Huabing Zhao <[email protected]>
/lgtm api |
Hi @derekargueta @mattklein123 could you please help review this PR when you have a moment? I noticed that you're listed as owners of the OAuth2 filter in the CODEOWNERS file. Thank you so much for your time and assistance! |
Signed-off-by: Huabing Zhao <[email protected]>
Commit Message: This PR adds a nonce to the state parameter of the oauth2 requests to mitigate the risk of CSRF.
Additional Description:
Risk Level: low
Testing: Unit and Integration test
Docs Changes: API docs: add a new
oauth_nonce
to theOAuth2Credentials.CookieNames
proto API.Release Notes: Yes
Platform Specific Features: No
[Optional Runtime guard:]
[Optional Fixes #Issue] Implement #35232 #29526
[Optional Fixes commit #PR or SHA]
[Optional Deprecated:]
[Optional API Considerations:]
The diagram below shows how nonce works within the oauth2 flow, with the red annotations highlighting the changes introduced in this PR.