fixes #78: make sure the correct Signature elements are verified#79
Conversation
miszobi
commented
Sep 16, 2016
- checks that the found Signature elements match their expected schema locations, and that there's only one of each
- make sure the expected Signatures are always verified
- a few other small hardenings
…verified - checks that the found Signature elements match their expected schema locations, and that there's only one of each - make sure the expected Signatures are always verified - a few other small hardenings
| <saml:Issuer>https://pitbulk.no-ip.org/simplesaml/saml2/idp/metadata.php</saml:Issuer> | ||
| <samlp:Extensions> | ||
| <saml:Response ID="fakeSignature"> | ||
| <ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#"> |
There was a problem hiding this comment.
This signature was found by processSignedElements, and the validation considered the Response signed, but subsequently wasn't validated by validateSign, because that one was looking for the Signature in the expected place. validateSign still passed, because the Assertion signature was okay, and it only required one of the signatures to be valid.
|
Let me the weekend to review the PR and maybe find an alternative solution, and let's push that and more tests to prevent it on monday. |
|
The only strictly required part is the one in The others are general security hardening fixes: using absolute xpaths where applicable, making sure the nodes we expect a single occurrence of actually appear only once - all these are good practices, as recommended by OWASP (also here) |
|
I'm agree with the improvement except the change of the validateSign method and the checkSignature method. Can we do the wantResponseSigned & wantAssertionSigned check on the processSignedElements instead doing that at the validateSign method? And leave the validateSign: |
|
I can drop the wantResponseSigned & wantAssertionSigned parameters from However the proposed implementation of lines 637-640:
lines 1562-1565:
So I believe we should go with something like: |
|
If you validate the integrity of the container (Response), the Assertion (signed or not) included should be considered correct too. |
|
True, but the spec does specifically say each MUST be checked if present. I see it as an additional defense-in-depth check, where even if the attacker could for example wrap the Response signature, the Assertion signature will also be checked. Any reasons for not doing it this way? |
|
Only the over cost. I understand that the spec says that, but maybe because the doc contains a non-related definition of each element |
|
Also take in mind that when the encryption appears on the assertion, the signature validation is not that easy:
|
|
Right. So maybe instead of calling As for performance, using a simple benchmark of running the assertions in However note that each of those tests runs validation 12 times, so that's 12000 validations, changing the per-validation cost from ~68ms to ~82ms. Seeing as during authentication the caller is usually dealing with several http requests and redirects, I don't think this is really notable. Also as mentioned above we'd be following the spec on this, and adding some extra verifications to the authentication process. |
|
Ok, sound reasonable. validateSign can validate a specific signature, based on the doc and the path. |
…e right document - validateSign now simpler, takes an xpath for the Signature to verify - added some tests for encrypted assertions, that require either the Response and/or Message sign, to verify
|
Updated as discussed. |