GHSA-7w99-5wm4-3g79: @better-auth/oauth-provider's OAuth authorization-code grant allows concurrent redemption when two token requests race the find-then-delete primitive
A race condition in @better-auth/oauth-provider versions >=1.6.0 and <1.6.11 allows concurrent redemption of the same OAuth authorization code. This occurs because the token endpoint uses a non-atomic find-then-delete operation to consume single-use authorization codes, enabling multiple token sets to be issued from one code. The issue also affects legacy plugins in better-auth versions >=1.4.8-beta.7 and <1.6.0. The vulnerability violates RFC 6749's single-use code requirement and can lead to multiple valid tokens from a single authorization code.
AI Analysis
Technical Summary
The OAuth provider's POST /oauth2/token endpoint for the authorization_code grant uses a non-atomic find-then-delete sequence to redeem single-use authorization codes. When two concurrent requests race, both can read the code before either deletes it, resulting in both requests successfully minting access, refresh, and ID tokens. This breaks the single-use guarantee mandated by RFC 6749 §4.1.2. The root cause is that the deletion primitive discards the row count, preventing detection of concurrent claims. The fix, introduced in version 1.6.11, replaces this with an atomic claimVerificationByIdentifier primitive that atomically claims and deletes the verification row, ensuring only the first request succeeds and others receive an invalid_grant error. Legacy plugins oidc-provider and mcp share this vulnerability and are fixed in better-auth 1.6.11. Workarounds at network, database, or application layers exist but do not fully resolve the issue without upgrading.
Potential Impact
Multiple independent token sets (access, refresh, and ID tokens) can be issued from a single authorization code, violating the OAuth 2.0 specification's single-use code requirement. This allows bypassing detection mechanisms that rely on single redemption, potentially enabling token duplication and unauthorized token use within the original user's authorization scope. The vulnerability affects both the main OAuth provider and legacy plugins, increasing the attack surface for affected deployments.
Mitigation Recommendations
An official fix is available by upgrading to @better-auth/oauth-provider version 1.6.11 or later. For legacy plugin users, upgrade better-auth to version 1.6.11 or later. No workaround fully closes the vulnerability without applying the patch. Temporary mitigations include deploying a reverse proxy that serializes token requests by authorization code, adding database uniqueness constraints on token issuance (if feasible), or implementing custom adapter hooks to detect duplicate claims; however, these are fragile and not recommended as sole solutions. Upgrading remains the only reliable remediation.
GHSA-7w99-5wm4-3g79: @better-auth/oauth-provider's OAuth authorization-code grant allows concurrent redemption when two token requests race the find-then-delete primitive
Description
A race condition in @better-auth/oauth-provider versions >=1.6.0 and <1.6.11 allows concurrent redemption of the same OAuth authorization code. This occurs because the token endpoint uses a non-atomic find-then-delete operation to consume single-use authorization codes, enabling multiple token sets to be issued from one code. The issue also affects legacy plugins in better-auth versions >=1.4.8-beta.7 and <1.6.0. The vulnerability violates RFC 6749's single-use code requirement and can lead to multiple valid tokens from a single authorization code.
CVSS v4.0
Affected software
Run on your own infrastructure? Check whether these packages are installed with threat-finder — our free open-source scanner.
AI-Powered Analysis
Machine-generated threat intelligence
Technical Analysis
The OAuth provider's POST /oauth2/token endpoint for the authorization_code grant uses a non-atomic find-then-delete sequence to redeem single-use authorization codes. When two concurrent requests race, both can read the code before either deletes it, resulting in both requests successfully minting access, refresh, and ID tokens. This breaks the single-use guarantee mandated by RFC 6749 §4.1.2. The root cause is that the deletion primitive discards the row count, preventing detection of concurrent claims. The fix, introduced in version 1.6.11, replaces this with an atomic claimVerificationByIdentifier primitive that atomically claims and deletes the verification row, ensuring only the first request succeeds and others receive an invalid_grant error. Legacy plugins oidc-provider and mcp share this vulnerability and are fixed in better-auth 1.6.11. Workarounds at network, database, or application layers exist but do not fully resolve the issue without upgrading.
Potential Impact
Multiple independent token sets (access, refresh, and ID tokens) can be issued from a single authorization code, violating the OAuth 2.0 specification's single-use code requirement. This allows bypassing detection mechanisms that rely on single redemption, potentially enabling token duplication and unauthorized token use within the original user's authorization scope. The vulnerability affects both the main OAuth provider and legacy plugins, increasing the attack surface for affected deployments.
Mitigation Recommendations
An official fix is available by upgrading to @better-auth/oauth-provider version 1.6.11 or later. For legacy plugin users, upgrade better-auth to version 1.6.11 or later. No workaround fully closes the vulnerability without applying the patch. Temporary mitigations include deploying a reverse proxy that serializes token requests by authorization code, adding database uniqueness constraints on token issuance (if feasible), or implementing custom adapter hooks to detect duplicate claims; however, these are fragile and not recommended as sole solutions. Upgrading remains the only reliable remediation.
Technical Details
- Gcve Source
- db.gcve.eu
- Osv Id
- GHSA-7w99-5wm4-3g79
- Osv Schema Version
- 1.4.0
- Aliases
- ["CVE-2026-53518"]
- Ecosystems
- ["npm"]
- Database Specific Severity
- HIGH
- Cvss Version
- 4.0
Threat ID: 6a4e4ef7c9d9e3dbe328cbfc
Added to database: 07/08/2026, 13:21:59 UTC
Last enriched: 07/08/2026, 13:44:18 UTC
Last updated: 07/08/2026, 15:01:35 UTC
Views: 3
Community Reviews
0 reviewsCrowdsource mitigation strategies, share intel context, and vote on the most helpful responses. Sign in to add your voice and help keep defenders ahead.
Want to contribute mitigation steps or threat intel context? Sign in or create an account to join the community discussion.
Actions
Updates to AI analysis require Pro Console access. Upgrade inside Console → Billing.
Need more coverage?
Upgrade to Pro Console for AI refresh and higher limits.
For incident response and remediation, OffSeq services can help resolve threats faster.
Latest Threats
Check if your credentials are on the dark web
Instant breach scanning across billions of leaked records. Free tier available.