Skip to content
Account takeover Write-up Advanced

SAMLStorm: Critical Authentication Bypass in XML-crypto and Node.js libraries

A vulnerability in the xml-crypto library caused SAML assertion digest checks to use a forged digest placed in an XML comment, while signature checks ignored comments, allowing attackers to forge SAML responses and gain unauthorised access to any account, including admin accounts, without user interaction.

workos.com

Published on workos.com

Any service using xml-crypto or a Node.js SAML implementation using it, should update immediately to the latest version. WorkOS customers are safe and were not impacted.

The author, on workos.com

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

How it worked

Root cause

The library checked the assertion digest on the non-canonicalized document (which keeps comments) but checked the signature on the canonicalized document (which strips comments), so an attacker could insert a forged digest in a comment that the digest check used while the signature check still passed.

Impact

An attacker could forge SAML assertions to gain unauthorised access to any user account, including admin accounts, without user interaction, potentially leading to full account takeovers; WorkOS patched within 24 hours and found no evidence of past compromise.

What the attacker needed

Service provider uses xml-crypto; attacker has a valid signature and digest pair; service provider trusts IdP certificate; attacker knows ACS URL, SP Entity ID, IdP Entity ID

The fix

The vulnerability was fixed in xml-crypto v6.0.1 (backported to v3.2.1 and v2.1.6), and WorkOS patched all customers within 24 hours.

How it was found

  1. Go to the target app using an email that redirects to an identity provider with publicly signed metadata.
  2. When attempting to sign in, pull the ACS URL and SP Entity ID from the SAML request.
  3. Pull the certificate and signature info, as well as the IdP Entity ID, from the public metadata.
  4. Craft a SAML response with the certificate and signed value from metadata.
  5. Modify the SAML assertion and recalculate the DigestValue, inserting it as a comment before the existing digest value.
  6. Send a request with the crafted SAML response to the ACS URL; the service provider validates it and you are authenticated.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

SAML is a way for websites to let you log in using an external identity provider. This bug let an attacker trick the website into accepting a fake login message, so they could log in as anyone, even an administrator, without needing a password.

What is Account takeover?

Getting into someone else's account through a flaw in sign-in, password reset, second factor, single sign-on or session handling.

Similar reports

View all

Same bug class and techniques, clearest first.

Account takeover

The lesson behind this report.

Getting into someone else's account through a flaw in sign-in, password reset, second factor, single sign-on or session handling.