-
Couldn't load subscription status.
- Fork 190
Update README.md to reflect getCertFromKeyInfo changes #470
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
Changes in node-saml#445 was not reflected in the documentation. This PR fixes it.
|
@dozgunyal , would you be open to changing your PR to remove the |
|
@dozgunyal , are you willing to make the adjustments? |
WalkthroughSwapped defaults for two SignedXml options in documentation: Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~2 minutes
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
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.
Actionable comments posted: 0
🧹 Nitpick comments (2)
README.md (2)
264-264: Clarify the meaning of "noop" default value.The term "noop" is not immediately clear to all users. Based on the example at line 153 (
getCertFromKeyInfo: () => null), "noop" appears to mean a function that returnsnullor does nothing. Consider clarifying this term or using more explicit language like "function that returns null" or "disabled by default".Apply this diff to improve clarity:
-- `getCertFromKeyInfo` - function - default `noop` - a function that returns the certificate from the `<KeyInfo />` node +- `getCertFromKeyInfo` - function - default `noop` (disabled; must provide your own implementation) - a function that returns the certificate from the `<KeyInfo />` node
264-264: Add explicit security warning about CVE-2024-32962.The past review discussion (PR #445 context) identified a critical security vulnerability (CVE-2024-32962 / GHSA-2xp3-57p7-qf4v) when
SignedXml.getCertFromKeyInfois used. While the default is now correctly set tonoop, users could still manually configure the vulnerable implementation. The documentation should include an explicit security warning to prevent misuse.Consider adding a security note near the
getCertFromKeyInfooption or in a dedicated security section. For example:- `getCertFromKeyInfo` - function - default `noop` - a function that returns the certificate from the `<KeyInfo />` node +- `getCertFromKeyInfo` - function - default `noop` - a function that returns the certificate from the `<KeyInfo />` node + **Security Warning:** Do **not** use `SignedXml.getCertFromKeyInfo` for this option, as it allows XML signatures to be validated with arbitrary certificates, bypassing the chain of trust. This would trigger CVE-2024-32962 / GHSA-2xp3-57p7-qf4v. Provide your own safe implementation if needed.
Hi, sorry, I will try to send it this weekend. |
|
Hi @cjbarth, Unfortunately, I do not agree with all of your concerns and I think this function is still a good helper. Before I start the my explanation, I would like to tell you that I am going to close this PR and will not contribute more because I do not think that I have the relevant competence and I lack the vision of you contributors. I am sorry if I wasted your time and energy but I am still glad that I bring this one to your attention. Why I think removing this function is not necessary: As per the standard:
Firstly, I think, these bring legitimacy to obtaining key from the KeyInfo, if only the certificate is strong enough and validated properly. The project that I was working at the time was also depending on this implementation. My suggestion would be extending the library documentation to highlight the importance of the validation of cert but keep this function. But again, I respectfully refuse to take this responsibility. Kindest regards to all. |
|
@dozgunyal , you are right, it is within spec to have the library return the KeyInfo, but we want the default to be |
|
@dozgunyal you wrote:
Have you checked implementation of getCertFromKeyInfo?
it is not showstopper to (re)implement by person who is at the same time capable to understand security concerns related to using cert that is controllable by attacker. I.e. person who is capable to construct some proper validation (*) for cert is most likely capable to extract it from provided KeyInfo node. (*) e.g. by checking that extracted cert is signed by some very specific corporate internal CA cert (I try to say that one should not trust all public CAs because attacker could order his/her own cert from the market and use associated key and signed cert to resign xml document) or that cert is listed at some corporate directory server to be trusted for signing (this would be equal to checking that extracted cert is at some list of trusted certs) @cjbarth I did not spot from #506 change that would require specifically aforementioned footgun implementation (at public production API). Someone shall configure his/her stack to use it and is going to be very happy that now all (and I mean all) signed documents with attached certs are considered properly signed because it is less common to test incorrectly signed cases (test case that attacker resigned doc). It is more common to test only so called "happy cases". Situation was similar with passport-saml when one was able to disable cert checking completely by not providing cert at all / setting it to falsy, here is one starred gist of such approach: https://gist.github.com/fuxingloh/4d6e1caa24237c5870809fe24c47726f ( gist was fixed Aug 22, 2022 but it provided very unsecure config between years 2017 - 2022 https://gist.github.com/fuxingloh/4d6e1caa24237c5870809fe24c47726f/revisions ). There was also other similar cases. I thought that footgun getCertFromKeyInfo was on its way out: https://github.com/node-saml/xml-crypto/pull/470/files#r1591640940 https://github.com/node-saml/xml-crypto/pull/470/files#r2219669880 |
|
Yes we should remove the footgun I understand that sometimes, users do need to override the implementation of getCertFromKeyInfo. However, none of these cases, should or would involve using the untrusted certificate from the key info node verbatim. We should provide sample known functions for: getCertFromKeyInfo (and remove default implementation). For example: getCertFromTrustedCert(cert) { getCertFromTrustedFingerprint(fingerprint) { getCertFromTrustedCA(ca) { These should cover all the legitimate use cases. Default should be I'm not sure what use case @dozgunyal had. I'm pretty sure it falls into the 3 above. I agree with @srd90 analysis about footgun. I would like to point out xmlsec1 had a similar recurring problem, where they trusted the certificate inside the attacker supplied keyinfo node by default. It has lead to several authentication bypasses, affecting big applications. Regarding @dozgunyal statement on the spec:
We should be following secure by default standards. This specification is poorly written (no wonder the number of bugs in XML signature), we shouldn't follow this advice. The spec shouldn't mean that we should trust attacker supplied certificates by default. It means we have to provide a mechanism for clients to verify with a trusted certificate, and that the specification doesn't detail it (it should have given examples like above). Regarding @cjbarth statement on the signed keyinfo:
Signing keyinfo doesn't do anything here. Here, the problem is concerning using an untrusted certificate (i.e. from the keyinfo node), to verify the XML signature. Even if the keyinfo node is signed, we would be verifying it with the same untrusted certificate (from |
|
Thank you to both @ahacker1-securesaml and @srd90 for your comments. I've gone back and forth on this many times, reading the spec, and then listening to your expertise. I can easily see a scenario by which that So, for right now, we certainly want to get the documentation updated to reflect what is really going on. In the next breaking release I can certainly see removing it because we have no intention of dealing with certificate chains and revocation. Still, I can see internal applications that would use their own certificate to sign something and send it. In that case, the signature would prove only that the payload hasn't changed since it was signed with the provided key. In that case, when coupled with certificate inspection, a thusly signed XML document could be shown to be approved by the signer, no matter who generated the original XML. (I will process all the XML documents generated by a desktop in our domain, and each one will sign it with its own cert and include that in So, maybe I'm missing something, but the problem isn't really that the cert comes from the XML, it is that, without inspecting the cert, we shouldn't trust it as I understand @srd90 also says. So, by removing this stub code, we are forcing them to write code that both pulls the |
Changes in #445 was not reflected in the documentation.
This PR attempts to fix it.
Summary by CodeRabbit