Skip to content

Refresh tokens are sent to a repointed upstream's new IdP #7333

Backlog

Description

@jhrozek

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

  1. Run the embedded auth server with Redis storage and an OIDC upstream named default at IdP A. Sign in, so a session holds an upstream refresh token from A.
  2. Change default's issuer to IdP B. Keep the name and the Redis store, then restart.
  3. 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

  1. added
    bug
    on Nov 26, 2026
  2. added
    needs-triage
    on Nov 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    authenticationbugneeds-triage

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions