Skip to content

Fix admin roles assignments by protocol mappers for DCR (#957) - #51499

Merged
pskopek merged 1 commit into
keycloak:mainfrom
pskopek:issues/keycloak-51473
Aug 7, 2026
Merged

pskopek merged 1 commit into
keycloak:mainfrom
pskopek:issues/keycloak-51473

Conversation

@pskopek

@pskopek pskopek commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

closes #CVE-2026-16102
closes #51473

closes #CVE-2026-16102
closes keycloak#51473

Signed-off-by: mposolda <mposolda@gmail.com>
Signed-off-by: Peter Skopek <peter.skopek@ibm.com>
Copilot AI balanced review requested due to automatic review settings August 6, 2026 11:56
@pskopek
pskopek requested a review from a team as a code owner August 6, 2026 11:56

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 jimmychakkalakal left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have gone through code changes, LGTM. I approve changes from my side

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

Successfully merging this pull request may close these issues.

CVE-2026-16102 Default DCR policy allows role forgery via user property mappers

5 participants