fix: validate signatures on HTTP-POST bound messages#4
Merged
Conversation
extractSignature() only recognized SignatureStringReader (detached signatures used by the Redirect binding), so enveloped XML signatures carried by POST-bound messages were silently dropped and validateSignature() always threw "Invalid signature". Flatten SignatureXmlReader into the same value/algorithm/data shape by reading the raw SignatureValue and re-canonicalizing SignedInfo, then run reference/digest validation before the signature node gets detached from the document by validateReference(). A failed reference check is treated as no signature at all. Fixes #1 Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This was referenced Jul 2, 2026
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.
Summary
extractSignature()only recognizedSignatureStringReader(the detached signature used by the HTTP-Redirect binding), so the enveloped<ds:Signature>carried by HTTP-POST bound messages was silently dropped, makingvalidateSignature()always throwInvalid signaturefor POST-bound requests/responses (the most common SP flow: IdP posting a signed<Response>to the ACS endpoint).SignatureXmlReader: it is flattened into the samevalue/algorithm/datashape used for the Redirect binding, by reading the rawSignatureValueand re-canonicalizingSignedInfo— the same inputsXMLSecurityDSig::verify()itself relies on — sovalidateSignature()can verify both binding types through the same code path.validateReference()) is run to detect tampering with the signed content. It has to happen after the SignatureValue/SignedInfo are extracted, sincevalidateReference()detaches the<ds:Signature>node from the document (per the enveloped-signature transform), which would otherwise throw off canonicalization if done first. A failed reference check is treated the same as no signature at all.SignatureDTO shape is unchanged.Fixes #1