Repository navigation
Description
Bug description
Stored upstream token rows don't record which identity provider issued them. The auth server picks the provider for a refresh by the upstream's name only (refresher.go, r.providers[expired.ProviderID]). If an operator points an upstream at a different IdP but keeps the name and the store, the next refresh of every existing session sends the old IdP's refresh token to the new IdP's token endpoint.
The refresh grant guard (refresh_grant_guard.go) makes the same choice when the stored upstream access token has expired, and callback carry-forward (maybeCarryForwardRefreshToken) can copy an earlier refresh token into a new row on the same basis.
This was already the case before "Bind provider-identity rows to the issuer and subject claim that created them" (#7256). That work binds identity-link rows to their issuer and subject claim, but upstream token rows have no such binding.
Steps to reproduce
- Run the embedded auth server with Redis storage and an OIDC upstream named
defaultat IdP A. Sign in, so a session holds an upstream refresh token from A. - Change
default's issuer to IdP B. Keep the name and the Redis store, then restart. - Use the session until its upstream access token expires, then use a ToolHive refresh token (or any request that triggers an upstream refresh).
Expected behavior
A refresh token is only sent to the authority that issued it. A row from a different issuer is treated as unusable: the refresh fails and the user signs in again.
Actual behavior
The auth server sends IdP A's refresh token to IdP B's token endpoint. B normally rejects it, but A's credential has still been disclosed to B. For a claim-only change on the same IdP, the refresh succeeds and the session keeps working for the old account.
Additional context
Possible fix: record the issuer (or the same binding the identity rows now use) on UpstreamTokens when the row is written. Then refuse to refresh, or to carry a refresh token forward, when it doesn't match the upstream's current configuration. Rows written before the change carry no issuer and need a rule, like the stamp-on-first-match rule in #7256.
Until then, operators should revoke existing sessions before repointing an upstream.
Activity