8000 Restrict defaultRoles and full scope via client registration policies by edewit · Pull Request #54887 · keycloak/keycloak · GitHub
[go: up one dir, main page]

Skip to content

Restrict defaultRoles and full scope via client registration policies - #54887

Merged
mposolda merged 5 commits into
keycloak:mainfrom
edewit:backport-54702-main
Nov 12, 2026
Merged

mposolda merged 5 commits into
keycloak:mainfrom
edewit:backport-54702-main

Conversation

@edewit
@edewit edewit commented Nov 9, 2026 •
Copy link
Copy Markdown
Contributor

Summary

Backports the CVE-2026-109081 fix from 26.8.2 onto main so Dynamic Client Registration cannot inject realm default-role composites or enable full scope unless an admin removes the new client registration policies.

MigrateTo26_8_2 now combines the existing Admin API audience/scope migration on main with the client registration policy installation from the backport. The upgrade note is documented under 27.0.0.

Closes #54702

@edewit
edewit marked this pull request as ready for review November 9, 2026 09:06
@edewit
edewit requested a review from a team as a code owner November 9, 2026 09:06
Copilot AI balanced review requested due to automatic review settings November 9, 2026 09:06
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.

🟡 Changes recommended

Migration-only manifests leave compatibility metadata unchanged, preventing required recreate-upgrade enforcement, while missing baseline classes cause the test-phase compatibility verifier to fail.

2 open issues
What changed in this PR

Ports the CVE-2026-109081 fix to main, restricting Dynamic Client Registration from changing realm default roles or enabling full scope unless an administrator removes the corresponding policies.

Changes:

  • Adds default-role protection and enables the existing full-scope restriction for authenticated registration.
  • Installs policies in existing realms and declares the migration incompatible with rolling upgrades.
  • Adds regression tests and documents the restrictions and administrator opt-out.
File Description
tests/​base/​src/​test/​java/​org/​keycloak/​tests/​client/​ClientRegistrationTest.java Tests policy enforcement and removal.
tests/​base/​src/​test/​java/​org/​keycloak/​tests/​client/​AbstractClientRegistrationTest.java Adds a realm-management user and authentication helper.
services/​src/​test/​java/​org/​keycloak/​services/​clientregistration/​policy/​impl/​DefaultRolesClientRegistrationPolicyTest.java Tests rejection of nonempty and null-element default roles.
services/​src/​main/​resources/​META-INF/​services/​org.keycloak.services.clientregistration.policy.ClientRegistrationPolicyFactory Registers the new policy factory.
services/​src/​main/​java/​org/​keycloak/​services/​clientregistration/​policy/​impl/​DefaultRolesClientRegistrationPolicyFactory.java Defines the default-role policy provider.
services/​src/​main/​java/​org/​keycloak/​services/​clientregistration/​policy/​impl/​DefaultRolesClientRegistrationPolicy.java Rejects registration requests that change default roles.
services/​src/​main/​java/​org/​keycloak/​services/​clientregistration/​policy/​DefaultClientRegistrationPolicies.java Enables the restrictions by default.
services/​src/​main/​java/​org/​keycloak/​services/​clientregistration/​AbstractClientRegistrationProvider.java Skips null role names during updates.
services/​src/​main/​java/​org/​keycloak/​protocol/​oauth2/​cimd/​provider/​AbstractPersistentClientIdMetadataDocumentProvider.java Removes default-role creation from metadata registration.
model/​storage-private/​src/​main/​resources/​META-INF/​rolling-upgrades-unsupported-changes.json Marks the policy migration as rolling-upgrade incompatible.
model/​storage-private/​src/​main/​resources/​META-INF/​rolling-upgrades-supported-changes.json Records the supported migration baseline.
model/​storage-private/​src/​main/​java/​org/​keycloak/​storage/​datastore/​DefaultMigrationManager.java Registers the new migrator.
model/​storage-private/​src/​main/​java/​org/​keycloak/​migration/​migrators/​MigrateTo26_8_2.java Installs missing policies in existing realms.
docs/​guides/​securing-apps/​client-registration.adoc Describes policy defaults and removal.
docs/​documentation/​upgrading/​topics/​changes/​changes-27_0_0.adoc Documents behavior changes and cluster upgrade requirements.

Review effort: Balanced

edewit and others added 3 commits November 10, 2026 09:21
Replace hardcoded manage-realm/RAT checks with Default Roles Disabled and
authenticated Full Scope Disabled policies so admins can opt back in.

Closes CVE-2026-109081
Closes keycloak#54702

Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com>
Main requires both supported and unsupported JSON inventories for the
db-compatibility verifier; mark the new policy migrator as unsupported.

Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com>
Include Migration helper classes and OidcIssuerMigration in the supported
baseline, and hash unsupported migration-only manifests so recreate upgrades
are required.

Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com>
@edewit
edewit force-pushed the backport-54702-main branch from 277a95a to bb235de Compare November 10, 2026 08:29
Copilot AI balanced review requested due to automatic review settings November 10, 2026 08:29
@edewit
edewit requested a review from a team as a code owner November 10, 2026 08:29
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.

🔵 Needs a closer look

The security-sensitive upgrade path requires runtime validation that existing realms receive the policies and packaged Quarkus discovers the migration-only manifest to reject rolling upgrades.

No open issues 🎉

2 resolved since last review

Review effort: Balanced

Drop SPI helper classes the Maven plugin does not discover so the
supported/unsupported inventories match the module classpath.

Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com>
Copilot AI balanced review requested due to automatic review settings November 10, 2026 08:41
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.

🔵 Needs a closer look

The security backport changes persisted realm policies and rolling-upgrade compatibility, requiring runtime validation of affected-release upgrades and mixed-version cluster rejection that is unavailable in this review.

No open issues 🎉

Review effort: Balanced

@mposolda mposolda self-assigned this Nov 10, 2026
@mposolda mposolda 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 am not sure why this PR needs to do any updates of the file rolling-upgrades-suported-changes.json considering that the original PR does not have anything like that. Also not sure about introducing the file rolling-upgrades-unsupported-changes.json .

Looks like the files were removed from main on purpose and they are not needed anymore?
@ahus1 Could you please confirm?

@ahus1
ahus1 commented Nov 10, 2026
Copy link
Copy Markdown
Member

@edewit: Please remove the files rolling-upgrades-suported-changes.json and rolling-upgrades-unsupported-changes.json from the PR. The only exist in release branches where we do support rolling updates between patch releases.

cc: @mposolda

These inventories are only used on release branches that support
rolling updates between patch releases, so drop them from the main
backport along with the related compatibility hashing change.

Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com>
@edewit
edewit commented Nov 10, 2026
Copy link
Copy Markdown
Contributor Author

Removed rolling-upgrades-supported-changes.json and rolling-upgrades-unsupported-changes.json from this PR, and reverted the related DatabaseCompatibilityMetadataProvider hashing change. Those inventories stay on release branches only, as discussed.

Copilot AI balanced review requested due to automatic review settings November 10, 2026 13:53
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.

🔵 Needs a closer look

Security-sensitive DCR authorization and existing-realm migration still require integration validation, including upgrades from 26.8.2 and clustered upgrade compatibility, which could not be exercised in this review environment.

No open issues 🎉

Review effort: Balanced

@mposolda mposolda 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.

@edewit Thanks!

@mposolda
mposolda merged commit 8aabe42 into keycloak:main Nov 12, 2026
127 of 136 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[CVE-2026-109081] Principal with only create-client can inject a role into the realm default-roles — #YWH-PGM40475-290

4 participants

0