Skip to content

Admin REST API: Insufficient default restrictions on protocol mapper configuration by privileged client administrators #50588

Closed as duplicate

Description

@abstractj

Description

Keycloak's protocol mapper system allows privileged users with client management capabilities (manage-clients, FGAv2 delegated admins, dynamic client registration, CIMD) to configure dangerous mappers — such as direct claim, custom audience, custom role, and script mappers — without any default restrictions. These mappers can manipulate tokens to target other applications or escalate permissions within the realm.

Client policies exist as a mitigation mechanism but are not enabled by default and do not cover all endpoints (e.g., client scope assignment can bypass client policies). Client registration policies only enforce during the registration flow, not on Admin REST API operations.

This is a broad hardening issue encompassing multiple attack vectors. The single concrete exploitable vector — privilege escalation via hardcoded role mapper injection from manage-clients to realm-admin.

Version affected

All current versions (reported against development branch). The architectural gap has existed since protocol mappers were introduced.

Expected behavior

  • Dangerous protocol mappers (direct claim, custom audience, custom role, script mapper) should have default restrictions or require explicit opt-in for non-realm-admin users.
  • Client policies should enforce on all client management endpoints, including Admin REST API and client scope assignment.
  • Not all client scopes should be available to all clients by default.
  • Script mappers should have additional restrictions given their ability to execute arbitrary code.

Actual behavior

  • All protocol mappers are available to any user with client management privileges, with no default restrictions.
  • Client registration policies only enforce during OIDC/SAML registration flows, not Admin REST API calls.
  • Client policies can be bypassed by directly mapping a client scope to a client.
  • Script mappers are available without additional authorization checks.

Steps to reproduce

  1. Assign manage-clients role to a user (or configure FGAv2 delegated client admin).
  2. Using the Admin REST API, create or update a client with a hardcoded-role protocol mapper pointing to a privileged role (e.g., realm-admin).
  3. Authenticate as the client's service account.
  4. Observe the token contains the escalated role without any policy enforcement blocking the mapper configuration.

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

Activity

  1. self-assigned this
    on Oct 8, 2026
  2. mposolda commented on Oct 15, 2026

    @mposolda
    Contributor

    Related issue for documentation update: #54010 (warning to the documentation about the fact that client administrator can assign any client scope)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Fields

No fields configured for weakness.

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions