Skip to content

feat(client): refuse an issuer key source bound to another issuer - #994

Merged
osanderson merged 6 commits into
mainfrom
feat/issuer-bound-key-source
Nov 26, 2026
Merged

osanderson merged 6 commits into
mainfrom
feat/issuer-bound-key-source

Conversation

@osanderson

Copy link
Copy Markdown
Collaborator

The audit's E-9 hypothesis is a key source shared between clients for different issuers. #989 refuted it as an exploit, but it left a misconfiguration open: an issuer key source bound to one issuer could be given to a client or resource server for another. This change refuses that at construction. Sources that aren't bound to an issuer are still accepted, so it isn't breaking.

feat(keys): IssuerBound

keys.IssuerBound is a new optional interface. Its single method, BoundIssuer() string, returns "" when the source isn't bound to one issuer.

  • JWKSIssuerKeySource: reports the issuer given with WithIssuer, or "" without it.
  • LocalIssuerKeys: always reports its own issuer.
  • Wrappers: an embedding wrapper inherits the binding. One that changes which issuers it serves must override BoundIssuer, as with KeySourceAssurance.

feat(client) and feat(resource): refuse a source bound to another issuer

Client: client.New now refuses Dependencies.IssuerKeys that report a bound issuer other than cfg.Issuer. The comparison is the exact one the client uses for every iss check, and the error names both issuers. NewFromDiscovery goes through New and binds its source to the discovered issuer, so it always matches.

Resource: resource.JWTAccessTokens gets the same check against its Issuer, through NewJWTAccessTokens and NewVerifier. serverresource.NewVerifier builds LocalIssuerKeys from the same issuer, so it always matches.

Such a source could never have validated the configured issuer's own tokens, so this only moves the failure from every verification to construction. UPGRADING.md has a note under v0.87.0.

Not covered: resource.AccessTokenAssurance.IssuerKeys, which a custom resolver declares, has no issuer beside it to compare against.

Tests

  • Refusal tests: client and resource tests cover a mismatched bound source, both a stub and a real LocalIssuerKeys, plus a trailing-slash variant. They fail when the check is replaced with return nil.
  • Acceptance tests: a matching source, an unbound one, and a source without the interface are all accepted.
  • Mutants: six new, all killed.
  • Suites: the race suite, sqlstore, every example module and the interop client pass, and lint is clean.
  • Existing callers: the conformance client's hand-built sources are unbound, so they're unaffected.

Nothing on the wire changes.

🤖 Generated with Claude Code

osanderson and others added 6 commits November 26, 2026 09:10
A JWKSIssuerKeySource built WithIssuer, and every LocalIssuerKeys,
refuses lookups for any issuer but its own, but nothing outside the
source could see that binding. A verifier wired by hand to a source
bound to a different issuer only found out when every verification
failed at runtime.

Add the optional IssuerBound interface, whose BoundIssuer returns the
issuer a source serves exclusively, or "" when it serves any.
JWKSIssuerKeySource reports the WithIssuer issuer (or ""), and
LocalIssuerKeys always reports its own, so the verifiers built on them
can check the binding at construction.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A Dependencies.IssuerKeys source bound to an issuer other than
Config.Issuer (a keys.LocalIssuerKeys, or a keys.JWKSIssuerKeySource
built WithIssuer) refuses every key lookup the client makes, so the
client built fine and then failed every JARM, ID token and signed
UserInfo verification.

New now checks a source implementing keys.IssuerBound and refuses one
whose bound issuer isn't exactly Config.Issuer, naming both issuers.
An unbound source, or one not implementing the interface, is accepted
as before. Dependencies.IssuerKeys now also says that a source shared
between clients of different issuers must be bound.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A JWTAccessTokens whose IssuerKeys is bound to an issuer other than
its Issuer (a keys.LocalIssuerKeys, or a keys.JWKSIssuerKeySource
built WithIssuer) refuses every key lookup, so the verifier built fine
and then answered every request with a key-resolution failure.

JWTAccessTokens' validation, run by NewJWTAccessTokens and by
NewVerifier for a literal, now refuses a source implementing
keys.IssuerBound whose bound issuer isn't exactly Issuer, naming both
issuers. An unbound source, or one not implementing the interface, is
accepted as before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
client.New and resource's JWTAccessTokens validation now refuse an
issuer key source bound to a different issuer. Only a configuration
that already failed every verification is affected; document what the
error looks like and how to fix the wiring.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Cover client.New's and JWTAccessTokens' refusal of an issuer key source
bound to another issuer, their acceptance of an unbound one, and the
BoundIssuer reports of JWKSIssuerKeySource and LocalIssuerKeys.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
It ships after 0.86.0, and as a feature it makes that release 0.87.0.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@codecov

codecov Bot commented Nov 26, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@sonarqubecloud

Copy link
Copy Markdown

@osanderson
osanderson merged commit ba421da into main Nov 26, 2026
34 checks passed
@osanderson
osanderson deleted the feat/issuer-bound-key-source branch November 26, 2026 01:49
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