GitLab Enterprise admin login can be bypassed without auth via ruby-saml round-trip bug
Exploiting round-trip and namespace-confusion flaws in the ruby-saml library enables unauthenticated administrator access to GitLab Enterprise.
Security & privacy PortSwigger Research 18 Mar 2025 Attack Prototype evidence
Published as “SAML roulette: the hacker always wins”
Why it matters
If unpatched, GitLab installations using ruby-saml could be taken over by attackers without any credentials.
Summary
The researchers built a testbed to probe ruby-saml’s handling of XML round-trip parsing and discovered that mutations introduced via SYSTEM identifiers and DOCTYPE !ATTLIST declarations cause REXML and Nokogiri to diverge. By crafting a SAMLResponse that exploits this divergence and a namespace-confusion trick, they can bypass signature validation and forge assertions. Using publicly available WS-Federation metadata signed with the target’s certificate, they demonstrate unauthenticated admin login to GitLab Enterprise. The write-up includes PoC code and notes that the vulnerabilities were patched in specific GitLab versions.
What they found 3
- XML comments and CDATA can be used to alter document structure during mutation, bypassing signature verification.
“By leveraging XML comments and CDATA sections, an attacker can manipulate the document’s structure during mutation, bypassing signature verification and effectively gaining unauthorized access by assuming another user's identity.”
- The crafted vector allows exploitation of any application using Ruby-SAML, enabling login as any user.
“This vector allowed exploitation of GitLab and any other application using the Ruby-SAML library by manipulating the document and forging assertions, effectively enabling an attacker to log in as any user.”
- Inconsistent handling of XML validation between parsers lets attackers manipulate signature verification.
“The vulnerability stems from inconsistencies in how different XML parsers handle document validation, allowing an attacker to manipulate signature verification.”
Caveats 4
- Finding a valid signed XML document can be challenging. Fortunately, Identity Providers (IdPs) silently support Single Sign-On protocol: WS-Federation by default for every tenant.
- Before Ruby 3.4.2, REXML truncated !ATTLIST strings in doctype declarations, making the exploit fragile.
- The attack requires a signed XML document with a matching certificate, which may be hard to obtain.
- While Namespace Confusion alone can exploit Ruby-SAML, it faces one limitation: REXML's poor handling of XML marshalling/unmarshalling introduces another round trip issue.
What’s new here 4
- Discovery of a round-trip mutation via quoted SYSTEM identifiers that changes XML parsing outcome.
- Namespace-confusion attack using DOCTYPE !ATTLIST to create conflicting namespace declarations between REXML and Nokogiri.
- Combination of both bugs to achieve unauthenticated administrator access to GitLab Enterprise.
- A reusable testbed for evaluating round-trip vulnerabilities across SAML libraries.