Repository navigation
fix(mcp): a revoked OAuth token stops working within a minute - #128
Merged
Merged
Conversation
OAuth access tokens (late_at_) are re-verified after 60s instead of 600s, so an RFC 7009 revocation at zernio.com reaches the MCP within a minute. API keys keep the 10-minute cache; the 1-hour outage grace and in-flight de-duplication are unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Why
ZernioTokenVerifiercaches a confirmed bearer for 600s. Now that zernio.com has an RFC 7009 revocation endpoint (Schedule-Posts-API #10347, advertised asrevocation_endpointin the live AS metadata), a revoked OAuth access token still worked on/mcpand/chatgptfor up to 10 minutes.What
late_at_, fromapp/api/oauth/token/route.tsgenerateToken("late_at_")) are re-verified after_OAUTH_FRESH_TTL_SECONDS = 60._FRESH_TTL_SECONDS = 600.resolved_by/waited_msclaims (logged asauth/auth_wait_msonmcp_tool_call) are unchanged.The cache is per process and production runs 4 workers (
workerfield in Axiom), so the bound is still 60s: each worker re-asks on its own.Also worth knowing: every tool call already sends the bearer to the API, and
_ApiTransportevicts the cache entry on a 401. So during the 60s window a revoked token could not read or write data. It could still reach the surfaces that don't call the API (initialize, tools/list, docs search).Extra load on
/v1/auth/verifyThe repo does have telemetry for this: the
zernio-mcpAxiom dataset gets onemcp_tool_callper tool call withauth(cache|upstream|joined|grace) andauth_wait_ms. Last 7 days (2026-11-17 to 2026-11-24):Caveat:
token_scopeis empty on every event, so the telemetry can't split OAuth from API keys. I estimated the upper bound by counting distinct (caller, worker, time bucket) groups:Verifies from initialize and tools/list are not in this telemetry, so real totals are somewhat higher.
/v1/auth/verifyonly authenticates and returns, so the extra cost per call is small.Tests
tests/test_mcp_auth_cache.py:AuthenticationErrorpytestfor the auth, middleware, HTTP auth, PRM and telemetry tests: 116 passed. Full suite: 3501 passed, 14 skipped.Local verification
Local server:
MCP_PUBLIC_URL=http://127.0.0.1:8765 zernio-mcp-http, pointed at production zernio.com discovery.Bearer resource_metadata="http://127.0.0.1:8765/.well-known/oauth-protected-resource/mcp"for/mcp, and.../chatgptfor/chatgpt.error="invalid_token"anderror_description.resourceishttp://127.0.0.1:8765/mcpandhttp://127.0.0.1:8765/chatgpt, exactly the URLs the client connected to.authorization_serversis["https://zernio.com"], matching the live issuer byte for byte./chatgptadvertises its narrowed scopes. The legacy root/.well-known/oauth-protected-resourcereturns 308 to/mcp's document.mcp2.3.0,OAuthClientProvider, which by default rejects aresourcemismatch per RFC 8707), run against both surfaces: 401, then PRM, then the AS metadata from zernio.com, then DCR against prod, then the authorize redirect withresource=<surface URL>, the surface's scopes,S256andresponse_type=code. I stopped at the consent screen, since no human login was available.MCP_VERIFY_URLpointed at a local stub that answers 401 once a token is revoked. tools/list ran every 5s:late_at_token: verified at t=0, revoked at t=5.3s, still served from cache through t=55.8s, refused at t=60.9s. The refusal was a 401 witherror="invalid_token"andresource_metadata.sk_key revoked at the same moment: still served at t=76s, as expected with its 600s cache.I could not test a real production OAuth token end to end, because getting one needs browser consent.
Differences vs Sentry MCP and Cloudflare MCP
Reference PRM documents, fetched live:
mcp.sentry.dev:{resource, authorization_servers:[self], scopes_supported, bearer_methods_supported}observability.mcp.cloudflare.com:{resource, authorization_servers:[self], bearer_methods_supported}https://zernio.com)workers-oauth-provider)realmin challengerealm="OAuth"realmis optional in RFC 6750 and RFC 9728, and clients ignore it. Keep as is.resource_name,resource_documentationin PRMscopes_supportedin PRM/chatgpt)scopein the 401 challengescopes_supported. Could add later; out of scope here.error_descriptionon invalid_tokenerror="invalid_token"with no description/.well-known/oauth-protected-resource/mcpdocumentNo changes to metadata or challenges in this PR.
🤖 Generated with Claude Code