Inside the ruby-saml bypasses where two XML parsers read one login differently
Between September 2024 and December 2025, ruby-saml fixed five CVEs that let anyone holding one IdP-signed document log in as any user. A teardown of all three rounds: the wrong-signature XPath bug, the REXML-vs-Nokogiri split that GitHub Security Lab found, PortSwigger’s attribute pollution and void canonicalization, the matching xmlseclibs flaw, and what service-provider teams should change.
By The Xalgorix Team
Five CVEs in fifteen months, all in one Ruby gem, all with the same outcome. Between September 2024 and December 2025, ruby-saml, the SAML toolkit that GitLab and many other Ruby apps use (often through omniauth-saml), shipped fixes for CVE-2024-45409, CVE-2025-25291, CVE-2025-25292, CVE-2025-66567 and CVE-2025-66568. In each case an attacker who held a single document signed by the identity provider could build a SAML response for any user they liked and log in as that user.
The individual tricks differ. The root cause barely changes: the code that checked the signature and the code that decided who was logging in were looking at different parts of the XML, and in most of the 2025 bugs they were literally using different parsers. This teardown walks through the three rounds of fixes in order, then pulls out what a service-provider team should change whatever SAML library it uses.
What a service provider checks before it trusts a login
A SAML response arrives at your app (the service provider, or SP) as a base64 XML document posted by the user's browser. The user controls every byte of it. The only thing that makes it trustworthy is an XML Signature made with the identity provider's private key, and validating that signature is a multi-step dance:
The digest ties the assertion to SignedInfo; the signature ties SignedInfo to the IdP's key. The chain only holds if every step operates on the same nodes, and if the final step, reading the user's identity, reads from the element that was actually hashed. Break any link and you get XML Signature Wrapping (XSW), a class described in 2012 in the USENIX Security paper “On Breaking SAML: Be Whoever You Want to Be”. Older XSW attacks moved a genuinely signed assertion somewhere the verifier would still find it, and put a forged one where the app would read it. That needed a signed assertion, which is a high bar. The ruby-saml bugs lowered it.
Round one, September 2024: an incorrect XPath selector
CVE-2024-45409 was published on 10 September 2024. The GitHub advisory title is blunt: an authentication bypass “via Incorrect XPath selector”. NVD's description says ruby-saml up to 1.12.2 and 1.13.0 through 1.16.0 “does not properly verify the signature of the SAML Response”, and that an unauthenticated attacker with access to any signed SAML document from the IdP could forge a response with arbitrary contents. NVD scored it 9.8; GitHub, as the CNA, scored it 10.0. Fixes landed in 1.17.0 and 1.12.3.
The detail to hold onto is “any signed document”. A signed assertion for your own low-privilege account counts. So, depending on the IdP, do things that never look like logins at all, which becomes important in round three.
Round two, March 2025: two parsers, each checking half
Two more bypasses were reported to the maintainer on 14 November 2024: one by the researcher ahacker1, one by Peter Stöckli of GitHub Security Lab. The fixes shipped on 12 March 2025 as ruby-saml 1.18.0 and 1.12.4, alongside GitLab's critical patch release 17.9.2, 17.8.5 and 17.7.7. Stöckli's write-up, “Sign in as anyone”, explains the architecture that made them possible: during signature verification ruby-saml parsed the same response with two XML libraries, REXML (pure Ruby) and Nokogiri (libxml2), and used each for different steps.
# Simplified from the steps described by GitHub Security Lab
# (xml_security.rb, ruby-saml <= 1.17.0)
# Nokogiri view of the document
sig_node = noko_doc.at_xpath("//ds:Signature")
canon_string = canonicalize(sig_node.SignedInfo) # what gets verified
ref_node = noko_doc.xpath("//*[@ID=$id]")
hash = digest(canonicalize(ref_node)) # what gets hashed
# REXML view of the same bytes
rexml_sig = REXML::XPath.first(rexml_doc, "//ds:Signature")
signature_value = rexml_sig.SignatureValue # expected signature
digest_value = rexml_sig.SignedInfo.Reference.DigestValue # expected hash
ok = (hash == digest_value) && rsa_verify(signature_value, canon_string)Read the last line carefully. The hash comes from the node Nokogiri found; the value it is compared against comes from the SignedInfo REXML found. The signature is verified over Nokogiri's SignedInfo but read from REXML's. If an attacker can make the two parsers disagree about which Signature element comes first, the checks stop referring to the same thing.
That is what the two CVEs did. CVE-2025-25291 used a DOCTYPE-handling difference; CVE-2025-25292 used namespace handling, where a crafted namespace makes the same XPath query return different nodes in each parser (per the GHSL advisory). The attacker plants a second Signature that only one parser sees, for example inside StatusDetail. The genuine IdP signature, lifted from any document signed with the same key, satisfies the signature check, while the digest check compares against a value the attacker wrote and that, in Stöckli's words, “has no corresponding signature”.
Stöckli's long-term recommendation is the most useful line in the post: take the digest value from the SignedInfo that was already extracted and verified, rather than looking it up again. Done that way, the code would have been safe even with two parsers. Removing one parser was deferred to a future major release.
Round three, December 2025: an incomplete backport and a digest of nothing
Zakhar Fedotkin of PortSwigger Research then showed that 1.12.4 had not closed the class. His Black Hat Europe 2025 research, “The Fragile Lock” (published 10 December 2025), demonstrated a full authentication bypass against GitLab EE 17.8.4 and led to two advisories published on 9 December 2025, both affecting ruby-saml up to and including 1.12.4 and both fixed in 1.18.0:
- CVE-2025-66567, an incomplete fix for CVE-2025-25292: REXML and Nokogiri still build different document structures from the same namespace-laden input. Fedotkin's paper describes two techniques of this kind: attribute pollution, where namespace-agnostic lookups such as Nokogiri's
node["ID"]and REXML resolve a collidingID/samlp:IDpair in opposite orders, and namespace confusion, where REXML treats the reservedxmlnsandxmlprefixes as ordinary attributes, so aSignaturecan be visible to one parser and invisible to the other without any DTD. - CVE-2025-66568, “void canonicalization”: when libxml2's canonicalizer hits invalid input it may return an empty string instead of failing, and ruby-saml computed the
DigestValueover that empty string as if canonicalization had worked.
The second bug is the more unsettling one, because the hash of nothing is a constant. For SHA-256 it is always:
$ printf '' | openssl dgst -sha256 -binary | base64 47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=
Fedotkin triggers the canonicalization error with a relative namespace URI, something the XML Signature spec already warns is not operational in canonical form. As he puts it, “most implementations silently continue execution, treating the missing output as an empty or ‘void’ canonical form”. A digest check over a constant no longer binds the signature to any particular content, and combined with an IdP-signed document it yields what he calls a “Golden SAML Response”: one that keeps passing validation whatever claims the attacker changes.
Where the signed documents come from
Round three also widened the supply of raw material. Fedotkin lists sources of IdP-signed XML that require no account at all: signed SAML metadata (some IdPs sign it on request, for example with a ?sign=true parameter), signed error responses triggered by a malformed AuthnRequest (which can reflect attacker-influenced content), and publicly available WS-Federation metadata for major IdPs. When he raised this with Okta, the response was that changing its signing behaviour would violate the SAML and WS-Fed standards. In other words, the IdP will keep signing those documents; the SP has to stop being fooled by them.
The void-canonicalization behaviour was not unique to Ruby. Rob Richards' PHP library xmlseclibs had the same flaw, fixed in 3.1.4 on 8 December 2025 as CVE-2025-66578, and SimpleSAMLphp issued SSPSA 202512-01 (CVE-2025-66475) the same day. Fedotkin reports php-saml as affected too, and the XMLSec library and Shibboleth's xmlsectool as not affected.
One mistake in three costumes
Lay the five CVEs side by side and they reduce to a single invariant being broken in different ways: the bytes you verified must be the bytes you use.
Two lessons generalize beyond SAML. First, every re-lookup is an opportunity for an attacker to change the answer: once a verifier has found the signed node, it should hand that node to the caller rather than letting the caller go looking again by ID or XPath. Second, a security check that receives an empty or error result must fail, not continue. Silent fallbacks in a parser are a convenience; silent fallbacks in a signature verifier are an authentication bypass. The same instinct, refusing anything the parser had to guess about, is behind the XML parser hardening advice for XXE.
What to change in your service provider
Start with inventory, because SAML libraries tend to arrive as transitive dependencies:
# Ruby bundle exec gem list | grep -E "ruby-saml|omniauth-saml" # PHP composer show robrichards/xmlseclibs onelogin/php-saml simplesamlphp/simplesamlphp 2>/dev/null
- Patch to the versions that close all five. ruby-saml 1.18.0 or later; the December advisories list everything up to and including 1.12.4 as vulnerable, so a 1.12.x pin has to move. Check that omniauth-saml (or whatever wraps ruby-saml) actually resolves to it. On PHP, xmlseclibs 3.1.4 or later, and a current SimpleSAMLphp. For self-hosted GitLab, stay on a supported patch release; 17.9.2, 17.8.5 and 17.7.7 were the first to fix the round-two bugs.
- Read identity only from the verified element. If you maintain your own SAML handling, make the verifier return the node it hashed and take
NameID, attributes and conditions from that object, never from a fresh query over the whole document. OWASP's SAML Security Cheat Sheet puts it as rejecting assertions outside the validated signed content. - Fail closed on parser trouble. Reject any response with a DOCTYPE, parse errors (Nokogiri exposes them as
doc.errors; GitHub notes that checking them would have stopped at least one practical exploit), or an empty canonicalization result. - Validate against a strict schema with as few extension points as possible. Every exploit above parked its extra nodes in a place the schema allowed, such as
StatusDetailorExtensions. - Do not make access decisions on email suffixes alone. Fedotkin's real-world SaaS case combined the ruby-saml bypass with email-parser discrepancies to land in an account it should not have reached.
- Add compensating controls while you upgrade. GitLab's guidance for unpatched instances was app-side 2FA for all users, disabling the SAML two-factor bypass, and requiring admin approval for auto-created users. GitHub Security Lab knew of no reliable indicator of compromise and suggests watching for SAML logins from IP addresses that do not fit the user.
Testing an SP you are authorized to assess
Version checks tell you whether a known bug is present; they say nothing about the SAML code you wrote around the library, which is where the “re-lookup by ID” mistake usually lives. A meaningful test needs three things: a test IdP (or a test tenant) you are allowed to use, a low-privilege account on it, and an inventory of every document that IdP signs. SAML Raider covers the classic XSW permutations, and Fedotkin released a Burp extension, linked from his research post, that automates the newer techniques. A finding only counts when a forged response logs you into a second test account you control; a parser warning or an accepted-but-ignored response is a lead, not a result.
That last point is where automated tools, Xalgorix included, need honest limits. An autonomous tester can fingerprint ruby-saml versions, replay and mutate responses, and check whether a forged NameID lands in a different session, but it cannot conjure a signed IdP document out of nothing, and it should never be pointed at a production IdP without the owner's consent. Treat SAML as a feature where a human sets up the trust relationship and the tooling does the tedious permutations.
Ready to see it prove a bug?
Start scanning on Cloud →