Executive brief
xml-crypto is a Node.js library used for digital signatures and encryption in XML documents, often used in authentication systems like SAML. A vulnerability in its default configuration allows attackers to bypass security checks by providing their own untrusted certificate within a malicious document. This could allow an attacker to spoof digital signatures, potentially leading to unauthorized access or the ability to submit fraudulent data that the system treats as authentic.
Technical details
The vulnerability exists in xml-crypto versions 4.x and 5.x due to the default behavior of the getCertFromKeyInfo method. By default, the library extracts and trusts any X509Certificate found in the <KeyInfo /> element of a signed XML document, even if a specific publicCert was explicitly configured for verification. An attacker can exploit this by re-signing a document with a malicious private key and attaching the corresponding certificate to the XML. The library will prefer the attacker-supplied certificate over the trusted one, resulting in a successful signature validation of a spoofed payload. This was addressed in version 6.0.0 by disabling the implicit usage of the default certificate extraction logic.
Affected products
- node-saml xml-crypto >= 4.0.0, < 6.0.0
Timeline
- 2023-06-17: other: Vulnerability introduced in version 4.0.0 via PR 301
- 2024-05-01: advisory: GitHub Security Advisory published
- 2024-05-01: patched: Fixed in version 6.0.0
References
- https://github.com/node-saml/xml-crypto/security/advisories/GHSA-2xp3-57p7-qf4v
- https://github.com/node-saml/xml-crypto/pull/301
- https://github.com/node-saml/xml-crypto/pull/445
- https://github.com/node-saml/xml-crypto/commit/21201723d2ca9bc11288f62cf72552b7d659b000
- https://github.com/node-saml/xml-crypto/commit/c2b83f984049edb68ad1d7c6ad0739ec92af11ca
- https://github.com/node-saml/xml-crypto