-
Notifications
You must be signed in to change notification settings - Fork 170
Prevent error when an EncryptedAssertion is next to the Signature in the document root. #69
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…s next to the Signature in the document root.
|
Any update on this? |
|
+1 |
|
@XavierTalpe @sebakerckhof Sorry about the delay here - We'll take a look at this today. |
| else | ||
| return cb_wf new Error( "Signed data does not contain a SAML Assertion!" ) | ||
| else if signatures_from_response | ||
| decrypted_assertion_dom = (new xmldom.DOMParser()).parseFromString(decrypted_assertion) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry about the delay of this review; I was on vacation and didn't have a chance to look it over.
I think there's a potential security pitfall here. Specifically, the fact that signatures_from_response is set only means that the response contains some signature, but this line is parsing the decrypted assertion and passing it on as validated. The signature may not have covered the encrypted assertion (or unencrypted assertion) of the response and this means it would accept invalid data.
I'm not sure what the best fix is for this. It seems like either it would have to be decrypted again from the signed data or some reference would have to be maintained and checked that the assertion was part of the signed data. It's also possible I'm misunderstanding this logic so please let me know if that is the case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll take a look at this in one of the coming days.
|
+1 |
I came across an issue when the SAML login response has the following structure:
Note that both the EncryptedAssertion and the Signature block are part of the root node. The EncryptedAssertion also does not contain any Signature elements after decryption.
The current version of the code fails with the error Signed data did not contain a SAML Assertion!.
This bug is caused by the combination of
and
In case the EncryptedAssertion block does not contain any Signatures,
check_saml_signature(result, cert)will fail andcheck_saml_signature saml_response_str, certis executed to retrieve the Signatures from the original SAML response. Because this SAML response still contains the EncryptedAssertion,getElementsByTagNameNS(XMLNS.SAML, 'Assertion')will fail.I modified the code so it can handle each use case. I looked into adding a test but this seems a bit trickier than expected because I can't use the original SAML response (company privacy/security).
My apologies if I overlooked something, I'm not a SAML expert :).