Skip to content

Updating SAML defualt signature validation securely when settings are… - #54766

Open
PadzerButch wants to merge 1 commit into
keycloak:mainfrom
PadzerButch:Issue_53713_SAML
Open

PadzerButch wants to merge 1 commit into
keycloak:mainfrom
PadzerButch:Issue_53713_SAML

Conversation

@PadzerButch

Copy link
Copy Markdown
Contributor

Relating to issue #53713

Closes #54749

@PadzerButch
PadzerButch marked this pull request as ready for review November 10, 2026 13:33
@PadzerButch
PadzerButch requested review from a team as code owners November 10, 2026 13:33
Copilot AI balanced review requested due to automatic review settings November 10, 2026 13:33

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 defaults can break existing SAML logins, but the required upgrade-guide entry explaining both defaults, signing and trusted-key requirements, and explicit false opt-outs is missing.

1 open issue
What changed in this PR

This PR hardens Keycloak’s SAML identity brokering for #54749 by enabling signature checks when settings are omitted, while preserving explicit opt-outs.

Changes:

  • Enables secure server-side defaults and verifies assertion signatures whenever signed assertions are required.
  • Aligns Admin Console key controls with the effective signature settings.
  • Adds regression coverage and updates existing fixtures to explicitly opt out where needed.
File Description
testsuite/​integration-arquillian/​tests/​base/​src/​test/​resources/​org/​keycloak/​testsuite/​broker/​kc3731-broker-realm.json Explicitly permits unsigned assertions in the fixture.
testsuite/​integration-arquillian/​tests/​base/​src/​test/​java/​org/​keycloak/​testsuite/​saml/​LogoutTest.java Adds explicit signature opt-outs.
testsuite/​integration-arquillian/​tests/​base/​src/​test/​java/​org/​keycloak/​testsuite/​saml/​IdpInitiatedLoginTest.java Preserves unsigned test-provider behavior.
testsuite/​integration-arquillian/​tests/​base/​src/​test/​java/​org/​keycloak/​testsuite/​saml/​BrokerTest.java Adds explicit signature opt-outs.
testsuite/​integration-arquillian/​tests/​base/​src/​test/​java/​org/​keycloak/​testsuite/​broker/​KcSamlBrokerConfiguration.java Explicitly disables assertion-signature requirements.
tests/​base/​src/​test/​java/​org/​keycloak/​tests/​sessionlimits/​KcSamlUserSessionLimitsBrokerTest.java Preserves unsigned session-limit fixtures.
tests/​base/​src/​test/​java/​org/​keycloak/​tests/​i18n/​LoginPageTest.java Disables signature validation for the display fixture.
tests/​base/​src/​test/​java/​org/​keycloak/​tests/​cli/​admin/​KcAdmUpdateTest.java Adds explicit fixture opt-outs.
tests/​base/​src/​test/​java/​org/​keycloak/​tests/​cli/​admin/​KcAdmCreateTest.java Checks omitted settings remain absent after creation.
tests/​base/​src/​test/​java/​org/​keycloak/​tests/​broker/​saml/​SamlBrokerEmptyNameIdTest.java Keeps signature checks outside name-ID test scope.
tests/​base/​src/​test/​java/​org/​keycloak/​tests/​broker/​saml/​KcSamlSignedDocumentOnlyBrokerTest.java Reuses the shared certificate helper.
tests/​base/​src/​test/​java/​org/​keycloak/​tests/​broker/​saml/​KcSamlBrokerTest.java Tests defaults, opt-outs, imports, and invalid signatures.
tests/​base/​src/​test/​java/​org/​keycloak/​tests/​broker/​InterfaceSamlIdentityProviderStoreTokenTest.java Explicitly permits response-only signing.
tests/​base/​src/​test/​java/​org/​keycloak/​tests/​broker/​AbstractKcSamlBrokerTest.java Shares certificate lookup and enables signature-error events.
tests/​base/​src/​test/​java/​org/​keycloak/​tests/​admin/​partialimport/​PartialImportProvidersTest.java Checks partial imports preserve omitted settings.
tests/​base/​src/​test/​java/​org/​keycloak/​tests/​admin/​identityprovider/​IdentityProviderTypeTest.java Adds explicit SAML fixture opt-outs.
tests/​base/​src/​test/​java/​org/​keycloak/​tests/​admin/​identityprovider/​IdentityProviderSamlTest.java Tests metadata import and effective signature defaults.
tests/​base/​src/​test/​java/​org/​keycloak/​tests/​admin/​identityprovider/​AbstractIdentityProviderTest.java Supplies mutable configuration with a fixture validation opt-out.
tests/​base/​src/​test/​java/​org/​keycloak/​tests/​account/​LinkedAccountsRestServiceTest.java Adds opt-outs to the SAML account-link fixture.
services/​src/​test/​java/​org/​keycloak/​test/​broker/​saml/​SAMLIdentityProviderTest.java Tests default and explicit configuration values.
services/​src/​main/​java/​org/​keycloak/​broker/​saml/​SAMLIdentityProviderFactory.java Enables signature validation for metadata imports.
services/​src/​main/​java/​org/​keycloak/​broker/​saml/​SAMLIdentityProviderConfig.java Defaults both signature settings to enabled.
services/​src/​main/​java/​org/​keycloak/​broker/​saml/​SAMLEndpoint.java Verifies signatures when signed assertions are required.
js/​apps/​admin-ui/​test/​utils/​AdminClient.ts Adds identity-provider retrieval for UI tests.
js/​apps/​admin-ui/​test/​identity-providers/​saml-signature-defaults.spec.ts Tests switches and signing-key control visibility.
js/​apps/​admin-ui/​src/​identity-providers/​add/​DetailSettings.tsx Applies effective defaults and updates key-action visibility.
js/​apps/​admin-ui/​src/​identity-providers/​add/​DescriptorSettings.tsx Shows key controls when either signature setting requires them.

Review effort: Balanced


public boolean isValidateSignature() {
return Boolean.valueOf(getConfig().get(VALIDATE_SIGNATURE));
return Boolean.valueOf(getConfig().getOrDefault(VALIDATE_SIGNATURE, "true"));

@tkyjovsk tkyjovsk Nov 11, 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.

@PadzerButch The documentation is missing. (Not present in any of the 3 stacked PRs.)

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

@PadzerButch There are bunch of places (7) where the validation opt-outs aren't required by the tests at all. See my inline comments. I tested these locally, and all these can be safely removed.

In addition to these though, there are bunch of other tests which previously assumed the defaults to be false, and the added opt-outs in them now serve as a workaround to get to their testing logic (even though it has nothing to do with validating signatures).

I'm not exactly sure what to do about those, or how much additional work would it be to adapt them for signature validations.

PR location Opt-out added by this PR Why it is a fixture workaround
AbstractKcSamlBrokerTest.java:247 wantAssertionsSigned=false; validateSignature=false already existed Its provider client emits unsigned SAML for general broker tests. The signature-focused tests deliberately override or remove the shared fixture settings.
SamlBrokerEmptyNameIdTest.java:234–235 Both settings Its mock IdP builds an unsigned response; the tests concern NameID and principal handling.
KcSamlUserSessionLimitsBrokerTest.java:133 wantAssertionsSigned=false; validateSignature=false already existed in the PR Its provider client emits unsigned SAML; the tests concern session limits.
KcSamlBrokerConfiguration.java:253 wantAssertionsSigned=false; validateSignature=false already existed Its provider client emits unsigned SAML for shared legacy broker tests.
BrokerTest.java:109–110 Both settings The helper supplies generally unsigned synthetic login responses for tests of response handling, expiry, and related behavior. testAnyNamespacePreservedInContext signs an assertion but does not configure its test signing key as trusted.
LogoutTest.java:717–718 Both settings Several logout tests first log in through a synthetic unsigned IdP response.
kc3731-broker-realm.json:74 wantAssertionsSigned=false; validateSignature=false already existed The corresponding provider-realm clients emit unsigned SAML; the tests concern IdP-initiated SSO.

.attribute("guiOrder", String.valueOf(i))
.build());
.attribute("guiOrder", String.valueOf(i));
if ("saml".equals(idpInfo[0])) {

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.

Signature validation opt-outs not required by the test.

.identityProviders(IdentityProviderBuilder.create()
.providerId(SAMLIdentityProviderFactory.PROVIDER_ID)
.alias("mysaml")
.attribute(SAMLIdentityProviderConfig.VALIDATE_SIGNATURE, "false")

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.

Signature validation opt-outs not required by the test.

.attribute(SAMLIdentityProviderConfig.POST_BINDING_AUTHN_REQUEST, "false")
.attribute(SAMLIdentityProviderConfig.BACKCHANNEL_SUPPORTED, "false")
.attribute(SAMLIdentityProviderConfig.ARTIFACT_BINDING_RESPONSE, "false")
.attribute(SAMLIdentityProviderConfig.VALIDATE_SIGNATURE, "false")

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.

Signature validation opt-outs not required by the test.

realm.identityProviders(IdentityProviderBuilder.create()
.providerId("saml")
.alias("mysaml")
.attribute("validateSignature", "false")

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.

Signature validation opt-out not required by the test.

.providerId("saml")
.attribute(SAMLIdentityProviderConfig.SINGLE_SIGN_ON_SERVICE_URL, "https://saml-idp-sso-service/")
.attribute(SAMLIdentityProviderConfig.POST_BINDING_AUTHN_REQUEST, "true")
.attribute(SAMLIdentityProviderConfig.VALIDATE_SIGNATURE, "false")

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.

Signature validation opt-outs not required by the test.

idp.setConfig(config);
}
idp.setConfig(config == null ? new HashMap<>() : new HashMap<>(config));
idp.getConfig().putIfAbsent("validateSignature", "false");

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.

Signature validation opt-out not required by any of the tests that are extending this abstract one.

.attribute(SAMLIdentityProviderConfig.NAME_ID_POLICY_FORMAT, JBossSAMLURIConstants.NAMEID_FORMAT_UNSPECIFIED.get())
.attribute(SAMLIdentityProviderConfig.SIGNATURE_ALGORITHM, SignatureAlgorithm.RSA_SHA256.name())
.attribute(SAMLIdentityProviderConfig.VALIDATE_SIGNATURE, Boolean.TRUE.toString())
.attribute(SAMLIdentityProviderConfig.WANT_ASSERTIONS_SIGNED, Boolean.FALSE.toString())

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.

Signature validation opt-out not required by any of the implementing test classes.

Copilot AI balanced review requested due to automatic review settings November 11, 2026 17:50

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 SAML signature-default hardening.

1 open issue

Review effort: Balanced

Copilot AI balanced review requested due to automatic review settings November 12, 2026 09:49

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

The review records no active issues with the SAML signature-default changes.

1 open issue

Review effort: Balanced

… omitted, relating to issue keycloak#53713

Closes keycloak#54749

Signed-off-by: Paddy Buckley <paddy.buckley@ibm.com>

# Conflicts:
#	docs/documentation/upgrading/topics/changes/changes-27_0_0.adoc
#	tests/base/src/test/java/org/keycloak/tests/broker/saml/KcSamlBrokerTest.java
Copilot AI balanced review requested due to automatic review settings November 16, 2026 14:43

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

Enabling XML signing in the shared fixture breaks existing issuer-validation and Redirect-signature test controls because consumers mutate assertions without re-signing or trust a different key.

2 open issues

Review effort: Balanced

Comment on lines +230 to +231
clientAttributes.put(SamlConfigAttributes.SAML_ASSERTION_SIGNATURE, "true");
clientAttributes.put(SamlConfigAttributes.SAML_SERVER_SIGNATURE, "true");
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.

SAML Default signature validation securely when settings are omitted

3 participants