# SAML Attacks
> SAML attacks forge or replay a SAML assertion so the service provider (SP) logs the attacker in as someone else. They nearly always exploit a gap between the XML the signature check validated and the XML the application then reads as identity.
## How it works
The IdP sends a signed XML assertion saying "this is user X". For it to mean anything, the SP has to establish three things:
1. A **trusted** IdP key produced the signature.
2. The signature covers **the exact element** the SP reads `NameID` and attributes from.
3. The assertion is **for this SP, fresh, and unused** (`Audience`, `Recipient`/`Destination`, `NotBefore`/`NotOnOrAfter`, `InResponseTo`).
Most real bugs break (1) or (2). XML makes this easy. Several elements can match the same lookup, ID attributes are ambiguous, namespace handling and canonicalization (C14N) differ between parsers, and many libraries run two parsers in one code path. Trail of Bits argues SAML is "a fractal of bad design" built on XML-DSig validation that most implementations delegate to libxmlsec ([[raw/blog.trailofbits.com/saml-a-fractal-of-bad-design-12072|Trail of Bits]]). The classes from the 2012 USENIX "On Breaking SAML" paper keep coming back ([[raw/usenix.org/usenix-on-breaking-saml-be-whoever-you-want-to-be-3884|USENIX]]). By volume and severity SAML has the worst record of the SSO protocols, with XSW recurring in 2012, 2018 and 2024 ([[raw/guptadeepak.com/sso-protocol-security-critical-vulnerabilities-in-saml-oauth-oidc-jwt-4718|survey]]).
Mechanism families:
- **XML Signature Wrapping (XSW)**: the legitimately signed element stays in the document so verification passes, while an attacker-added assertion sits elsewhere and is what the identity-reading code resolves to. Variants differ by where the signed and injected elements are placed (Response vs Assertion wrapping, ID manipulation, namespace abuse) ([[raw/ibm.com/ibm-what-is-xml-signature-wrapping-3883|IBM]]). The attacker needs only one validly signed document from the IdP ([[raw/endorlabs.com/cve-2025-47949-samlify-saml-sso-bypass-4100|samlify]]).
- **Parser differentials**: two parsers disagree about which element is "the" signature or assertion. In ruby-saml, REXML extracted the `DigestValue` and Nokogiri extracted the `SignedInfo`/assertion. A valid signature verified one thing, and a fabricated assertion was hashed against an unsigned digest ([[raw/github.blog/sign-in-as-anyone-bypassing-saml-sso-authentication-with-parser-differ-4101|GitHub Security Lab]]).
- **Canonicalization failures**: PortSwigger's *Void Canonicalization*. When C14N errors (for example on a relative namespace URI), most libraries continue with an empty canonical form instead of failing, so the digest is computed over nothing. Signed IdP documents that are public (metadata, signed error responses, WS-Fed metadata) can then supply the signature ([[raw/portswigger.net/the-fragile-lock-novel-bypasses-for-saml-authentication-portswigger-re-3898|The Fragile Lock]]).
- **Signature exclusion / untrusted signer**: the SP accepts a message with no signature, or a signature from any key rather than the configured IdP certificate ([[raw/epi052.gitlab.io/epi052-how-to-hunt-bugs-in-saml-a-methodology-part-ii-3882|epi052]], [[raw/security.paloaltonetworks.com/cve-2020-2021-pan-os-authentication-bypass-in-saml-4533|PAN-OS]]).
- **Encryption/verification ordering**: encrypted assertions get decrypted and consumed without the signature binding the decrypted content ([[raw/projectdiscovery.io/github-enterprise-saml-authentication-bypass-cve-2024-4985-cve-2024-94-4102|GHE]], [[raw/sentinelone.com/cve-2026-2092-keycloak-auth-bypass-vulnerability-4953|Keycloak]]).
- **Context checks**: a missing `AudienceRestriction` check lets an assertion minted for another SP be replayed ([[raw/github.com/kong-gateway-enterprise-saml-plugin-does-not-enforce-audiencerestricti-14138|Kong]]). An unsigned `RelayState` used to correlate the flow allows login CSRF ([[raw/github.com/social-core-login-csrf-in-saml-callbacks-via-relaystate-15352|social-core]]).
- **XML-processing side effects**: DTDs and external entities in the parser (XXE/DoS) on the unauthenticated ACS endpoint ([[raw/workos.com/fun-with-saml-sso-vulnerabilities-and-footguns-workos-4536|WorkOS]]). Appliance SAML parsers have also been memory-safety sinks ([[raw/workos.com/saml-rough-quarter-five-critical-vulnerabilities-in-four-months-4958|WorkOS]]).
## What to check
- [ ] Inventory the SAML library and version used on the SP, including transitive dependencies (omniauth-saml → ruby-saml, etc.), and check them against the cases below.
- [ ] Does the SP reject responses and assertions with **no** signature? With a signature from a self-signed, non-IdP cert?
- [ ] Is the element consumed for identity the same node (by ID or reference) that the signature covers? Run the XSW variants with SAML Raider or an equivalent ([[raw/epi052.gitlab.io/epi052-how-to-hunt-bugs-in-saml-a-methodology-part-ii-3882|epi052 methodology]]).
- [ ] Does the code path use more than one XML parser, or re-parse after verification?
- [ ] Is a canonicalization or transform error fatal, or silently ignored?
- [ ] Is schema validation strict, with minimal extension points? Are DTDs and external entities disabled? Is payload size limited?
- [ ] Are `Audience`, `Recipient`, `Destination`, the validity window and `InResponseTo` enforced? Is there a replay cache for assertion IDs?
- [ ] With encrypted assertions, is the signature checked over the decrypted assertion that is actually consumed?
- [ ] Is `RelayState` treated as untrusted (open redirect, login CSRF, session restoration)?
- [ ] On appliances: are "validate IdP certificate" style options enabled? Is vendor cloud-SSO auto-enabled?
## Notable cases
- **ruby-saml ≤1.17.0 (CVE-2025-25291/25292)**: a REXML vs Nokogiri differential. One valid signature from the target IdP let an attacker log in as any user. Fixed in 1.18.0 ([[raw/github.blog/sign-in-as-anyone-bypassing-saml-sso-authentication-with-parser-differ-4101|GitHub Security Lab]]).
- **The Fragile Lock (CVE-2025-66567/66568)**: attribute pollution, namespace confusion and Void Canonicalization in the Ruby and PHP SAML stacks. Demonstrated against GitLab EE 17.8.4 ([[raw/portswigger.net/the-fragile-lock-novel-bypasses-for-saml-authentication-portswigger-re-3898|PortSwigger]], [[raw/workos.com/saml-rough-quarter-five-critical-vulnerabilities-in-four-months-4958|WorkOS]]).
- **samlify <2.10.0 (CVE-2025-47949)**: signature wrapping in a widely used Node.js library, allowing arbitrary user impersonation ([[raw/endorlabs.com/cve-2025-47949-samlify-saml-sso-bypass-4100|Endor Labs]]).
- **GitHub Enterprise Server (CVE-2024-4985 / CVE-2024-9487)**: signature verification bypass with the optional encrypted-assertions feature. It needed a follow-up fix ([[raw/projectdiscovery.io/github-enterprise-saml-authentication-bypass-cve-2024-4985-cve-2024-94-4102|ProjectDiscovery]]).
- **Keycloak**: an encrypted assertion injected into an unsigned response (CVE-2026-2092) ([[raw/sentinelone.com/cve-2026-2092-keycloak-auth-bypass-vulnerability-4953|SentinelOne]]). The SAML broker also replayed signed assertions without holder-of-key verification (GHSA-486h-gxch-8c4x) ([[raw/github.com/keycloak-saml-identity-broker-authentication-flaw-high-13859|advisory]]).
- **PAN-OS (CVE-2020-2021, CVSS 10.0)**: with "Validate Identity Provider Certificate" disabled, unauthenticated access to GlobalProtect, the web UI and Prisma Access ([[raw/security.paloaltonetworks.com/cve-2020-2021-pan-os-authentication-bypass-in-saml-4533|Palo Alto]]).
- **FortiCloud SSO (CVE-2025-59718/59719)**: improper signature verification on crafted SAML. Exploited within a week of disclosure against `admin` accounts. FortiCloud SSO is auto-enabled at FortiCare registration unless turned off ([[raw/picussecurity.com/cve-2025-59718-forticloud-sso-authentication-bypass-4099|Picus]], [[raw/thehackernews.com/fortinet-fortigate-saml-sso-bypass-active-attack-4098|THN]]).
- **2026 run**: Citrix NetScaler IdP memory overread (CVE-2026-3055, exploited), authentik assertion injection (CVE-2026-25922), OneUptime decoupled signature verification (CVE-2026-34840) ([[raw/workos.com/saml-rough-quarter-five-critical-vulnerabilities-in-four-months-4958|WorkOS]]).
- **Kong Gateway Enterprise**: AudienceRestriction not enforced, so cross-SP assertion replay ([[raw/github.com/kong-gateway-enterprise-saml-plugin-does-not-enforce-audiencerestricti-14138|advisory]]).
## Defenses
- Use a maintained library and patch it aggressively. Most SAML CVEs are library-level ([[raw/portswigger.net/the-fragile-lock-novel-bypasses-for-saml-authentication-portswigger-re-3898|PortSwigger]]).
- Use strict SAML schemas with minimal extensibility, and process **only signed elements** after verification ([[raw/portswigger.net/the-fragile-lock-novel-bypasses-for-saml-authentication-portswigger-re-3898|PortSwigger]]).
- Order the work as: schema validation first, then signature validation, then use the canonicalized and verified XML. Validate every signature, and confirm you are the intended recipient ([[raw/workos.com/fun-with-saml-sso-vulnerabilities-and-footguns-workos-4536|WorkOS]]).
- Disable DTD processing and remote entity loading, and cap payload size ([[raw/workos.com/fun-with-saml-sso-vulnerabilities-and-footguns-workos-4536|WorkOS]]).
- Pin the IdP signing certificate per connection. Fail closed on a missing signature, an unknown key, or any C14N or transform error.
- Enforce audience, recipient, destination, time window and `InResponseTo`, and keep a replay cache ([[raw/cheatsheetseries.owasp.org/saml-security-owasp-cheat-sheet-4535|OWASP SAML]]).
- Bind the flow to the browser session, not to an unsigned `RelayState`.
- For new integrations, prefer OIDC ([[raw/blog.trailofbits.com/saml-a-fractal-of-bad-design-12072|Trail of Bits]]).
## Related
- [[Authentication Security]] · [[OpenID Connect Security]] · [[Account Takeover]] · [[OAuth 2.0 Vulnerabilities]]
- [[XML External Entity Injection]] · [[Login CSRF]] · [[URL Parser Differentials]] · [[API Security]] · [[Python Security]]
## Sources
- [[raw/blog.trailofbits.com/saml-a-fractal-of-bad-design-12072|SAML: A fractal of bad design]]
- [[raw/usenix.org/usenix-on-breaking-saml-be-whoever-you-want-to-be-3884|USENIX: On Breaking SAML — Be Whoever You Want to Be]]
- [[raw/ibm.com/ibm-what-is-xml-signature-wrapping-3883|IBM: What is XML Signature Wrapping?]]
- [[raw/epi052.gitlab.io/epi052-how-to-hunt-bugs-in-saml-a-methodology-part-ii-3882|epi052: How to Hunt Bugs in SAML — A Methodology (Part II)]]
- [[raw/github.blog/sign-in-as-anyone-bypassing-saml-sso-authentication-with-parser-differ-4101|Sign in as anyone: Bypassing SAML SSO authentication with parser differentials]]
- [[raw/portswigger.net/the-fragile-lock-novel-bypasses-for-saml-authentication-portswigger-re-3898|The Fragile Lock: Novel Bypasses for SAML Authentication - PortSwigger Research]]
- [[raw/workos.com/fun-with-saml-sso-vulnerabilities-and-footguns-workos-4536|Fun with SAML SSO vulnerabilities and footguns (WorkOS)]]
- [[raw/cheatsheetseries.owasp.org/saml-security-owasp-cheat-sheet-4535|SAML Security (OWASP Cheat Sheet)]]
- [[raw/endorlabs.com/cve-2025-47949-samlify-saml-sso-bypass-4100|CVE-2025-47949: samlify SAML SSO bypass]]
- [[raw/projectdiscovery.io/github-enterprise-saml-authentication-bypass-cve-2024-4985-cve-2024-94-4102|GitHub Enterprise SAML Authentication Bypass (CVE-2024-4985 / CVE-2024-9487)]]
- [[raw/sentinelone.com/cve-2026-2092-keycloak-auth-bypass-vulnerability-4953|CVE-2026-2092: Keycloak Auth Bypass Vulnerability]]
- [[raw/github.com/keycloak-saml-identity-broker-authentication-flaw-high-13859|Keycloak SAML identity broker authentication flaw (high)]]
- [[raw/workos.com/saml-rough-quarter-five-critical-vulnerabilities-in-four-months-4958|SAML rough quarter: Five critical vulnerabilities in four months]]
- [[raw/github.com/kong-gateway-enterprise-saml-plugin-does-not-enforce-audiencerestricti-14138|Kong Gateway Enterprise SAML plugin does not enforce AudienceRestriction]]
- [[raw/github.com/social-core-login-csrf-in-saml-callbacks-via-relaystate-15352|social-core: login CSRF in SAML callbacks via RelayState]]
- [[raw/security.paloaltonetworks.com/cve-2020-2021-pan-os-authentication-bypass-in-saml-4533|CVE-2020-2021 PAN-OS: Authentication Bypass in SAML]]
- [[raw/picussecurity.com/cve-2025-59718-forticloud-sso-authentication-bypass-4099|CVE-2025-59718: FortiCloud SSO Authentication Bypass]]
- [[raw/thehackernews.com/fortinet-fortigate-saml-sso-bypass-active-attack-4098|Fortinet FortiGate SAML SSO Bypass Active Attack]]