Skip to content

[CIMD] Metadata scope field attaches arbitrary realm client scopes without operator allowlist - #55213

Open
tnorimat wants to merge 1 commit into
keycloak:mainfrom
Hitachi:ISSUE-55130
Open

tnorimat wants to merge 1 commit into
keycloak:mainfrom
Hitachi:ISSUE-55130

Conversation

@tnorimat

Copy link
Copy Markdown
Contributor

closes #55130

…thout operator allowlist

closes keycloak#55130

Signed-off-by: Takashi Norimatsu <takashi.norimatsu.ws@hitachi.com>
@tnorimat
tnorimat requested a review from a team as a code owner November 16, 2026 04:46
Copilot AI balanced review requested due to automatic review settings November 16, 2026 04:46
@tnorimat

Copy link
Copy Markdown
Contributor Author

Problem

The scope property of a CIMD metadata document was copied directly into the client's optional client scopes. Any existing realm client scope could be attached by name, without operator approval.

Fix

Added a Client scope allow list option (cimd-client-scope-allow-list) to the client-id-metadata-document executor. It is enforced in two places:

  1. Before the client is saved (create and refresh): scope names in the metadata scope property that are not in the allow list are removed before the client is created or updated.
  2. On every authorization request: optional client scopes on the CIMD client that are not in the allow list are removed. This also covers:
    • an allow list tightened while the cached metadata is still valid (no re-fetch needed),
    • metadata without a scope property (realm default optional client scopes, or scopes kept from an earlier version, are not left on the client).

If the allow list is empty, CIMD clients have no optional client scopes. Default client scopes are not affected.

The check is called from process(), not from the overridable validateClientMetadata(), so a subclass cannot skip it.

Notes

Tests

Added to ClientIdMetadataDocumentTest:

  • scopes off the list are removed on create and on refresh
  • empty allow list
  • allow list tightened without a re-fetch
  • metadata without a scope property

The docs (mcp-authz-server.adoc) describe the new option.

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.

🟢 Approval recommended

No active review issues are reported for the CIMD client-scope allowlist change.

No open issues 🎉

What changed in this PR

This PR addresses #55130 by adding an administrator-controlled client scope allowlist for Client ID Metadata Document (CIMD) clients, preventing metadata from attaching arbitrary realm client scopes.

Changes:

  • Filters metadata scopes before creation or refresh and removes disallowed optional scopes on every authorization request, including cached requests.
  • Adds executor configuration and documentation, clarifying that an empty allowlist permits no optional scopes while default client scopes remain unaffected.
  • Adds tests for creation, refresh, allowlist tightening, missing metadata scopes, and an empty allowlist.
File Description
tests/​base/​src/​test/​java/​org/​keycloak/​tests/​client/​policies/​ClientIdMetadataDocumentTest.java Adds allowlist regression tests and updates test configuration.
services/​src/​main/​java/​org/​keycloak/​protocol/​oauth2/​cimd/​clientpolicy/​executor/​AbstractClientIdMetadataDocumentExecutorFactory.java Exposes the allowlist setting and its help text.
services/​src/​main/​java/​org/​keycloak/​protocol/​oauth2/​cimd/​clientpolicy/​executor/​AbstractClientIdMetadataDocumentExecutor.java Enforces the allowlist on metadata and persisted optional scopes.
docs/​guides/​securing-apps/​mcp-authz-server.adoc Documents configuration and scope-removal behavior.

Review effort: Balanced

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.

[CIMD] Metadata scope field attaches arbitrary realm client scopes without operator allowlist

2 participants