Skip to content

Token validator with an in-process key provider falls back to fetching JWKS over HTTP for an unknown kid #7412

Backlog

Description

@ChrisJBurns

Problem

When the token validator has an in-process key provider (the embedded auth server's keys), a token with a kid that provider doesn't know is not refused straight away. The validator falls back to fetching the JWKS over HTTP from the issuer's /.well-known/jwks.json.

In a pod that can't reach its own public issuer URL (Kind, or a cluster without hairpin routing), the fetch never succeeds. Every such token then fails with:

invalid_token: failed to lookup JWKS: resource "<issuer>/.well-known/jwks.json" is not ready

The token is refused, so this fails closed. But:

  • The error reads like an outage. The real cause is a token signed by a key the server doesn't have.
  • The HTTP fetch is pointless when the in-process provider already holds the full key set.
  • The first such request can block for up to 5 seconds while the JWKS URL is registered.

Where

pkg/auth/token.go (v0.70.1):

  • getKeyFromJWKS: tries the local key provider, then falls through to the HTTP JWKS when the kid isn't found.
  • ensureJWKSRegistered: registers the URL with a 5s budget and treats httprc.ErrNotReady as registered, so Lookup keeps returning "not ready".

How to reproduce

Run the embedded auth server and vMCP in one process, with an issuer URL the process can't reach. Send the vMCP an MCP request whose bearer token has a kid the embedded server didn't issue, for example a token from another authorization server. Expect key ID … not found; you get the "not ready" error.

Found by Mecatl's Kind end-to-end test (stacklok/mecatl#3048), which sends the embedded gateway a token from a different authorization server.

Suggested fix

When the local key provider is the whole key set for this issuer, refuse an unknown kid with key ID <kid> not found and skip the HTTP fallback.

If the fallback has to stay (for example for keys another replica rotated in), make the error name the unknown kid instead of "JWKS not ready".

Impact

Low. Nothing gets in that shouldn't. It means misleading errors, an extra network fetch per bad token where the fetch can succeed, and a one-off 5-second stall.

Activity

  1. added
    needs-triage
    bug
    kubernetes
    vmcp
    on Nov 30, 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

    authenticationbugkubernetesneeds-triageoidcvmcp

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions