node-saml / xml-crypto

Xml digital signature and encryption library for Node.js
MIT License
198 stars 172 forks source link

Multiple signature problem by OKTA SAMLResponse #223

Open H-D-Choi opened 3 years ago

H-D-Choi commented 3 years ago

There is an option to sign double the assertion in OKTA. But xml-crypto has a rule which SAMLResponse has to has only one signature. Therefore it can't be validated due to that reason. How and Could I contribute here to solve this problem?

cjbarth commented 1 year ago

Thank you for identifying this condition @H-D-Choi . Please create a PR with a test suite and we'll check the code over and get it landed.

srd90 commented 11 months ago

@H-D-Choi your issue report speaks about "sign double the assertion" and it also speaks about xml-crypto not being able to validate SAMLResponse which has more than one signature.

I.e. you are mixing multiple assertion signature and SAML Response signature into same report. One possibility is that you are seeing SAML response which has top level (Response) signature and signed assertion.

It is business as usual that SAML authentication response can have two signatures (if IdP is configured to sign Response and Assertion). In business as usual case one signature would cover Response (and also assertion due to assertion being child of Response) and second one would cover only Assertion.

OKTA's documentation https://help.okta.com/en-us/content/topics/apps/aiw-saml-reference.htm (link referenced 02 Nov 2023) provides only these possibilities at Advanced Settings section:

Response | Choose whether the IdP digitally signs the SAML authentication response message. Assertion Signature | Choose whether the SAML assertion is digitally signed.

i.e. there doesn't seem to be any option to "sign assertion twice" but there seems to be possibility to configure signing of Response and signing of Assertion.

Have you perhaps enabled Response and Assertion signing (i.e. both) and are you perhaps using some (catch all signatures from any nesting level) xpath statement which loads all Signature elements to be used for validation or something like that.

Here are two different SAML libraries approach to validate signatures with xml-crypto (both support aforementioned scenario):