Repository navigation
fix(federation): refuse a chain that expires while it resolves, and answer a re-entrant failure hook - #990
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Resolver.Resolve read the clock once, when it started, and verified every statement it fetched at that time. A resolution whose fetches outlasted the chain's earliest exp therefore returned a chain that had already expired, and AutomaticClientRepository handed the requests waiting on that resolution a client, and its keys, registered from it. The cache itself was not extended past the chain's expiry: its entry expired with the chain, so only the requests sharing that resolution were answered from the expired chain. Resolve now checks ResolvedEntity.ExpiresAt against the clock again when it finishes, with the MaxClockSkew tolerance each statement's exp was checked with, and refuses a chain that has expired by then. Automatic registration repeats the check after building the registration, since fetching the RP's jwks_uri can take the chain past its expiry after Resolve returned. Such a registration fails like any other: invalid_client for the client, reported to OnResolutionFailure and remembered for FailureCacheAge. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…lient_id OnResolutionFailure runs on the resolution's goroutine before the resolution finishes. A hook calling ResolveClient for the same client_id relied on the failure having been remembered just before it ran; when it had not been (the memory of failures full, which any caller can bring about by naming enough failing client_ids, or the hook outlasting FailureCacheAge) the call joined the in-flight resolution and waited on the hook that was waiting on it. With no deadline on the call that wait never ended: the hook, the requests sharing the resolution and its place under MaxConcurrentResolutions were held for good, so enough of them refused every new resolution with ErrTooManyResolutions. The failure is now also recorded on the in-flight resolution before the hook is called, bounded as a remembered failure is, and a request for that client_id that finds it there gets it at once instead of waiting. That covers the hook's own calls, whatever context they carry, and makes the documented promise that a request arriving while the hook runs is answered without joining the resolution hold even when the failure could not be remembered. The hook's documentation now says a hook may resolve the same client_id and what it gets. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ooks Cover the chain expiry check at the end of Resolve and after building an automatic registration, its clock-skew tolerance, and the failure published on an in-flight resolution for OnResolutionFailure. The remembered-before-hook mutant moves past the new publishFailure call. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
osanderson
force-pushed
the
fix/audit-e6-e7
branch
from
November 25, 2026 23:18
944aef2 to
74d08bd
Compare
|
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.



This PR fixes two federation issues from the audit's unverified hypotheses (section E). Both were confirmed on v0.85.0.
E-6: a trust chain that expires while it resolves (
fix(federation))Resolver.Resolveread the clock once at the start and checked every statement against that time. If a slow fetch took the clock past the chain'sexp,Resolvereturned a chain that had already expired.AutomaticClientRepositorythen registered and cached the client, capped at the chain'sexp, so it wasn't kept beyond the expiry. The requests sharing that one resolution were still answered with the expired registration:ResolveClientreturned the client, and the key source returned its keys.The fix checks the chain's
ExpiresAtagainst the clock at two points:Resolvefinishes.checkChainUnexpireduses the sameMaxClockSkewtolerance as each statement'sexpcheck. A chain accepted today, when no time passes during resolution, is still accepted.register. Fetching the RP'sjwks_urican take the chain past its expiry afterResolvereturns. A chain refused here fails like any other registration:invalid_client, reported to the hook and remembered.UPGRADING.md has a section under v0.85.1. The only new refusal is a chain that expires part-way through a resolution.
E-7: a resolution-failure hook resolving its own
client_id(fix(federation))R-20's follow-up remembers a failure before
OnResolutionFailureruns, so a re-entrantResolveClientnormally gets that failure at once. It wasn't remembered in two cases:FailureCacheAge.In either case, a hook calling
ResolveClientfor the sameclient_idwithout a deadline joined the in-flight resolution and waited on itself. Neither call ever returned, and the resolution held aMaxConcurrentResolutionsslot. A run was still stuck after 20 s, and with one slot an unrelated resolution gotErrTooManyResolutions.The fix:
OnResolutionFailuredoc comment,server.Configand the federation guide now say a hook may resolve the sameclient_id, and that resolving a different one needs a slot of its own.Tests
expduring the Trust Anchor fetch, and during the RP'sjwks_urifetch. Cases cover long pastexp, just past the skew, within the skew, beforeexp, and no time passing, for bothResolveClientand the key source.Nothing on the wire changes for valid flows. Conformance is running anyway, since the federation plans exercise
Resolve.🤖 Generated with Claude Code