Your agent kicks off a multi-step job with a valid bearer token, hits a short-lived refresh window halfway through, and two workers retry the token exchange at once.
Instead of failing cleanly—or resuming once—one auth code mints two live sessions, or a single transient helper timeout locks out every session on the machine for 15 minutes.
Across four recent primary sources—FastMCP v4.2.4 (GHSA-78c8-3jhx-5mg7), LangSmith Fleet's Needs reconnect release, Anthropic Claude Code v2.1.326 / v2.1.332 & Issue #103343, and MCP SEP-2207—here is what actually goes wrong when agent credentials age mid-run.
1. Non-atomic token consumption turns one retry into two sessions (FastMCP v4.2.4 / GHSA-78c8-3jhx-5mg7)
In FastMCP v4.2.4 ("Burn After Reading", November 20–21, 2026), maintainers patched GHSA-78c8-3jhx-5mg7 in OAuthProxy.
Previously, exchange_authorization_code and exchange_refresh_token redeemed credentials in two separate steps against _code_store:
# Vulnerable pattern (FastMCP <= 4.2.3): non-atomic get-then-delete
code_model = await self._code_store.get(key=authorization_code.code)
if not code_model:
raise TokenError("invalid_grant", "Authorization code not found")
# ... expiry / scope checks ...
await self._code_store.delete(key=authorization_code.code) # return bool ignored
Because get() yields to the event loop on disk-backed stores (the library default FileTreeStore wrapped in FernetEncryptionWrapper) and network stores (RedisStore), two concurrent /token requests presenting the same authorization code both read the record before either deleted it. Each exchange minted a fresh upstream_token_id and separate JTI mapping—meaning revoking one session left the twin session alive.
In the advisory's proof of concept:
- Default
FileTreeStore + Fernet: 18/20 dual-token race wins atn=2and 20/20 atn=5. - Two-replica
RedisStore: 19/20 atn=2. -
MemoryStore(non-suspending read): 0/20.
The fix in v4.2.4 (PR #6614 & PR #6620):
- Consume authorization codes and refresh tokens atomically with
delete()and reject withinvalid_grantunlessdelete()actually removed a record (claiming refresh tokens after the upstream refresh succeeds so transient upstream errors remain retryable). - Keep a revoked proxy access token invalid even after a subsequent refresh.
2. Silent refresh failures need in-place reconnection (LangSmith Fleet, November 2026)
When a long-lived agent or cron schedule runs unattended for days, an OAuth refresh failure cannot just crash the loop or prompt users to create a brand-new account binding (which orphans existing workflows).
In its November 16–23, 2026 updates (LangSmith Cloud changelog and LangSmith Fleet changelog), LangChain introduced explicit token lifecycle states:
-
In-place
Needs reconnect: When a refresh token can no longer renew, Fleet replaces the Connected badge with Needs reconnect and a Reconnect action that re-authorizes the existing account rather than creating a duplicate—so existing agent connections immediately resume. -
Graceful tool-server skipping: Agent runs skip MCP servers whose tokens are inactive instead of stalling the whole execution, while API responses surface
statusandstatus_reason. -
Structured
credential_status: Managed tools server lists reportconnected,needs_connect,needs_reconnect, orunavailablecleanly to callers.
3. When a local bearer helper poisons every session on the machine (Claude Code v2.1.326, v2.1.332, & #103343)
Anthropic shipped multiple MCP OAuth and headersHelper fixes in November 2026 (Claude Code CHANGELOG):
-
v2.1.321: Prevented MCP OAuth flows from forwarding secrets such as refresh tokens to another host on HTTP redirect. -
v2.1.326: Fixed an issue where one failed MCPheadersHelper(or an untrusted folder skipping it) caused other sessions to start without that MCP server when no stored OAuth refresh token existed. -
v2.1.332: Fixed pluginheadersHelperscripts receiving corruptedCLAUDE_PLUGIN_ROOTand server URL values when credential env vars held switch values like1, and updatedCLAUDE_CODE_OAUTH_TOKENhandling so prefixes can end inoat02-as well asoat01-.
Yet Issue #103343 (still reproduced on v2.1.332) highlights a subtle cache-poisoning failure mode for HTTP MCP servers configured with headersHelper (and no oauth block):
- Session A runs
headersHelper; the helper fails once or exceeds its10stimeout. - The client still hits the MCP endpoint without an
Authorizationheader. - The server replies
HTTP 401with OAuth discovery metadata (registration_endpoint). - The client treats it as an interactive OAuth server and writes
{ "<server>": { "timestamp": ... } }to the machine-wide~/.claude/mcp-needs-auth-cache.jsonwith a 15-minute TTL (900,000 ms). - Every new session on that host logs
Skipping connection (cached needs-auth)and drops all tools from that server for 15 minutes—even after the helper is healthy again.
4. What the MCP Authorization Spec forbids assuming (2026-07-28, SEP-2207)
The Model Context Protocol Authorization Specification (2026-07-28) and SEP-2207 capture the underlying contract rule that too many agent harnesses ignore:
-
Clients MUST NOT assume that advertising
refresh_tokeningrant_typesor sendingoffline_accessguarantees a refresh token will be returned. Authorization servers retain policy discretion, and clients must handle short-lived access-token expiry via explicit re-authentication. - Public clients using refresh tokens MUST have their refresh tokens rotated by the authorization server—making single-use atomic storage (Section 1) mandatory whenever concurrent agent workers share a session.
- On step-up
WWW-Authenticatechallenges (SEP-2350), treat the challenged scopes as authoritative rather than assumingscopes_supportedcovers what a specific tool call needs mid-run.
Practical checklist before your next deploy
-
Make code and refresh claims atomic: Replace
get()+delete()with single-operation atomic delete or compare-and-swap on Redis/SQL/file stores, and reject losers withinvalid_grant. -
Isolate non-OAuth helper failures per connection: Never let a transient
headersHelpertimeout write an interactive OAuth lockout cache across unrelated sessions on the same host. -
Separate credential status from agent topology: Support in-place
needs_reconnectre-authorization so renewing an expired token restores existing agents rather than minting orphan bindings. - Re-check token state and revocation on resume: Just like human approval grants, an agent resuming after a pause or retry must verify the token has not been revoked or downgraded before dispatching external side effects.
Honest limitation
This synthesis is compiled directly from primary advisories, release notes, issue logs, and protocol specifications (FastMCP GHSA-78c8-3jhx-5mg7 & v4.2.4, LangSmith Fleet / Cloud changelogs, Claude Code v2.1.326 / v2.1.332 & #103343, and MCP 2026-07-28 / SEP-2207). We did not run an independent OAuth concurrency load harness or production LangSmith/Claude Code telemetry benchmark.
Primary References
-
FastMCP Advisory
GHSA-78c8-3jhx-5mg7& Releasev4.2.4:https://github.com/PrefectHQ/fastmcp/security/advisories/GHSA-78c8-3jhx-5mg7,https://github.com/PrefectHQ/fastmcp/releases/tag/v4.2.4 -
LangSmith Cloud & Fleet Changelogs:
https://changelog.langchain.com/announcements/langchain-fleet-oauth-needs-reconnect-status-and-resilient-mcp-connections,https://docs.langchain.com/langsmith/fleet/changelog -
Anthropic Claude Code
CHANGELOG.md(v2.1.321,v2.1.326,v2.1.332) & Issue#103343:https://github.com/anthropics/claude-code/blob/main/CHANGELOG.md,https://github.com/anthropics/claude-code/issues/103343 -
MCP Authorization Specification (
2026-07-28,SEP-2207):https://modelcontextprotocol.io/specification/2026-07-28/basic/authorization
Top comments (0)