Repository navigation
Only accept assertion-only signatures on a SAML Response - #55344
Open
naruto-lgtm wants to merge 1 commit into
Open
naruto-lgtm wants to merge 1 commit into
naruto-lgtm wants to merge 1 commit into
Conversation
XMLSignatureUtil.validate accepted a document with an unsigned root whenever every saml:Assertion in it was signed, whatever the root element was. An unsigned LogoutRequest carrying a genuine IdP-signed Assertion in its Extensions therefore passed signature validation. Restrict that fallback to a samlp:Response root or the single samlp:Response payload of an ArtifactResponse; other messages have to be signed at the root. Signed-off-by: Nayyar <nayyar@bugqore.com>
Contributor
There was a problem hiding this comment.
🔵 Needs a closer look
The shared SAML signature-acceptance changes require security-sensitive binding interoperability validation across broker, server, and adapter flows that could not be performed in this review environment.
No open issues 🎉
What changed in this PR
This PR tightens shared SAML signature validation so a signed assertion cannot authenticate an unsigned non-Response message, such as a LogoutRequest.
Changes:
- Restricts assertion-only validation to a SAML Response or the single Response payload of an ArtifactResponse.
- Adds a regression test for unsigned LogoutRequests containing signed assertions and compatibility tests for supported Response cases.
| File | Description |
|---|---|
saml-core/src/test/java/org/keycloak/saml/processing/api/saml/v2/sig/SAML2SignatureTest.java |
Adds rejection and compatibility tests using signed assertions. |
saml-core/src/main/java/org/keycloak/saml/processing/core/util/XMLSignatureUtil.java |
Gates assertion-only validation on the root or artifact payload message type. |
Review effort: Balanced
Unreported flaky test detectedIf 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.broker.KcSamlFirstBrokerLoginTest#testVerifyEmailRequiredActionWhenChangingEmailDuringFirstLoginKeycloak CI - FIPS IT (strict) org.keycloak.testsuite.broker.KcSamlFirstBrokerLoginTest#testFixDuplicationsByReviewProfileKeycloak CI - FIPS IT (strict) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Repro: with "Validate Signature" on for a SAML identity provider, POST to
/realms/{realm}/broker/{alias}/endpointan unsignedsamlp:LogoutRequestwith the brokerDestination, a victim'sNameID, and any genuine assertion signed by that IdP (for example the attacker's own login assertion, expired or not) copied unchanged intosamlp:Extensions. Every brokered session of the victim is logged out.Cause:
XMLSignatureUtil.validatefalls back to "the root is unsigned but everysaml:Assertionin the document is signed" for any root element, so the signed assertion stands in for the LogoutRequest it does not cover. The same fallback is reached bySamlServicefor POST/SOAP AuthnRequest, LogoutRequest, LogoutResponse and ArtifactResolve, and by the SAML adapter.Fix: keep that fallback only for a
samlp:Responseroot or the singlesamlp:Responsepayload of anArtifactResponse, which are the only messages where a signed assertion is what gets consumed and where both the POST and artifact bindings rely on it today. Every other message has to be signed at the root, matching what the Redirect binding already enforces through the query signature.SAML2SignatureTestgains a regression test for the wrapped LogoutRequest (fails before, passes after) and two guards for the assertion-only Response and ArtifactResponse cases; the SAML broker tests intests/basestay green.