fix: let an assertion be presented only once - #44
Open
shreemaan-abhishek wants to merge 1 commit into
Open
Conversation
Nothing stopped the same assertion being posted back a second time inside its validity window. Its ID is remembered now, in an lua_shared_dict the deployment names, and a second presentation is refused. The entry lives as long as the assertion's own Conditions leave it usable, so the cache holds exactly what could still be replayed. An assertion that names no expiry is remembered for replay_ttl, since nothing in the assertion says when to stop. Unset replay_dict leaves assertions untracked, which is what deployments with no shared dict to spare get today.
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Comment |
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.
Closes #37, item 5 of its suggested scope. Stacked on #43, which is stacked on #42; the base branch retargets as each merges.
What was wrong
An assertion could be posted back as many times as its window allowed. #42 bounds that window and #43 ties the assertion to one
AuthnRequest, which together shrink the opening a great deal, but neither makes an assertion single-use, and single-use is what "bearer" means: whoever holds it is the subject.What it does now
login_callbackremembers the ID of every assertion it accepts and refuses a response carrying one it has seen. The store is anlua_shared_dictthe deployment names through the newreplay_dictoption, because a library cannot declare one and the entry has to be shared across workers. Unset leaves assertions untracked, which is today's behaviour; a name that nolua_shared_dictmatches fails loudly atnew()rather than quietly not tracking anything.How long an entry lives is taken from the assertion rather than from configuration:
Conditions/@NotOnOrAfterplus theclock_skewallowance is the last moment the checks in #42 would still accept it, so the cache holds exactly what is still replayable and no more. An assertion that names no expiry has nothing to derive from and is remembered forreplay_ttl, 600 seconds by default.Two smaller points:
sp_issuer, so several SP instances sharing one dict do not collide.lua_shared_dictevicts under pressure. An eviction weakens replay protection silently, so a forcible insert logs a warning naming the dict as full.Tests
TESTs 21 to 23 in
t/assertion-conditions.t. TEST 23 reads the entry's TTL back out of the dict, covering both the derived window and thereplay_ttlfallback.Full run on this branch,
t/assertion-conditions.tandt/signed-response.t, 120 subtests, all pass. Rebuilt against #43'slua/with the new tests kept, the two that should fail do and only those:TEST 22 passes on both, which is the point of it.