Ruby-SAML / GitLab Authentication Bypass (CVE-2024-45409)
Ruby-SAML used an overly broad XPath expression to extract the DigestValue from a SAML response, allowing an attacker to smuggle a second DigestValue inside the samlp:Extensions element. This let an attacker bypass signature validation and forge a SAML assertion, gaining unauthorised access to applications such as GitLab.
httpvoid.com
Published on httpvoid.com
Note - This is cross post from our work at Projectdiscovery Blog
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 used the XPath expression //ds:DigestValue, which selects the first DigestValue anywhere in the document, instead of restricting the search to the SignedInfo block.
Impact
An attacker could bypass SAML authentication and gain unauthorised access to applications such as GitLab.
What the attacker needed
A valid SAML response from the IdP; ability to modify the SAML response
The fix
The vulnerability was fixed by tightening the XPath selector to avoid selecting DigestValue elements from anywhere in the document.
How it was found
- Insert a DigestValue of the modified assertion inside the samlp:extensions element.
- The XPath selector extracts this smuggled DigestValue instead of the one from the SignedInfo block.
- Since the SignedInfo block itself is not modified, it passes the signature check, but the actual assertion content could have been tampered with.
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 a login server to tell an application that a user is authenticated, using a signed digital document. The application checks the signature to make sure the document has not been changed. Here, the library looked for the digest value in the wrong place, so an attacker could put a fake digest earlier in the document and trick the application into accepting a modified login.
What is OAuth / SSO?
Mistakes in OAuth, OpenID Connect, SAML or token handling that leak codes and tokens or link an attacker's identity to a victim's account.