Skip to content

Follow-up to #54382 and #54463 - Require manage-realm to set vault expressions in identity provider configuration - #55102

Draft
jimmychakkalakal wants to merge 3 commits into
keycloak:mainfrom
jimmychakkalakal:issues/54979-Require-manage-realm-to-set-vault-expressions-in-identity-provider-configuration
Draft

jimmychakkalakal wants to merge 3 commits into
keycloak:mainfrom
jimmychakkalakal:issues/54979-Require-manage-realm-to-set-vault-expressions-in-identity-provider-configuration

Conversation

@jimmychakkalakal

@jimmychakkalakal jimmychakkalakal commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Problem

A ${vault.} expression resolves to the same secret in every vault-enabled field of a realm, whichever component the secret was provisioned for. A user holding only manage-identity-providers could therefore set an identity provider's clientSecret to the vault expression used by a client they cannot manage, and Keycloak would send the resolved value to the identity provider's token URL.

Changes

  1. IdentityProvidersResource#create and IdentityProviderResource#update return 403 when a non-manage-realm caller submits a vault expression in the identity provider configuration that is new or different from the stored value.
  2. The check uses the same expression pattern that the vault transcriber resolves.
  3. Existing identity providers with a stored vault expression are unaffected unless that value is changed.

Other paths that can reference vault keys already require manage-realm: components (LDAP bind credential, key providers), authenticator configuration, realm settings (SMTP) and partial import.

Closes #54979

@jimmychakkalakal jimmychakkalakal changed the title Follow-up to #54382 and #54463, as agreed in the discussion on #54463. Follow-up to #54382 and #54463 - Require manage-realm to set vault expressions in identity provider configuration Nov 12, 2026
@jimmychakkalakal
jimmychakkalakal requested a balanced review from Copilot November 12, 2026 13:21

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

A critical authorization gap lets an IdP manager without manage-realm retain a vault-backed client secret while changing tokenUrl, causing login to send the resolved secret to an attacker-controlled endpoint.

1 open issue
What changed in this PR

This follow-up to #54382 and #54463 restricts vault expressions in identity provider configuration to reduce cross-component secret disclosure by delegated administrators.

Changes:

  • Requires manage-realm to introduce or change vault expressions during identity provider creation and updates.
  • Preserves unchanged stored vault expressions.
  • Adds integration tests for delegated-admin restrictions and realm-admin access.
File Description
tests/​base/​src/​test/​java/​org/​keycloak/​tests/​vault/​VaultCrossComponentSecretDisclosureTest.java Adds permission and secret-disclosure regression tests with a file-backed vault.
services/​src/​main/​java/​org/​keycloak/​services/​resources/​admin/​IdentityProvidersResource.java Applies vault-expression authorization during creation.
services/​src/​main/​java/​org/​keycloak/​services/​resources/​admin/​IdentityProviderResource.java Defines the shared authorization check and applies it during updates.

Review effort: Balanced

@mposolda mposolda self-assigned this Nov 12, 2026
@mposolda
mposolda marked this pull request as ready for review November 12, 2026 15:46
@mposolda
mposolda requested a review from a team as a code owner November 12, 2026 15:46
@mposolda mposolda removed their assignment Nov 12, 2026
@jimmychakkalakal
jimmychakkalakal marked this pull request as draft November 12, 2026 15:53
@jimmychakkalakal
jimmychakkalakal force-pushed the issues/54979-Require-manage-realm-to-set-vault-expressions-in-identity-provider-configuration branch from b7fbda7 to cc09776 Compare November 13, 2026 14:40
@jimmychakkalakal
jimmychakkalakal requested a balanced review from Copilot November 13, 2026 14: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.

🟡 Changes recommended

The new tests are rejected by an earlier helper and never exercise the guard, leaving blocked tokenUrl changes and permitted display-name-only updates by delegated managers without regression coverage.

1 open issue
1 resolved since last review

Review effort: Balanced

…nfiguration

Vault keys are shared by all components of a realm. A user with only
manage-identity-providers could set an identity provider client secret to the
vault expression of a client and make Keycloak send the resolved secret to a
token URL controlled by that user.

Creating an identity provider, or changing an existing vault expression in its
configuration, now requires the manage-realm role. Unchanged vault expressions
on existing identity providers are still accepted, so existing configurations
keep working.

Closes keycloak#54979

Signed-off-by: Jimmy Chakkalakal <jimmy.chakkalakal@ibm.com>
…rovider configuration

Regression test for issue keycloak#54979 that verifies the security guard at IdentityProviderResource.java:246-248, which prevents delegated identity provider managers from changing critical IdP settings when vault-backed secrets are involved.

Test coverage:
1. Vault expression detection via regex pattern (valid/invalid cases)
2. Masked secret comparison logic for reusability checks
3. Guard logic simulation: delegated managers cannot change tokenUrl with vault expressions, but can update non-sensitive fields if the vault expression is unchanged

This unit test approach avoids infrastructure overhead (HTTPS requirements, running Keycloak server) while providing complete coverage of the core guard logic.

Closes keycloak#54979
… tests

Convert to parameterized tests with @ParameterizedTest for better maintainability and readability:
- Vault expression detection: 4 scenarios using @CsvSource
- Secret comparison: 4 scenarios using @MethodSource with SecretComparisonData record
- Guard logic: 4 scenarios using @MethodSource with GuardLogicData record

Benefits:
- Reduces code duplication (12 test cases from single test methods)
- Clear test data definition (what, not how)
- Better IDE/report visualization of test coverage
- Easier to add new scenarios

Closes keycloak#54979

Signed-off-by: Jimmy Chakkalakal <jimmy.chakkalakal@ibm.com>
@jimmychakkalakal
jimmychakkalakal force-pushed the issues/54979-Require-manage-realm-to-set-vault-expressions-in-identity-provider-configuration branch from e7303a7 to 3a699c5 Compare November 16, 2026 11:30
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.

Follow-Up of [CVE-2026-117688] [Security] Vault expressions are not scoped per component, so delegated admins can use other components' secrets

3 participants