Repository navigation
Updating SAML defualt signature validation securely when settings are… - #54766
PadzerButch wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
🟡 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")); |
There was a problem hiding this comment.
@PadzerButch The documentation is missing. (Not present in any of the 3 stacked PRs.)
tkyjovsk
left a comment
There was a problem hiding this comment.
@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])) { |
There was a problem hiding this comment.
Signature validation opt-outs not required by the test.
| .identityProviders(IdentityProviderBuilder.create() | ||
| .providerId(SAMLIdentityProviderFactory.PROVIDER_ID) | ||
| .alias("mysaml") | ||
| .attribute(SAMLIdentityProviderConfig.VALIDATE_SIGNATURE, "false") |
There was a problem hiding this comment.
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") |
There was a problem hiding this comment.
Signature validation opt-outs not required by the test.
| realm.identityProviders(IdentityProviderBuilder.create() | ||
| .providerId("saml") | ||
| .alias("mysaml") | ||
| .attribute("validateSignature", "false") |
There was a problem hiding this comment.
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") |
There was a problem hiding this comment.
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"); |
There was a problem hiding this comment.
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()) |
There was a problem hiding this comment.
Signature validation opt-out not required by any of the implementing test classes.
f345a53 to
b187f78
Compare
b187f78 to
12d7898
Compare
… 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
12d7898 to
2d81b3f
Compare
There was a problem hiding this comment.
🟡 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
| clientAttributes.put(SamlConfigAttributes.SAML_ASSERTION_SIGNATURE, "true"); | ||
| clientAttributes.put(SamlConfigAttributes.SAML_SERVER_SIGNATURE, "true"); |
Relating to issue #53713
Closes #54749