Skip to content

oidc: finish JWKS refresh before waking waiters - #513

Open
dgplex wants to merge 1 commit into
coreos:v3from
dgplex:fix/jwks-refresh-completion
Open

dgplex wants to merge 1 commit into
coreos:v3from
dgplex:fix/jwks-refresh-completion

Conversation

@dgplex

@dgplex dgplex commented Nov 9, 2026

Copy link
Copy Markdown

Problem

RemoteKeySet signals the current refresh before updating the cache and clearing the in-flight entry. A verifier woken by the signal can finish, then another verification can join the already completed refresh. If the issuer has published a new signing key in the meantime, the second verification may reject a valid token using the new key ID without fetching the new JWKS.

Change

Update the cache and signal completion while holding the same lock that protects the in-flight entry. A new verifier can only acquire the lock after that entry has been cleared. Current waiters still receive the same keys or error.

Verification

  • go test ./...
  • go test -run '^TestRotation$' -count=100 ./oidc
  • In a local reproduction, widening the scheduling window between completion and cleanup triggered the signature failure. Keeping the delay but moving the notification under the lock passed. Reverting the ordering failed again.

Co-authored-by: Codex <codex@openai.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant