Skip to content
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

User Credentials grant doesn't verify user_id vs Client Credentials user_id #1028

Open
whvandervelde opened this issue Jun 27, 2022 · 0 comments

Comments

@whvandervelde
Copy link

When you are using the UserCredentials grant, the default TokenController doesn't check if Client Credentials user_id matches with UserCredentials user_id.
This means when you are requesting a token you can use any valid client_id + client_secret and username + password combo to get a valid token for the user(name).
Its hard to detect because token response doesn't containing user info, but TokenController should check if user_id's match.

The grantAccessToken in TokenController should probably contain something like this in its grantAccessToken():

if (!$clientInfo = $this->clientStorage->getClientDetails($clientId)) {
    $response->setError(400, 'unauthorized_client', 'The grant type is unauthorized for this client');
    return null;   
}

$userId = $clientInfo['user_id'] ?? null;
$matchUserId = $grantType->getUserId();

if (!isset($userId) || !($userId === $matchUserId)) {
    $response->setError(400, 'unauthorized_client', 'The grant type is unauthorized for this client');
    return null;   
}
@whvandervelde whvandervelde changed the title UserCredential grant doesn't verify user_id vs Client Credentials user_id User Credentials grant doesn't verify user_id vs Client Credentials user_id Jun 27, 2022
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

No branches or pull requests

1 participant