xml-crypto HMAC-SHA1 signature validation bypass via key confusion

Severity: info · Published 2020-10-27

xml-crypto is a Node.js library used to create and validate XML digital signatures, a critical component for securing XML-based data exchanges in applications like SAML authentication and financial systems. An attacker can craft a valid HMAC-SHA1 signature using only knowledge of the public key, allowing them to forge signatures and bypass validation checks that protect data integrity and authentication.

Technologies: xml-crypto (npm). Vendors: npm.

Quick answers

Is This vulnerability exploited in the wild?
No. Junglewise Threat Intelligence has no report of This vulnerability being exploited in the wild.
How severe is This vulnerability?
Informational severity, published 27 October 2020.
Which products and versions are affected?
xml-crypto (npm) SEMVER:introduced=0,fixed=2.0.0.
Is there a fix for This vulnerability?
Yes. xml-crypto (npm): upgrade to 2.0.0 or later. Junglewise finds every place you run it, drafts the upgrade and applies it once you approve.
How is This vulnerability attacked?
It is attacked over the network, in a software library.
Am I affected?
Check whether you run xml-crypto (npm) at an affected version. Junglewise does that check for you around the clock: connect your code, cloud and domains, and it matches new vulnerabilities like this one against what you actually run and tells you when one reaches you.

How to fix

  • xml-crypto (npm): upgrade to 2.0.0 or later
    npm install xml-crypto@2.0.0

Technical details

The vulnerability arises from a key confusion flaw where both HMAC and RSA-based signature algorithms use the same key variable, and the choice of algorithm is controlled by user input. An attacker can inject an HMAC-SHA1 signature that validates correctly using the RSA public key alone, without possession of the private key. This breaks the cryptographic assumption that HMAC validation requires knowledge of a secret key. The vulnerability affects xml-crypto versions up to and including 1.5.3; the fix in version 2.0.0 disables HMAC signature methods by default and requires explicit re-enablement via SignedXml.enableHMAC().

Affected products

  • node-saml xml-crypto < 2.0.0

Timeline

  • 2020-10-26: disclosed: Advisory GHSA-c27r-x354-4m68 published
  • 2020: patched: Fix released in version 2.0.0 with HMAC methods disabled by default

References

This page as Markdown. Free to reuse under CC BY 4.0 with a link back.