-
Notifications
You must be signed in to change notification settings - Fork 183
Add implicit C14N when signing if no transforms specified #503
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
base: master
Are you sure you want to change the base?
Conversation
It seems the SAML spec does support this as an option:
My concern is that while this may improve things for some users, it will break them for others, as it changes a default behavior. There are reports-- I'm not sure if they are current-- that ADFS may have problems and some Java-based servers may have problems as well. That concern could be addressed if the new behavior was opt-in, or if there was evidence that would help in more cases then it might break. if (this.options.enableImplicitCanonicalisation !== false) {
// Apply implicit transform
} |
transforms.length === 0 || | ||
transforms[transforms.length - 1] === "http://www.w3.org/2000/09/xmldsig#enveloped-signature" | ||
) { | ||
transforms.push("http://www.w3.org/TR/2001/REC-xml-c14n-20010315"); |
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.
Wouldn't exclusive C14N be more compatible?
transforms.push("http://www.w3.org/2001/10/xml-exc-c14n#");
First of all: I'm not XMLSIG expert. @markstos Lets put case SAML aside for a moment and investigate XMLSIG... xml-crypto already applies implicit Algorithm seems to be that:
Other tools seems to apply symmetrically similar automatic C14N See e.g. #212 (comment) and #212 (comment) . Side note: xml-crypto provides functionality to introduce one or more "API user defined" implicit transforms prior to validating signature Lines 649 to 654 in d295ecc
Those are applied to the end of transforms list and after that code proceeds to check whether "overall list of transformas at validation phase" should contain also http://www.w3.org/TR/2001/REC-xml-c14n-20010315 C14N:Lines 656 to 667 in d295ecc
Signing (with xml-crypto) requires always explicitly defined transforms (i.e. visible at signature element's transforms structure). About SAML aspect: e.g.
So...it seems that at least SAML case is covered even if automatic implicit My point is that evidence shows that lack of implicit Maybe @ahacker1-securesaml has some insight to share to this PR/discussion especially if work with new validation / signing functionality is still in active phase. random sidenote: interesting piece of history at this issue lsh123/xmlsec#841 (comment) |
a) We should apply the However, I disagree with the method that this is implemented in the PR and library. We should avoid adding implicit transforms (like in the PR and how it was previously implemented). Instead, we should:
This is same method as how Santuario does it. Internally, they create a function for each transform that accepts XMLSignatureInput: octets | Node-Set, then transforms depending on it. Conclusion: |
When signing, the library currently does not apply any canonicalization to the referenced document being signed, unless explicitly specified in the
transforms
config property.This behaviour differs from many other XML signature libraries such as javax.xml.crypto.dsig and signxml, who implicitly apply
http://www.w3.org/TR/2001/REC-xml-c14n-20010315
if the user does not specify any canonicalization transforms.This PR proposes adding the same implicit canonicalization behaviour, to make the output more consistent with other implementations.
Related issues: #210 #212 #484 #486