Skip to content

Mask vault password in show-config#51013

Merged
shawkins merged 2 commits into
keycloak:mainfrom
AkashKumar7902:agent/mask-vault-password-show-config
Jul 24, 2026
Merged

Mask vault password in show-config#51013
shawkins merged 2 commits into
keycloak:mainfrom
AkashKumar7902:agent/mask-vault-password-show-config

Conversation

@AkashKumar7902

Copy link
Copy Markdown
Contributor

Closes #50844

Summary

  • mark the vault password mapper as sensitive so show-config masks both the public option and its mapped SPI property
  • suppress unmapped SmallRye-normalized duplicates of KC_* variables because KcEnvConfigSource already provides their canonical keys
  • add regression coverage for kc.vault-pass and kc.spi-vault--keystore--pass, including checks that plaintext secrets never appear

Testing

  • ./mvnw -pl quarkus/server,quarkus/dist -am -DskipTests -DskipTestsuite -DskipExamples install
  • ./mvnw test -pl quarkus/tests/integration -Dtest=ShowConfigCommandDistTest (9 tests passed)
  • ./mvnw -pl quarkus/runtime,quarkus/tests/integration -DskipTests spotless:check

AI assistance

This contribution was developed with assistance from OpenAI Codex agents. I reviewed and understand every change and am responsible for the implementation and for responding to review feedback.

Mark the vault password mapper as sensitive and ignore duplicate SmallRye environment aliases so the password is never shown in show-config output.

Closes keycloak#50844

Signed-off-by: Akash Kumar <meakash7902@gmail.com>
@AkashKumar7902
AkashKumar7902 marked this pull request as ready for review July 18, 2026 21:02
@AkashKumar7902
AkashKumar7902 requested review from a team as code owners July 18, 2026 21:02
Copilot AI review requested due to automatic review settings July 18, 2026 21:02

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.

Pull request overview

Masks vault passwords in show-config and removes plaintext duplicates produced by environment-variable normalization.

Changes:

  • Marks the vault password mapper as sensitive.
  • Suppresses noncanonical KC_* environment entries.
  • Adds regression tests for public and mapped vault password properties.

Reviewed changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated no comments.

File Description
ShowConfigCommandDistTest.java Tests vault password masking and plaintext exclusion.
VaultPropertyMappers.java Marks vault passwords for masking.
ShowConfig.java Filters normalized environment-variable duplicates.

PropertyMapper<?> mapper = PropertyMappers.getMapper(property);

// Ignore SmallRye-normalized duplicates of KC_* variables; KcEnvConfigSource provides the canonical keys.
if (mapper == null && property.startsWith(MicroProfileConfigProvider.NS_KEYCLOAK_PREFIX)

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.

This should be split off as a different issue. We don't generally expect the spi keys to be directly used when there is a first class option. This would also happen with more than just the env config source if the legacy key format is used - e.g. kc.spi-vault-keystore-pass

@michalvavrik michalvavrik Jul 21, 2026

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.

This should be split off as a different issue. We don't generally expect the spi keys to be directly used when there is a first class option. This would also happen with more than just the env config source if the legacy key format is used - e.g. kc.spi-vault-keystore-pass

That test looks legit (I checked and it is failing without this), as long as users can set it, we should plan to fix it. In another issue is fine.

In SmallRye Config terms, we could just be using io.smallrye.config.FallbackConfigSourceInterceptor for the legacy key format and then, we could rely on "masked". But I know that Keycloak works differently, I'll not try to understand it more as this part will be handled in another issue.

@shawkins shawkins Jul 21, 2026

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.

as long as users can set it

It's documented that you shouldn't use that and you should see a warning about using a "second-class" option, so it's much less of a concern that masking the proper configuration option for the vault password.

In SmallRye Config terms, we could just be using io.smallrye.config.FallbackConfigSourceInterceptor

There's two related cases:

  1. Our KC_SPI_FOO__BAR__KEY is turned into kc.spi-foo--bar--key by the KcEnvConfigSource, but the EnvConfigSource assumes that it's kc.spi.foo."bar".key - which is effectively what the proposed change is trying to filter here.

  2. What I'm highlighting, which is applicable to any config source, is that we support also kc.spi-foo-bar-key as an legacy alternative to the double dash version.

I don't think we looked at using the FallbackConfigSourceInterceptor for the second case - it's just being handled in the MicroProfileConfigProvider.

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.

Thanks.

Our KC_SPI_FOO__BAR__KEY is turned into kc.spi-foo--bar--key by the KcEnvConfigSource, but the EnvConfigSource assumes that it's kc.spi.foo."bar".key - which is effectively what the proposed change is trying to filter here.

IIRC SR Config assumes this when it doesn't know there is such a property as kc.spi-foo--bar--key, which is why when you are mapping env vars to such properties you are supposed to also declare them in some dotted config source with lower priority.

I do not say it is a solution, I'll not work on this as we agreed it is a separate issue. I appreciate the context, thanks again.

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.

which is why when you are mapping env vars to such properties you are supposed to also declare them in some dotted config source with lower priority

Does it need to be lower priority - wouldn't that have to be a .env or in the application.properties?

I thought it was aware of kc.spi-foo--bar--key in the KcEnvConfigSource but does not consider it a match for KC_SPI_FOO__BAR__KEY because of the conversion rule to double quotes being superseding.

In any case, let's remove this change from the PR and move this discussion over to #51113

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.

Does it need to be lower priority - wouldn't that have to be a .env or in the application.properties?

I don't know, I don't keep up to date knowledge of SR Config internals because it keeps changing like crazy. https://smallrye.io/smallrye-config/Main/config/environment-variables/ doesn't mention priority, it just says a dotted config source. There is "It can be set in a low ordinal source, even without value." but that doesn't mean it can't work with the higher one.

I said lower priority because that is what I did in the past when using K8 extension to specify env vars, env vars to dotted prop names is ambiguous, so when we created it in a dotted format with stale values, it started working as they were overridden by the env vars.

I thought it was aware of kc.spi-foo--bar--key in the KcEnvConfigSource but does not consider it a match for KC_SPI_FOO__BAR__KEY because of the conversion rule to double quotes being superseding.

Sorry for being slow, but I don't understand why kc.spi-foo--bar--key shouldn't be resolved to KC_SPI_FOO__BAR__KEY if the former is specified somewhere. I may just don't know about that rule and it is my bad!

In any case, let's remove this change from the PR and move this discussion over to #51113

Absolutely. I assume it will be clear when I sit down on it, I still didn't debug it, maybe I shouldn't say anything until then.

Signed-off-by: Steve Hawkins <shawkins@redhat.com>
Copilot AI review requested due to automatic review settings July 24, 2026 14:44

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

LGTM - removed the additional logic and test, so that it can be addressed under the other issue.

@shawkins
shawkins enabled auto-merge (squash) July 24, 2026 14:45

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.

Pull request overview

Copilot reviewed 1 out of 2 changed files in this pull request and generated no new comments.

@keycloak-github-bot keycloak-github-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Unreported flaky test detected, please review

@keycloak-github-bot

Copy link
Copy Markdown

Unreported flaky test detected

If the flaky tests below are affected by the changes, please review and update the changes accordingly. Otherwise, a maintainer should report the flaky tests prior to merging the PR.

org.keycloak.testsuite.forms.MultipleTabsLoginTest#multipleTabsParallelLoginTestWithAuthSessionExpiredAndRegisterClick

Keycloak CI - Forms IT (firefox)

org.opentest4j.AssertionFailedError: expected: <true> but was: <false>
	at org.junit.jupiter.api.AssertionFailureBuilder.build(AssertionFailureBuilder.java:151)
	at org.junit.jupiter.api.AssertionFailureBuilder.buildAndThrow(AssertionFailureBuilder.java:132)
	at org.junit.jupiter.api.AssertTrue.failNotTrue(AssertTrue.java:63)
	at org.junit.jupiter.api.AssertTrue.assertTrue(AssertTrue.java:36)
...

Report flaky test

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.

show-config prints the vault keystore password in cleartext

5 participants