Skip to content

Report: canMapClientScope fast-path skips the checkAdminRoles protection, letting a manage-clients administrator scope-map admin roles to clients #55285

Description

@abstractj

Describe the bug

A realm administrator who holds only the manage-clients permission can map a built-in realm-management administrator role, such as manage-users, to the client scope of any client they manage. Keycloak blocks the same administrator from mapping these roles through the two other role-mapping paths, which are mapping a role to a user or group and adding a role as a composite of another role. The client scope mapping path does not apply the same check, so the three paths are inconsistent. This happens with both the V1 and V2 admin permission models. This is a different code path from the one addressed by CVE-2026-3121.

Client scope mapping does not grant a role to anyone. It only limits which of an authenticating user's existing roles can appear in the tokens of that client. The administrator cannot use the mapped role themselves, and a user who already holds the role can already obtain admin-scoped tokens through the built-in admin-cli client. A manage-clients administrator can also already make any client they manage include all of a user's roles by enabling full scope allowed, so no escalation beyond what manage-clients allows was identified. The issue is an inconsistency between the three role-mapping checks.

Version

26.8.2. Also present on main.

Expected behavior

Mapping a built-in administrator role to a client scope is rejected for a manage-clients administrator who does not already hold that role or an equivalent privilege, consistent with the other two role-mapping paths, in both permission models.

Actual behavior

A manage-clients administrator can map a built-in administrator role such as manage-users to the scope of a client they manage, and the server accepts the request with HTTP 204. The same administrator receives HTTP 403 when mapping that role to a user or adding it as a composite role.

Acknowledgement

Thank you to Yuqi Qiu and Xiang Li (Nankai University, AOSP Lab) for reporting this issue.


This issue was originally tracked in the private repository. Migrated by @abstractj.

Metadata

Metadata

Assignees

No one assigned

    Fields

    No fields configured for weakness.

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions