FastMCP 4.2.4 fixes duplicate token issuance with the same credentials in its OAuth proxy, a server that forwards external authentication requests. Developers using this proxy can reduce the risk of duplicate sessions by updating. The update also prevents access tokens revoked after a refresh from becoming valid again.
1. Two sessions from the same credentials
Authorization codes are designed for single use, but earlier FastMCP versions could issue tokens to two requests submitting the same code almost simultaneously. Like two ticket counters admitting two people with one ticket, another request could read the code before the first request deleted it.
The tokens created by the two requests represent separate sessions. According to the advisory, an attacker who intercepts a code and its PKCE verifier can obtain a session alongside the victim. The verifier is a value submitted with the code to protect its exchange. Both sessions have the same scope, defining the actions allowed by the service. Revoking the victim's session could leave the attacker's session active.
2. Refresh tokens and revoked access tokens are also affected
The same concurrency issue affected refresh token exchanges. If the upstream provider handling authentication does not rotate refresh tokens, two concurrent requests using the same token can each obtain independently usable successor refresh tokens. This could let a stolen refresh token survive a legitimate user's refresh.
The release also includes a separate OAuth fix. It prevents revoked proxy access tokens from being validated as valid again after a refresh completes. The security changes thus address both duplicate issuance and preservation of revoked status.
3. Default configurations are also affected
The advisory identifies versions 2.13.0 through 4.2.3 as affected, with the fix in this release. The default configuration uses a disk-based store, so it is affected even without a custom store.
In the advisory's reproduction tests on 4.1.0, the default disk store produced duplicate issuance in 18 of 20 trials with 2 concurrent requests and in 20 trials with 5 requests. The following results come from a Redis reproduction script sending 2 concurrent requests with the same code. The in-memory store was also tested for comparison.
FastMCP 4.1.0, authcode_race.py, Redis 7-alpine, 2 concurrent exchange requests using the same authorization code, 20 trials per configuration
| Store configuration | Trials with duplicate issuance |
|---|---|
| Shared Redis with 2 server replicas, copies performing the same function | 19 |
| Redis with 1 server | 19 |
| In-memory, single process | 0 |
With concurrency increased to 5 requests in the same script, the single Redis store produced duplicate issuance in all 20 trials, while the in-memory store produced none. The in-memory store did not yield execution to other requests during reads, preventing duplicate exchanges. The advisory notes that results with 2 concurrent requests can vary between runs.
4. Behavior changes after updating
For both authorization codes and refresh tokens, 4.2.4 lets only the request that actually deletes the stored record succeed, rejecting others with invalid_grant. This allows only one request through even with stores shared by multiple server replicas, such as Redis.
The refresh token record is consumed after the upstream server successfully refreshes the token. This allows retries when a temporary upstream error causes a refresh to fail.
The following old code from the advisory read and then deleted the authorization code without checking whether deletion succeeded.
code_model = await self._code_store.get(key=authorization_code.code) # 1314
if not code_model:
raise TokenError("invalid_grant", "Authorization code not found")
# expires_in reject guard + scope translation; no await, no lock
await self._code_store.delete(key=authorization_code.code) # 13505. Security improvements and potential request failures
Blocking duplicate exchanges prevents multiple independent sessions from a single code and keeps access tokens revoked after a refresh. However, requests that resubmit a consumed code fail with invalid_grant rather than succeeding. Clients sending overlapping requests should check their behavior after updating, as duplicate retries may now surface as errors.
FastMCP 4.2.4 is a security update that enforces single-use tokens under concurrent requests and preserves revoked status.
