-
-
Notifications
You must be signed in to change notification settings - Fork 367
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
fix: return invalid_grant instead of invalid_request according to rfc6749#section-5.2 #426
Conversation
…oken is not found or does not belong to client.
…ation code flow when the user is not the owner of the authorization code or if the redirect uri doesn't match from the authorization request.
33a819b
to
0714d51
Compare
I opened GitHub to search the fosite source for this bug, and your very timely PR was the first thing I saw 🎉 |
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.
👍
@@ -65,7 +65,7 @@ func (c *RefreshTokenGrantHandler) HandleTokenEndpointRequest(ctx context.Contex | |||
signature := c.RefreshTokenStrategy.RefreshTokenSignature(refresh) | |||
originalRequest, err := c.TokenRevocationStorage.GetRefreshTokenSession(ctx, signature, request.GetSession()) | |||
if errors.Cause(err) == fosite.ErrNotFound { | |||
return errors.WithStack(fosite.ErrInvalidRequest.WithDebug(err.Error())) | |||
return errors.WithStack(fosite.ErrInvalidGrant.WithHint("The refresh token has not been found.")) |
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.
This information must not publicly be disclosed to make token scanning attacks harder:
return errors.WithStack(fosite.ErrInvalidGrant.WithHint("The refresh token has not been found.")) | |
return errors.WithStack(fosite.ErrInvalidGrant.WithDebug("The refresh token has not been found: %s", err)) |
I cannot commit my suggested changes because you haven't enabled "allow edits by maintainers". Could you please apply the change, then this is ready to merge :) |
Yup, I saw your changes. 👍 |
I used another workflow to apply them :) |
Resolves a regression issue which sends an invalid error response when a refresh token is being re-used, is not found, or the wrong client is accessing it. See https://community.ory.sh/t/refresh-token-endpoint-returns-invalid-request-error-expecting-invalid-grant/1637/2 See ory/fosite#426 See ory/fosite#418
Resolves a regression issue which sends an invalid error response when a refresh token is being re-used, is not found, or the wrong client is accessing it. This patch also bumps jose-related tooling which introduces better security measure against certain types of x509 attacks. See https://community.ory.sh/t/refresh-token-endpoint-returns-invalid-request-error-expecting-invalid-grant/1637/2 See ory/fosite#426 See ory/fosite#418
Related issue
#418
Proposed changes
Refresh token flow has been changed in order to return invalid_grant instead of invalid_request when there is a client mismatch or when the refresh token has not been found.
Authorization code flow has been changed in order to return invalid_grant instead of invalid_request when there is a client mismatch or the redirect uri doesn't match the one from the authorization request (or is empty).
Checklist
vulnerability. If this pull request addresses a security vulnerability, I
confirm that I got green light (please contact
security@ory.sh) from the maintainers to push
the changes.