fix(auth): reject replayed SAML assertions#407
Merged
Conversation
Accepting IdP-initiated (no-RelayState) POSTs in #406 opened a replay vector: any captured assertion — including an SP-initiated one with its RelayState stripped — could be re-POSTed and accepted until it expired, since the only remaining bound was its notBefore/notOnOrAfter window. The ACS now records each validated assertion by its signed ID in Valkey for the remainder of its validity window and rejects a second use — the same single-use pattern as the relay state and completion token. The ID is the dedup key (not a byte hash) because it lives inside the signed element: an attacker can't change it without the IdP's key, whereas the surrounding bytes can be mutated (re-canonicalization, namespace/attribute reordering, the unsigned Response wrapper) while keeping a valid signature. Without Valkey the assertion's expiry window remains the only bound.
Contributor
Author
|
🎉 This PR is included in version 0.35.3 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fast-follow to #406. Accepting IdP-initiated (no-
RelayState) POSTs opened an assertion-replay vector: any capturedSAMLResponse— including an SP-initiated one with itsRelayStatestripped — could be re-POSTed to the ACS and accepted until it expired, because the only remaining bound was the assertion'snotBefore/notOnOrAfterwindow.The ACS now records each validated assertion by its signed assertion ID in Valkey for the remainder of its validity window and rejects a second use — the same single-use pattern as the relay state (#405) and the completion token (#406). The ID is the dedup key (rather than a byte hash of the response) because it lives inside the signed element: an attacker can't change it without the IdP's key, whereas the surrounding bytes can be mutated (re-canonicalization, namespace/attribute reordering, the unsigned Response wrapper) while keeping a valid signature. Without Valkey the assertion's expiry window remains the only bound (consistent with the relay-state fallback).
Related Issue
Fast-follow to #406; closes the assertion-replay gap raised in review.
Type of Change
Testing
registerSamlAssertionreturns true on first use, false on replay (Valkey-backed); returns true without Valkey.tsc+ prettier clean for the changed files.Checklist