Summary
Relyra, a strict-by-default SAML 2.0 Service Provider library for Elixir and Phoenix, contained a signature verification flaw that allowed forged SAML assertions to be accepted as authenticated.
Because the cryptographic SignatureValue and associated digests were not actually verified against the IdP certificate, an attacker able to inject or alter SAML responses could obtain successful logins with attacker-controlled identities.
Affected context
This vulnerability affects applications that use vulnerable versions of the Relyra SAML Service Provider library (notably 1.0.0 and 1.1.0) to implement SAML 2.0 single sign-on.
It manifests when SAML responses from an Identity Provider (IdP) are treated as trusted if they merely conform structurally and appear to come from an expected source, without performing full XML Digital Signature (XMLDSig) verification against the configured IdP certificate.
Environments that terminate SAML at an application boundary using Relyra, especially those relying on SSO for administrative or high-privilege access, are particularly exposed if attackers can influence or relay SAML messages.
Exploit preconditions
- Attack surface: SAML assertion consumer endpoints (ACS) exposed by applications integrating Relyra.
- Required access: Ability to intercept, modify, or directly post crafted SAML Responses to the ACS endpoint (e.g., via network position, misconfigured IdP, compromised browser or client, or open redirect/relay abuses).
- Trigger point: The vulnerable signature-validation routine that processes the
<ds:Signature>element of the SAML Response or Assertion. - Why exploitation is possible: The library performed a structure-only check and accepted signatures without:
- Verifying
SignatureValueover the canonicalizedSignedInfowith:public_key.verifyagainst the IdP's public key. - Recomputing and comparing
DigestValueover the canonicalized referenced XML element. - Using the canonicalization logic (
canonicalize/2) in the actual verification path.
As a result, a forged signature with arbitrary NameID and related subject data could be returned as a successful authentication result.
Why this happens
The root cause is an incomplete XMLDSig verification implementation that validates the presence and shape of signature-related elements but does not cryptographically prove their authenticity.
This maps to CWE-347: Improper Verification of Cryptographic Signature and is closely tied to CWE-287: Improper Authentication, because the application's trust in user identity ultimately depends on a signature that was never actually verified.
The library failed to:
- Apply canonicalization and signature verification (
:public_key.verify) toSignedInfousing the configured IdP certificate. - Recalculate digests of the referenced XML fragments and compare them against
DigestValue.
Consequently, the trust boundary stopped at structural checks, allowing attacker-supplied signature bytes and identity attributes to be treated as valid.
Potential impact
- Attackers can impersonate arbitrary users by forging SAML Responses with attacker-controlled
NameIDand attributes. - Privilege escalation to administrative or highly privileged accounts if those roles are derived from SAML attributes or mapped identities.
- Complete bypass of SSO-based access controls across multiple relying applications integrated with the same IdP.
- Potential lateral movement between systems that trust the compromised SAML assertions for federation.
- Regulatory and compliance exposure due to unauthorized access to sensitive data and services.
General mitigation guidance
Mitigation focuses on enforcing complete, cryptographically sound SAML signature verification and strengthening the authentication boundary:
- Ensure XMLDSig verification includes:
- Canonicalization (e.g., exclusive C14N) of
SignedInfo. - Verification of
SignatureValueagainst the configured IdP certificate using a trusted crypto primitive. - Recalculation and comparison of
DigestValuefor each referenced element. - Treat SAML assertions as untrusted until all cryptographic checks and reference validations succeed, not just structural or schema checks.
- Restrict which IdP certificates are accepted and ensure they are provisioned via out-of-band, authenticated channels.
- Apply least-privilege and defense-in-depth controls so that SAML-based authentication does not automatically grant broad or administrative access without additional checks.
- Prefer mature, well-reviewed SAML and XMLDSig libraries or hardened verification routines that default to safe behavior and minimize custom signature-handling logic.
How teams detect issues like this
Effective detection involves reviewing both code and runtime behavior around SAML processing:
- Static analysis and code review:
- Look for custom SAML or XMLDSig handling that parses
<ds:Signature>but does not invoke strong cryptographic verification against a configured IdP public key. - Flag flows where canonicalization helpers (e.g.,
canonicalize/2) exist but are unused or bypassed in the verification path. - Identify any signature checks that rely only on the presence of signature elements, issuer fields, or document structure instead of validated cryptographic results.
- Configuration and policy checks:
- Verify that each relying party is configured with explicit, pinned IdP certificates and rejects unknown or unexpected keys.
- Enforce policies requiring full signature and digest validation for all SAML Responses/Assertions, including nested or referenced elements.
- Runtime monitoring:
- Monitor authentication logs for anomalous patterns, such as successful logins for accounts without normal login activity or from unusual clients.
- Use security testing and fuzzing tools that craft malformed or unsigned SAML Responses to confirm that the service correctly rejects them.
Automated security testing tools and SSO-focused scanners can help identify places where SAML assertions are accepted without complete cryptographic verification.

