fix(k8sjwt): skip unusable keys in JWKS discovery#499
Merged
Zoe Zhao (zoez7) merged 1 commit intoJul 23, 2026
Merged
Conversation
Benjamin Elder (BenTheElder)
left a comment
Collaborator
There was a problem hiding this comment.
[AI first pass experiment ...]
| } | ||
|
|
||
| if skipped > 0 { | ||
| slog.InfoContext(ctx, "Skipped unusable JWKs from issuer", |
Collaborator
There was a problem hiding this comment.
🤖 nit 🟢 – This Info summary fires on every Verify (discovery is per-request until key caching lands) — the same per-request noise the PR avoided by putting per-key skips at Debug. Consider Debug here too, or rate-limiting.
Contributor
Author
There was a problem hiding this comment.
Yeah, I was on the fence on this one. Moved it to Debug for now, will bump it back to Info once discovery is cached (the TODO above).
A key the verifier can't parse no longer fails discovery for the whole issuer: skip it, erroring only when no usable keys remain. Selection stays by kid + signature, so skipping is safe.
Anish Ramasekar (aramase)
force-pushed
the
aramase/i/k8sjwt_skip_unusable
branch
from
July 23, 2026 06:14
ca958c0 to
c150109
Compare
Zoe Zhao (zoez7)
approved these changes
Jul 23, 2026
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.
discoverKeysForIssuernow parses each JWK viaparseJWKand skips keys the verifier can't use (unsupportedkty/curve, malformed params, or nokid), failing only when no usable key remains — with distinct errors forempty JWKSvsno usable keys ... (N skipped). Matches the go-oidc/jose convention: skip at discovery, fail only when a token'skidmatches no usable key. Selection stays bykidand signatures are still verified, so skipping cannot enable forgery.Behavior note
A key with no
kidis now skipped instead of failing the whole set. Safe: tokens must carry akidand match by exactkid, so a no-kidkey was never selectable anyway.