Repository navigation
Fix admin roles assignments by protocol mappers for DCR (#957) - #51499
Merged
Merged
Conversation
closes #CVE-2026-16102 closes keycloak#51473 Signed-off-by: mposolda <mposolda@gmail.com> Signed-off-by: Peter Skopek <peter.skopek@ibm.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Hardens DCR authorization against administrative roles forged through protocol mapper claims.
Changes:
- Normalizes mapped role claims before filtering unauthorized admin roles.
- Revalidates DCR bearer-token roles against the current user session.
- Adds unit and integration coverage for mapper-based role injection.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
core/src/main/java/org/keycloak/representations/AccessToken.java |
Adds constants for access-role claims. |
core/src/main/java/org/keycloak/util/TokenUtil.java |
Converts and merges mapped role claims. |
core/src/test/java/org/keycloak/jose/JsonWebTokenTest.java |
Tests role-claim merging. |
services/src/main/java/org/keycloak/services/clientregistration/ClientRegistrationAuth.java |
Revalidates DCR admin roles. |
services/src/main/java/org/keycloak/services/managers/AuthenticationManager.java |
Reports whether lightweight roles were resolved. |
services/src/main/java/org/keycloak/services/resources/admin/AdminRoleTokenPostProcessor.java |
Normalizes claims before admin-role filtering. |
tests/base/src/test/java/org/keycloak/tests/client/AbstractClientRegistrationTest.java |
Shares client test construction. |
tests/base/src/test/java/org/keycloak/tests/client/ClientRegistrationPermissionsTest.java |
Adds DCR role-forgery integration tests. |
Comment on lines
+304
to
+307
| if (access1 == null) return access2; | ||
| if (access2 == null) return access1; | ||
| access1.getRoles().addAll(access2.getRoles()); | ||
| return access1; |
| if (token.getOtherClaims().containsKey(RESOURCE_ACCESS)) { | ||
| token.setResourceAccess(new HashMap<>(token.getResourceAccess())); // Re-create as hashMap as it might be unmodifiable map | ||
|
|
||
| if (token.getOtherClaims().get(RESOURCE_ACCESS) instanceof Map) { |
jimmychakkalakal
approved these changes
Aug 6, 2026
jimmychakkalakal
left a comment
Contributor
There was a problem hiding this comment.
I have gone through code changes, LGTM. I approve changes from my side
lhanusov
approved these changes
Aug 6, 2026
This was referenced Aug 20, 2026
2 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
closes #CVE-2026-16102
closes #51473