8000 Reject resourceType on user-managed permissions by pedroigor · Pull Request #54967 · keycloak/keycloak · GitHub
[go: up one dir, main page]

Skip to content

Reject resourceType on user-managed permissions - #54967

Merged
stianst merged 1 commit into
keycloak:mainfrom
pedroigor:issue-54696
Nov 12, 2026
Merged

stianst merged 1 commit into
keycloak:mainfrom
pedroigor:issue-54696

Conversation

@pedroigor
Copy link
Copy Markdown
Contributor

Closes #54696

Closes keycloak#54696

Signed-off-by: Stefan Guilhen <sguilhen@redhat.com>
@pedroigor
pedroigor requested review from a team as code owners November 10, 2026 10:18
Copilot AI balanced review requested due to automatic review settings November 10, 2026 10:18
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 change affects a cross-owner authorization boundary for a reported CVE, warranting security-maintainer review and integration validation of legacy persisted permissions.

No open issues 🎉

What changed in this PR

This PR hardens UMA user-managed permissions against cross-owner access through resource-type policies, addressing #54696.

Changes:

  • Rejects resourceType on user-managed permission creation and updates.
  • Excludes owner-bound policies from resource-type policy evaluation.
  • Adds regression tests for request validation and cross-owner access through legacy policies.
File Description
testsuite/​integration-arquillian/​tests/​base/​src/​test/​java/​org/​keycloak/​testsuite/​authz/​UserManagedPermissionServiceTest.java Tests create/update rejection and denial of cross-owner access through a legacy owner-bound policy.
services/​src/​main/​java/​org/​keycloak/​authorization/​protection/​policy/​UserManagedPermissionService.java Returns HTTP 400 when a user-managed permission specifies resourceType.
server-spi-private/​src/​main/​java/​org/​keycloak/​authorization/​policy/​evaluation/​DefaultPolicyEvaluator.java Filters owner-bound policies out of resource-type policy evaluation.

Review effort: Balanced

@martin-kanis martin-kanis left a comment
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good.

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

The fix looks correct to me. One thing needs sorting out before this can go in:

Testsuite Deprecation Check is failing (and with it "Status Check - Keycloak CI"). The PR adds ~122 lines to UserManagedPermissionServiceTest.java, and the check allows at most 100 added lines per file in the deprecated testsuite. The tests need trimming by roughly 25 lines, or moving to the new test framework.

What I checked:

  • Write path: checkRequest rejects resourceType on both create and update. Update validates the same payload, parsed as the same class, that the delegate then persists, so the check and the write cannot disagree.
  • Read path: skipping owner-bound policies in evaluateResourceTypePolicies neutralises policies stored before the fix, with no migration needed. The filter sits outside the cache, so cached results are filtered too.
  • No regression for legitimate sharing: owner-bound policies (Protection API and granted permission tickets) always carry an explicit resource, so they still apply through the per-resource lookup. Admin-created resource-type permissions have no owner and are unaffected.
  • No other route in: the scope-only lookup is limited to scope-type policies without a resource type, so a legacy uma policy cannot come back that way.

Optional, non-blocking:

  • createOwnerBoundResourceTypePolicy builds a policy with no resource attached, which the real API never produced. It still proves the evaluator filter, but a legacy policy with both a resource and a resource type would be closer to real data.
  • The new catch (RuntimeException ignore) blocks use the "ignored" exception. This matches the existing style in the file, so feel free to leave it.
  • The 400 on resourceType is a behaviour change for Protection API clients; is an upgrade note needed on main, or is that already covered by the release-branch notes?

@pedroigor
Copy link
Copy Markdown
Contributor Author

Thanks, @ssilvert. As you know, we are in the process of migrating tests to the new test framework.

@stianst
stianst merged commit 9e13e5e into keycloak:main Nov 12, 2026
94 of 96 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-114232] UMA user-managed permission resourceType field not validated — cross-owner resource access — #YWH-PGM40475-306

6 participants

0