-
-
Notifications
You must be signed in to change notification settings - Fork 51
Scope in refresh_token grant type is ignored. #104
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
Comments
@jorenvandeweyer great you found this! |
I thought about this issue yesterday. We have to be careful how we implement this. With the current ignored scope parameter there is no potential security issue. You always get the scope of the original requested scope (?). But Imagine following case: Authorization Code Grant: User can select three scopes: "read write delete" but selects only read scope. Now if refresh token would contains scope value, it could contain "read write delete" scope. What you would expect is that you have again only "read"-scope as the user specified in the authorization code flow specified that he only wants to grant "read" permission to the resource server. If we would just check if the user has the scope allowed by using the usual validateScope-method, an attacker could get with a refresh token more privileges than actually allowed by the user in the first password or authorization- grant. So we actually have to persist the original requested scope from the user then always check against that original scope when a scope is specified in the refresh token flow. |
@jorenvandeweyer is this still an issue? |
Yes this is still an issue and it is not that easy to fix.
regex:
const previousScopes = ['user:read', 'user:write']
const newScopes = ['user:read']
const valid = newScopes.every(newScope => previousScopes.includes(newScope)) |
If it's entirely internal (transforming any incoming scope to an array before furhter) I think it's at least non-breaking for "the outside", right? I think this should be implemented in the formats package, what do you think? |
I think we should also change it for the outside. Line 385 in 48baa8b
would become: validateScope?(user: User, client: Client, scope: string[]): Promise<string[] | Falsey>; which means that all implementations of validateScope functions should return a string instead of an array of strings. |
Then let's target this for 5.x and mark it breaking |
While checking the compliance of the
refresh_token
grant. I discovered that the optional scope parameter in the body is ignored.node-oauth2-server/lib/grant-types/refresh-token-grant-type.js
Lines 64 to 73 in 1b91ddc
https://datatracker.ietf.org/doc/html/rfc6749#section-6
The text was updated successfully, but these errors were encountered: