Summary
SuperTokens Core's SAML callback does not sufficiently bind assertions to login requests or prevent previously accepted assertions from being reused. An attacker who obtains a valid SAML response may be able to replay it to mint additional authorization codes or, in some flows, complete a login with an unintended identity.
Affected context
The issue affects SuperTokens Core's SAML callback handling in SP-initiated and IdP-initiated login flows. The risk arises when the callback accepts assertions without consuming RelayState, recording assertion identifiers, or enforcing request and recipient-related checks. Exploitation depends on obtaining a valid assertion and, for SP-initiated replay, its matching RelayState while the assertion remains valid.
Exploit preconditions
- Attack surface: The SAML callback endpoint,
/recipe/saml/callback - Required access: The attacker must obtain a valid SAML response; SP-initiated replay also requires its matching RelayState.
- Trigger point: Submission of the response to the callback before the assertion expires; IdP-initiated assertions may be replayed without RelayState.
- Why exploitation is possible: The callback does not reliably consume RelayState, track used assertion identifiers, bind the response to the pending request using
Response.InResponseTo, or validate relevant destination and subject-confirmation constraints.
Why this happens
The callback accepts SAML assertions without enforcing sufficient freshness, uniqueness, recipient, and request-binding checks. This creates an authentication replay weakness, associated with CWE-294, and can also involve CWE-346 when the response's origin or intended recipient is not properly validated. Failure to correlate an assertion with the pending login can enable identity substitution, related to CWE-384 session fixation and authentication-flow binding concerns.
Potential impact
- A previously accepted assertion could be replayed to obtain additional independently redeemable authorization codes.
- A login flow could be completed using an assertion associated with a different identity.
- IdP-initiated login could be accepted even when that flow is intended to be disabled.
- An attacker could gain access as the identity represented by a captured assertion.
General mitigation guidance
Defensive patterns focus on strict assertion validation and binding each response to a single login transaction.
- Reject assertions that have already been used, and enforce assertion expiry.
- Consume and validate RelayState and require
Response.InResponseToto match the pending request where applicable. - Validate the response destination and subject-confirmation recipient and time constraints.
- Enforce the configured policy for IdP-initiated login.
- Ensure authorization codes are issued only after all checks succeed, and apply least privilege to resulting sessions and tokens.
How teams detect issues like this
Review SAML callback code for assertion replay protection, request correlation, and validation of destination, recipient, and time conditions. Static analysis and code review can flag missing checks around SAML response handling and repeated authorization-code issuance. Runtime monitoring can look for repeated assertion identifiers, unexpected callback reuse, mismatched request identifiers, and IdP-initiated logins that conflict with policy.

