Skip to content

REF-26: Validate the SAML signature profile before trusting an assertion signature - #93

Merged
thomasnymand merged 1 commit into
masterfrom
feature/REF-26-assertion-signature-profile-validation
Aug 26, 2026
Merged

thomasnymand merged 1 commit into
masterfrom
feature/REF-26-assertion-signature-profile-validation

Conversation

@thomasnymand

@thomasnymand thomasnymand commented Aug 13, 2026 •

Copy link
Copy Markdown
Collaborator

Binds the assertion signature to the assertion the SP consumes.

Problem

AssertionValidationService.validateSignature called only SignatureValidator.validate(assertion.getSignature(), credential). That is a raw cryptographic check: it proves that some element in the document was signed with the IdP signing key from the configured metadata, but not that the signature covers the <Assertion> whose subject, attributes and NSIS level the SP then reads. A verifying signature was therefore not on its own sufficient grounds for trusting the identity data in the assertion, which is the core trust check of the authentication flow.

Secondary issue in the same method: assertion.getSignature() is null for an unsigned assertion, so SignatureValidator.validate(null, ...) threw an uncaught NullPointerException (HTTP 500) instead of a validation error. The assertion.isSigned() check that should have caught this ran at the end of validateAssertion, and only when oiosaml.servlet.profile.validation.enabled was true.

Changes

  • Run SAMLSignatureProfileValidator before the cryptographic check. It requires exactly one reference, restricts the transforms to enveloped-signature plus canonicalization, rejects Object children, and checks that the reference resolves to the element the signature is a child of — the binding that was missing.
  • Guard the signature up front. validateSignature now rejects an unsigned assertion (!isSigned() || signature == null) with an AssertionValidationException before touching it, so signing is enforced unconditionally instead of behind the profile-validation flag.
  • Removed the now-unreachable isSigned() check at the end of validateAssertion.

Trust is still anchored where it was: the verification credential is the signing certificate from the configured IdP metadata, and an embedded KeyInfo is not trusted.

Verification

Two regression tests in AssertionValidationServiceTest cover assertions whose signature verifies but is not bound to the element being consumed, one where the consumed assertion has its own ID and one where it reuses the ID of the referenced element. Each test first asserts that the signature still verifies under a raw SignatureValidator.validate, so it cannot pass for the wrong reason, and then asserts that validation rejects the assertion.

Checked in both directions:

  • With the production file reverted and the tests kept: both assertions pass validation. That is what this PR fixes.

@thomasnymand
thomasnymand force-pushed the feature/REF-26-assertion-signature-profile-validation branch 2 times, most recently from 68f07bd to 7efbea4 Compare August 13, 2026 11:26
…ion signature

validateSignature only called SignatureValidator.validate, a raw cryptographic
check that the signature verifies against the IdP signing certificate from the
configured metadata. It did not establish that the signature is bound to the
assertion the SP goes on to consume, so a verifying signature was not on its
own sufficient grounds for trusting the subject, attributes and NSIS level read
from that assertion.

Run SAMLSignatureProfileValidator before the cryptographic check. It requires
exactly one reference, restricts the transforms to enveloped signature plus
canonicalization, rejects Object children, and checks that the reference
resolves to the element the signature is a child of, which is the binding that
was missing. Trust is still anchored in the signing certificate from the
configured IdP metadata.

Also guard against a null signature up front: assertion.isSigned() was only
checked at the end of validateAssertion and behind the profile validation flag,
so an unsigned assertion reached SignatureValidator.validate(null, ...) and
failed with an uncaught NullPointerException instead of a validation error.
Signing is now enforced unconditionally in validateSignature, and that late,
now unreachable check has been removed.

Regression tests cover assertions where the signature reference does not
resolve to the consumed element. They assert that the signature still verifies
cryptographically, so they fail for the right reason and not because of a
broken signature.
@thomasnymand
thomasnymand force-pushed the feature/REF-26-assertion-signature-profile-validation branch from 7efbea4 to 2327f4f Compare August 13, 2026 11:30
@thomasnymand
thomasnymand requested review from mthiim and removed request for mthiim August 13, 2026 19:30
@thomasnymand
thomasnymand merged commit a419db1 into master Aug 26, 2026
2 checks passed
@thomasnymand
thomasnymand deleted the feature/REF-26-assertion-signature-profile-validation branch August 26, 2026 15:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants