Skip to content

Check ownership of every resource of a user-managed permission - #55537

Open
sguilhen wants to merge 1 commit into
keycloak:mainfrom
sguilhen:55388-uma-multi-resource-ownership
Open

sguilhen wants to merge 1 commit into
keycloak:mainfrom
sguilhen:55388-uma-multi-resource-ownership

Conversation

@sguilhen

@sguilhen sguilhen commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor
  • a user-managed permission is only ever created through the Protection API with a single resource attached. Multiple resources on a uma-type policy are only reachable by an administrator wiring one up directly through the full admin API, which is not the shape this policy type expects, and it is what let a policy span resources owned by different users. Creating or updating a uma-type policy with more than one resource is now rejected at that entry point instead. Existing policies already in this state are left as is.

  • findById(), delete() and update() in the Protection API still verify that the resolved policy is a uma-type permission owned by the caller, not just that the caller owns the associated resource. The resource-ownership check alone let a caller reach any policy associated with a resource it owns, including permissions of other types or owned by someone else, since the delegate used for these operations skips all administrative checks.

Closes #55388

@sguilhen
sguilhen requested review from a team as code owners November 25, 2026 17:26
Copilot AI balanced review requested due to automatic review settings November 25, 2026 17:26

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

The collection find() endpoint lacks the resource-ownership restriction applied to findById(), allowing users to retrieve mixed-owner policies through an alternate read path.

1 open issue
What changed in this PR

This PR addresses #55388 by strengthening resource-ownership checks for user-managed permissions in the UMA Protection API.

Changes:

  • Checks ownership of every associated resource before read-by-ID, update, and delete operations.
  • Rejects policies without associated resources.
  • Adds regression tests for mixed-owner, same-owner multi-resource, and resource-less policies.
File Description
testsuite/​integration-arquillian/​tests/​base/​src/​test/​java/​org/​keycloak/​testsuite/​authz/​UserManagedPermissionServiceTest.java Adds ownership and resource-less policy regression tests.
services/​src/​main/​java/​org/​keycloak/​authorization/​protection/​policy/​UserManagedPermissionService.java Centralizes checks across all resources associated with a policy.

Review effort: Balanced

@sguilhen
sguilhen force-pushed the 55388-uma-multi-resource-ownership branch from f908c20 to c2b9e62 Compare November 25, 2026 18:07
Copilot AI balanced review requested due to automatic review settings November 25, 2026 18:07

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

Ownership filtering occurs after pagination, potentially returning empty or short pages that cause clients to miss accessible permissions.

1 open issue
1 resolved since last review

Review effort: Balanced

@sguilhen
sguilhen force-pushed the 55388-uma-multi-resource-ownership branch from c2b9e62 to 3f3edc8 Compare November 26, 2026 14:26
Copilot AI balanced review requested due to automatic review settings November 26, 2026 14:26

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

Permission pagination loads all matching policies even for tiny pages and silently truncates explicit max=-1 requests, introducing performance and backward-compatibility regressions.

2 open issues
1 resolved since last review

Review effort: Balanced

@sguilhen
sguilhen force-pushed the 55388-uma-multi-resource-ownership branch from 3f3edc8 to a6ad2f9 Compare November 26, 2026 15:14
Copilot AI balanced review requested due to automatic review settings November 26, 2026 15:14

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

The pagination calculation can overflow for valid query parameters, causing an empty result even when accessible permissions exist.

1 open issue
2 resolved since last review

Review effort: Balanced

@sguilhen
sguilhen force-pushed the 55388-uma-multi-resource-ownership branch from a6ad2f9 to 4403253 Compare November 26, 2026 15:59
Copilot AI balanced review requested due to automatic review settings November 26, 2026 15:59

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 UMA permission ownership and pagination changes.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

Closes keycloak#55388

Signed-off-by: Stefan Guilhen <sguilhen@redhat.com>
@sguilhen
sguilhen force-pushed the 55388-uma-multi-resource-ownership branch from 4403253 to 0545c92 Compare November 26, 2026 23:20
Copilot AI balanced review requested due to automatic review settings November 26, 2026 23:20

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

Callers can still read or delete existing UMA policies governing another user’s resource, while omitting or changing the submitted type bypasses the update guard.

3 open issues

Review effort: Balanced

// type, any owner) from one created through this self-service API; the resource ownership check in
// checkRequest() is not enough on its own, since the caller may happen to own the resource an
// admin-authored permission of a different type governs
if (!"uma".equals(policy.getType()) || !identity.getId().equals(policy.getOwner())) {
// a user-managed permission (type "uma") is only ever created through the Protection API with a single
// resource attached; multiple resources are only reachable by an administrator wiring a policy up
// directly through the full admin API, which is not the expected shape for this policy type
if ("uma".equals(representation.getType()) && policy.getResources().size() > 1) {
Comment on lines +151 to +152
assertThrows(RuntimeException.class, () -> authzClient.protection(user, "password").policy(policyId).delete(policyId));
assertThrows(RuntimeException.class, () -> authzClient.protection(user, "password").policy(policyId).findById(policyId));
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.

Incomplete fix for CVE-2025-14778: UserManagedPermissionService.delete() still trusts only the first resource of a multi-resource UMA policy

3 participants