CVE-2026-53518: better-auth: race condition mints duplicate OAuth tokens

GHSA-7w99-5wm4-3g79 HIGH
Published July 7, 2026
CISO Take

better-auth's OAuth/OIDC token endpoint — including the paths used by MCP servers to authenticate Claude Desktop and other AI agent tool callers — redeems single-use authorization codes through a non-atomic read-then-delete sequence, so two concurrent requests carrying the same code can both slip past the check and each mint an independent access, refresh, and id token instead of one succeeding and the second being rejected. This matters anywhere better-auth (directly, via @better-auth/oauth-provider, or through the legacy oidc-provider/mcp plugins) fronts a token endpoint reachable by internal MCP clients or third-party OAuth apps: a successful race hands an attacker a fully valid, independently-revocable token set forked from someone else's authorization, without tripping standard single-use-code detection. The CVSS score is high (8.1, network vector, no privileges required, confidentiality and integrity impact) but real-world exploitation pressure is currently low — EPSS is negligible, it isn't in CISA KEV, and there's no public exploit or Nuclei template — so this is a patch-now item, not an active-incident one. Given better-auth's growing footprint as the identity layer in front of self-hosted MCP servers and agent tool-calling infrastructure, treat this as priority patching rather than waiting for exploitation telemetry, since a successful attacker gets a persistent, independently-valid credential into whatever the original authorization scoped. Upgrade to better-auth / @better-auth/oauth-provider 1.6.11 or later immediately; if an immediate upgrade isn't possible, add a shared idempotency cache or database uniqueness constraint keyed on the authorization code as a stopgap and audit auth logs for duplicate token issuance tied to a single code.

Sources: NVD GitHub Advisory EPSS CISA KEV ATLAS

What is the risk?

High severity (CVSS 8.1) but currently low exploitation pressure: EPSS is negligible (0.00029), the CVE is not in CISA KEV, no public exploit or Nuclei template exists, and CISA SSVC data is unavailable — indicating no evidence of active or automated exploitation today. The risk profile is asymmetric to its likelihood, however: exploitation requires no privileges and only network access plus the ability to fire two near-simultaneous requests with a captured authorization code, which is a low technical bar for anyone already positioned to intercept or race the code parameter (e.g., a malicious MCP tool, a compromised redirect target, or a network-adjacent attacker). The blast radius is amplified by the fact that the same vulnerable primitive (find-then-delete on a single-use verification row) is reused at 20+ call sites in the codebase, meaning the underlying architectural weakness is broader than this single endpoint even though only the OAuth token exchange is fixed in 1.6.11. Because better-auth explicitly documents MCP clients (Claude Desktop, custom MCP tool callers, AI agents) as consumers of this exact endpoint, organizations using better-auth to gate access to AI agent tooling should weight this higher than the CVSS-only score suggests.

How does the attack unfold?

Code Interception / Positioning
Attacker obtains or races a legitimate single-use authorization code destined for the OAuth/OIDC token endpoint, e.g. via a malicious MCP tool, compromised redirect, or network-adjacent position during an AI agent's OAuth flow.
Race Exploitation
Attacker fires two concurrent POST requests to /oauth2/token with the same code; both pass the non-atomic read step before either deletion completes, then both clear PKCE verification.
Duplicate Token Issuance
Both requests reach createUserTokens and each mints an independent, fully valid access/refresh/id token set scoped to the original authorization, evading single-use-code detection.
AML.T0091.000
Persistent Unauthorized Access
Attacker retains one forked token set to independently access MCP tools, agent resources, or downstream APIs the victim's session was authorized for, surviving revocation of the legitimate token.
AML.T0091.000

What systems are affected?

Package Ecosystem Vulnerable Range Patched
@better-auth/oauth-provider npm >= 1.6.0, < 1.6.11 1.6.11
better-auth npm < 1.6.11 1.6.11

How severe is it?

CVSS 3.1
8.1 / 10
EPSS
0.4%
chance of exploitation in 30 days
Higher than 34% of all CVEs
Exploitation Status
No known exploitation
Sophistication
Moderate

What is the attack surface?

AV AC PR UI S C I A
AV Network
AC Low
PR None
UI Required
S Unchanged
C High
I High
A None

What should I do?

1 step
  1. 1) Upgrade @better-auth/oauth-provider to 1.6.11+, or better-auth to 1.6.11+ if using the legacy oidc-provider/mcp plugin paths — this is the only complete fix, replacing the find-then-delete pattern with the atomic consumeVerificationValue/claimVerificationByIdentifier primitive. 2) If an immediate upgrade isn't feasible, deploy a stopgap: a shared (Redis-backed, not per-instance) reverse-proxy idempotency cache keyed on the code parameter that serializes concurrent redemption attempts, or a database-layer uniqueness constraint preventing two token rows from being created off the same upstream authorization code. 3) As a last resort, fork deleteVerificationByIdentifier to use adapter.deleteMany and check the returned row count, rejecting with invalid_grant when it's zero (requires forking the internal adapter — fragile, upgrade instead). 4) Detection: audit authentication logs and the oauthAccessToken/token-issuance tables for multiple token sets issued against the same authorization code or unusually close-timestamped token exchanges from the same client/user pair — this is the forensic signature of a successful race. 5) Since the same find-then-delete primitive exists at 20+ other call sites in better-auth, review release notes for the highest-impact variant sites migrated in 1.6.11 and confirm your deployment doesn't rely on any unmigrated legacy path.

What does CISA's SSVC say?

Decision Track
Exploitation none
Automatable No
Technical Impact total

Source: CISA Vulnrichment (SSVC v2.0). Decision based on the CISA Coordinator decision tree.

How is it classified?

Auth Bypass Data Leakage Agent API Framework AML.T0091.000

Which compliance frameworks are affected?

This CVE is relevant to:

ISO 42001
A.6.2.6 - AI system security
NIST AI RMF
MEASURE 2.7 - AI system security and resilience evaluated and documented
OWASP LLM Top 10
LLM07 - Insecure Plugin Design

Frequently Asked Questions

What is CVE-2026-53518?

better-auth's OAuth/OIDC token endpoint — including the paths used by MCP servers to authenticate Claude Desktop and other AI agent tool callers — redeems single-use authorization codes through a non-atomic read-then-delete sequence, so two concurrent requests carrying the same code can both slip past the check and each mint an independent access, refresh, and id token instead of one succeeding and the second being rejected. This matters anywhere better-auth (directly, via @better-auth/oauth-provider, or through the legacy oidc-provider/mcp plugins) fronts a token endpoint reachable by internal MCP clients or third-party OAuth apps: a successful race hands an attacker a fully valid, independently-revocable token set forked from someone else's authorization, without tripping standard single-use-code detection. The CVSS score is high (8.1, network vector, no privileges required, confidentiality and integrity impact) but real-world exploitation pressure is currently low — EPSS is negligible, it isn't in CISA KEV, and there's no public exploit or Nuclei template — so this is a patch-now item, not an active-incident one. Given better-auth's growing footprint as the identity layer in front of self-hosted MCP servers and agent tool-calling infrastructure, treat this as priority patching rather than waiting for exploitation telemetry, since a successful attacker gets a persistent, independently-valid credential into whatever the original authorization scoped. Upgrade to better-auth / @better-auth/oauth-provider 1.6.11 or later immediately; if an immediate upgrade isn't possible, add a shared idempotency cache or database uniqueness constraint keyed on the authorization code as a stopgap and audit auth logs for duplicate token issuance tied to a single code.

Is CVE-2026-53518 actively exploited?

No confirmed active exploitation of CVE-2026-53518 has been reported, but organizations should still patch proactively.

How to fix CVE-2026-53518?

1) Upgrade `@better-auth/oauth-provider` to 1.6.11+, or `better-auth` to 1.6.11+ if using the legacy `oidc-provider`/`mcp` plugin paths — this is the only complete fix, replacing the find-then-delete pattern with the atomic `consumeVerificationValue`/`claimVerificationByIdentifier` primitive. 2) If an immediate upgrade isn't feasible, deploy a stopgap: a shared (Redis-backed, not per-instance) reverse-proxy idempotency cache keyed on the `code` parameter that serializes concurrent redemption attempts, or a database-layer uniqueness constraint preventing two token rows from being created off the same upstream authorization code. 3) As a last resort, fork `deleteVerificationByIdentifier` to use `adapter.deleteMany` and check the returned row count, rejecting with `invalid_grant` when it's zero (requires forking the internal adapter — fragile, upgrade instead). 4) Detection: audit authentication logs and the `oauthAccessToken`/token-issuance tables for multiple token sets issued against the same authorization code or unusually close-timestamped token exchanges from the same client/user pair — this is the forensic signature of a successful race. 5) Since the same find-then-delete primitive exists at 20+ other call sites in better-auth, review release notes for the highest-impact variant sites migrated in 1.6.11 and confirm your deployment doesn't rely on any unmigrated legacy path.

What systems are affected by CVE-2026-53518?

This vulnerability affects the following AI/ML architecture patterns: agent frameworks, MCP/tool-calling infrastructure, OAuth/OIDC identity layer for AI agents, API/service authentication.

What is the CVSS score for CVE-2026-53518?

CVE-2026-53518 has a CVSS v3.1 base score of 8.1 (HIGH). The EPSS exploitation probability is 0.41%.

What is the AI security impact?

Affected AI Architectures

agent frameworksMCP/tool-calling infrastructureOAuth/OIDC identity layer for AI agentsAPI/service authentication

MITRE ATLAS Techniques

AML.T0091.000 Application Access Token

Compliance Controls Affected

ISO 42001: A.6.2.6
NIST AI RMF: MEASURE 2.7
OWASP LLM Top 10: LLM07

What are the technical details?

Original Advisory

### Am I affected? Users are affected if all of the following are true: - Their project depends on `@better-auth/oauth-provider` at a version `>= 1.6.0, < 1.6.11`, or uses the embedded plugin in `better-auth >= 1.4.8-beta.7, < 1.6.0`, or enables the legacy `oidc-provider` or `mcp` plugins from `better-auth/plugins`. - Their application exposes `/api/auth/oauth2/token` (or the legacy plugins' `/oauth2/token` and `/mcp/token`) as a token endpoint to OAuth/OIDC clients, including internal MCP clients (Claude Desktop, custom MCP tool callers, AI agents). - Their application has not implemented an external mitigation: a load-balancer-level idempotency cache keyed by `code`, a database trigger that rejects duplicate token issuance for the same authorization code, or a custom adapter override that performs an atomic compare-and-delete. Fix: 1. Upgrade to `@better-auth/oauth-provider@1.6.11` or later. If developers use the legacy plugin paths from `better-auth/plugins`, upgrade `better-auth` to `1.6.11` or later. 2. If developers cannot upgrade, see workarounds below. ### Summary The OAuth provider's `POST /oauth2/token` endpoint, on the `authorization_code` grant, redeems a single-use authorization code through a non-atomic find-then-delete sequence. Two concurrent requests with the same `code` value both pass the read step before either delete completes, then both proceed to PKCE verification and `createUserTokens`. Each surviving request mints a fresh access token, refresh token, and id token. RFC 6749 §4.1.2 requires authorization codes to be single-use; this primitive does not enforce that under concurrency. ### Details The same architectural primitive (find a single-use verification row, then delete it, then trust the row to authorize) is used in 20 other call sites across the codebase. The deletion primitive returns `Promise<void>`, discarding the row count surfaced by `adapter.deleteMany`, so no call site can detect "another caller already claimed this row". The fix lands at the primitive layer rather than at any individual call site. The fix introduces a `claimVerificationByIdentifier` primitive at the internal-adapter layer that performs an atomic claim-and-return, replaces the find-then-delete pair at this call site, and migrates the highest-impact variant sites in the same release. ### Patches Fixed in `@better-auth/oauth-provider@1.6.11` and `better-auth@1.6.11` for the legacy `oidc-provider` and `mcp` plugin paths. All three token-exchange call sites now consume the verification row through `internalAdapter.consumeVerificationValue`, an atomic claim primitive that deletes the row and returns its prior value in one operation. The first request to arrive takes the row and mints tokens; concurrent racers observe an empty result and return `invalid_grant`. Error-code consistency is also tightened on the `@better-auth/oauth-provider` token endpoint: the malformed-verification-value branches previously returned a project-specific `invalid_verification` code, which is not part of RFC 6749 §5.2's response error set. Both branches now return `invalid_grant` so spec-compliant clients can branch on the standard code without a special case. ### Workarounds None of these close the bug fully without a code patch. Upgrading is the only good path. - **Network-layer**: deploy an authorization-server-aware reverse proxy (Envoy, NGINX with Lua, custom Cloudflare Worker) that holds an in-flight registry keyed by the `code` parameter and serializes concurrent requests for the same code. Fragile under multi-instance deployments unless the registry is shared (Redis-backed). - **Database-layer**: add a SQL or Mongo uniqueness constraint that prevents two `oauthAccessToken` rows from being created with the same upstream code reference. Adapter-specific and not always feasible since the schema does not currently store the source code. - **Application-layer**: wrap `deleteVerificationByIdentifier` with a custom hook that uses `adapter.deleteMany` and surfaces the count, then injects an `invalid_grant` rejection when the count is zero. Requires forking the internal adapter. ### Impact - **Multiple independent token sets from a single authorization**: forked access tokens, refresh tokens, and id tokens issued from the same code, all valid for the original user's authorization scope. - **Detection bypass**: standard OAuth single-use enforcement does not fire for the second redemption when both requests interleave through the read step. - **Legacy-plugin reach**: `oidc-provider` and `mcp` plugins share the primitive on the same surface, so deployments using them inherit the same impact. ### Credit Reported by @chdanielmueller. ### Resources - [CWE-362: Concurrent Execution using Shared Resource with Improper Synchronization (Race Condition)](https://cwe.mitre.org/data/definitions/362.html) - [CWE-367: Time-of-check Time-of-use (TOCTOU) Race Condition](https://cwe.mitre.org/data/definitions/367.html) - [CWE-294: Authentication Bypass by Capture-replay](https://cwe.mitre.org/data/definitions/294.html) - [RFC 6749 §4.1.2: Authorization Response](https://datatracker.ietf.org/doc/html/rfc6749#section-4.1.2) - [OAuth 2.1 §4.1: Authorization Code Grant](https://datatracker.ietf.org/doc/html/draft-ietf-oauth-v2-1#section-4.1)

Exploitation Scenario

An attacker who can observe or briefly intercept an authorization `code` en route to the token endpoint — for example, via a malicious or compromised MCP tool integration, a network-adjacent position, or a leaked redirect URI in an AI agent's OAuth flow — fires two near-simultaneous `POST /api/auth/oauth2/token` requests using the same `code` value under the `authorization_code` grant. Because the verification row is read before either request's delete completes, both requests pass PKCE verification and both reach `createUserTokens`, each minting an independent, fully valid access token, refresh token, and id token scoped to the victim's original authorization. The attacker keeps one token set as a durable, independently-valid credential into whatever MCP tools, APIs, or data the victim's AI agent session was authorized to reach — and because it's a separate token, revoking the legitimate client's session does not invalidate the attacker's copy, giving them standing access until the underlying tokens expire or are separately discovered and revoked.

Weaknesses (CWE)

CWE-294 — Authentication Bypass by Capture-replay: A capture-replay flaw exists when the design of the product makes it possible for a malicious user to sniff network traffic and bypass authentication by replaying it to the server in question to the same effect as the original message (or with minor changes).

  • [Architecture and Design] Utilize some sequence or time stamping functionality along with a checksum which takes this into account in order to ensure that messages can be parsed only once.
  • [Architecture and Design] Since any attacker who can listen to traffic can see sequence numbers, it is necessary to sign messages with some kind of cryptography to ensure that sequence numbers are not simply doctored along with content.

Source: MITRE CWE corpus.

CVSS Vector

CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:N

Timeline

Published
July 7, 2026
Last Modified
July 15, 2026
First Seen
July 8, 2026

Related Vulnerabilities