8000 Deleted or missing referenced entities cause authorization policies a… by martin-kanis · Pull Request #55404 · keycloak/keycloak · GitHub
[go: up one dir, main page]

Skip to content

Deleted or missing referenced entities cause authorization policies a… - #55404

Merged
pedroigor merged 1 commit into
keycloak:mainfrom
martin-kanis:issue-54156
Nov 25, 2026
Merged

pedroigor merged 1 commit into
keycloak:mainfrom
martin-kanis:issue-54156

Conversation

@martin-kanis
@martin-kanis martin-kanis commented Nov 20, 2026 •
Copy link
Copy Markdown
Member

…nd dependent permissions to grant unintended access

The PR follows pattern from #54033

Closes #54156

@martin-kanis
martin-kanis requested review from a team as code owners November 20, 2026 10:40
Copilot AI balanced review requested due to automatic review settings November 20, 2026 10:40
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

Saving a negative group policy can silently drop unresolved references and broaden access, while client and client-scope updates can fail on retained missing references.

3 open issues
What changed in this PR

This PR addresses #54156 by hardening Keycloak authorization policies against deleted references, preserving affected policy associations, and making missing entities visible in the Admin UI.

Changes:

  • Add invalid-policy evaluation and preserve unresolved references during export/import.
  • Display shared warning labels for missing policy entities.
  • Add regression coverage, update deletion expectations, and document upgrade behavior.
File Description
testsuite/​integration-arquillian/​tests/​base/​src/​test/​java/​org/​keycloak/​testsuite/​authz/​ClientScopePolicyTest.java Expect depleted client-scope policies to remain.
testsuite/​integration-arquillian/​tests/​base/​src/​test/​java/​org/​keycloak/​testsuite/​authz/​admin/​UserPolicyManagementTest.java Update user-reference deletion assertions.
testsuite/​integration-arquillian/​tests/​base/​src/​test/​java/​org/​keycloak/​testsuite/​authz/​admin/​RolePolicyManagementTest.java Expect deleted role references to remain.
testsuite/​integration-arquillian/​tests/​base/​src/​test/​java/​org/​keycloak/​testsuite/​authz/​admin/​GroupPolicyManagementTest.java Expect deleted group references to remain.
testsuite/​integration-arquillian/​tests/​base/​src/​test/​java/​org/​keycloak/​testsuite/​authz/​admin/​ClientPolicyManagementTest.java Update client-reference deletion assertions.
testsuite/​integration-arquillian/​tests/​base/​src/​test/​java/​org/​keycloak/​testsuite/​authz/​admin/​AggregatePolicyManagementTest.java Update retained user-reference expectation.
tests/​base/​src/​test/​java/​org/​keycloak/​tests/​authz/​services/​PolicyReferenceValidationTest.java Test invalid references and preserved associations.
server-spi-private/​src/​main/​java/​org/​keycloak/​authorization/​store/​syncronization/​ClientApplicationSynchronizer.java Retain references in negative client policies.
js/​apps/​admin-ui/​src/​components/​users/​UserSelect.tsx Display missing selected users.
js/​apps/​admin-ui/​src/​components/​MissingPolicyReference.tsx Add reusable missing-reference warning.
js/​apps/​admin-ui/​src/​components/​client/​ClientSelect.tsx Display missing selected clients.
js/​apps/​admin-ui/​src/​clients/​authorization/​policy/​User.tsx Enable missing-user warnings.
js/​apps/​admin-ui/​src/​clients/​authorization/​policy/​Role.tsx Retain and flag missing roles.
js/​apps/​admin-ui/​src/​clients/​authorization/​policy/​Group.tsx Retain and flag missing groups.
js/​apps/​admin-ui/​src/​clients/​authorization/​policy/​ClientScope.tsx Reuse the shared warning component.
js/​apps/​admin-ui/​src/​clients/​authorization/​policy/​Client.tsx Enable missing-client warnings.
js/​apps/​admin-ui/​maven-resources/​theme/​keycloak.v2/​admin/​messages/​messages_en.properties Add missing-entity labels.
docs/​documentation/​upgrading/​topics/​changes/​changes-27_0_0.adoc Document changed authorization behavior.
authz/​policy/​common/​src/​main/​java/​org/​keycloak/​authorization/​policy/​provider/​user/​UserPolicyProviderFactory.java Preserve unresolved user references in export/import.
authz/​policy/​common/​src/​main/​java/​org/​keycloak/​authorization/​policy/​provider/​user/​UserPolicyProvider.java Invalidate negative policies with missing users.
authz/​policy/​common/​src/​main/​java/​org/​keycloak/​authorization/​policy/​provider/​role/​RolePolicyProviderFactory.java Preserve unresolved roles and export safely.
authz/​policy/​common/​src/​main/​java/​org/​keycloak/​authorization/​policy/​provider/​role/​RolePolicyProvider.java Validate required and negative role references.
authz/​policy/​common/​src/​main/​java/​org/​keycloak/​authorization/​policy/​provider/​permission/​UMAPolicyProviderFactory.java Handle missing entities in UMA representations.
authz/​policy/​common/​src/​main/​java/​org/​keycloak/​authorization/​policy/​provider/​group/​GroupPolicyProviderFactory.java Stop filtering unresolved group definitions.
authz/​policy/​common/​src/​main/​java/​org/​keycloak/​authorization/​policy/​provider/​group/​GroupPolicyProvider.java Invalidate negative policies with missing groups.
authz/​policy/​common/​src/​main/​java/​org/​keycloak/​authorization/​policy/​provider/​clientscope/​ClientScopePolicyProviderFactory.java Preserve depleted policies and unresolved exports.
authz/​policy/​common/​src/​main/​java/​org/​keycloak/​authorization/​policy/​provider/​clientscope/​ClientScopePolicyProvider.java Invalidate depleted or broken scope policies.
authz/​policy/​common/​src/​main/​java/​org/​keycloak/​authorization/​policy/​provider/​client/​ClientPolicyProviderFactory.java Preserve unresolved clients and remove duplicate cleanup.
authz/​policy/​common/​src/​main/​java/​org/​keycloak/​authorization/​policy/​provider/​client/​ClientPolicyProvider.java Invalidate negative policies with missing clients.

Review effort: Balanced

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

Unresolved policy references can make negative aggregates grant access to every identity, while ambiguous client imports can silently drop restrictions and permit unintended access.

3 open issues
3 resolved since last review

Review effort: Balanced

Copilot AI balanced review requested due to automatic review settings November 20, 2026 11:30
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

Export/import can turn an unresolved negative group policy into one that permits nonmembers after a matching group is created, while UMA read/update round trips lose unresolved group paths.

4 open issues

Review effort: Balanced

Copilot AI balanced review requested due to automatic review settings November 20, 2026 11:54
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

UMA updates can misinterpret unresolved group IDs and client/role name–ID collisions, granting or retaining access for unintended groups, clients, or roles.

3 open issues
3 resolved since last review

Review effort: Balanced

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

Regression coverage is missing for negative client and user policies with deleted references, including dependent-permission denial and invalid user-policy outcomes during fine-grained admin partial evaluation.

3 open issues
2 resolved since last review

Review effort: Balanced

Comment on lines +51 to 54
if (clientModel == null) {
if (negative) {
evaluation.setEffect(Effect.INVALID);
return;
Comment on lines +61 to +63
if (!isValid(policy, evaluation.getAuthorizationProvider())) {
evaluation.setEffect(Effect.INVALID);
return;
…nd dependent permissions to grant unintended access

Closes keycloak#54156

Signed-off-by: Martin Kanis <mkanis@ibm.com>
Copilot AI balanced review requested due to automatic review settings November 25, 2026 14:36
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 changes across runtime authorization, partial evaluation, and policy import/export require maintainer validation of fail-closed behavior and compatibility, especially since integration tests could not be run.

2 open issues
1 resolved since last review

Review effort: Balanced

@pedroigor
pedroigor merged commit 3acd4da into keycloak:main Nov 25, 2026
97 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.

Deleted or missing referenced entities cause authorization policies and dependent permissions to grant unintended access

3 participants

0