Jul 7, 2026·6 min read·20 visits
The OAuth provider fails to bind client-requested target resources to authorization codes and refresh tokens, allowing authenticated clients to escalate their access to any resource server in the validAudiences configuration list.
A security vulnerability in @better-auth/oauth-provider allows OAuth clients to obtain access tokens for unauthorized audiences due to unbound resource indicators. The implementation fails to bind the requested target resource to the initial authorization grant. Consequently, a client can request an access token targeting any resource server within the global allowlist, bypassing user consent boundaries.
The @better-auth/oauth-provider package, a component of the better-auth authentication framework, contains an authorization bypass flaw. The issue is located in the implementation of the RFC 8707 (Resource Indicators for OAuth 2.0) specification.
In a multi-resource server architecture, the authorization server must strictly limit the audience of an access token to the specific resources authorized by the user. Under RFC 8707, clients specify their target resource server via a resource query parameter during the authorization phase. The authorization server must capture this state and bind it to the resulting authorization grant.
Because the provider fails to persist the resource constraints between the authorization phase and the token exchange phase, clients can request access to any resource in the server configuration. The threat surface includes lateral access escalation across internal microservices and unauthorized access to downstream resource servers.
The core technical flaw stems from the complete decoupling of the authorization request parameter processing and the token generation logic. The provider ignores the resource parameter at the authorization endpoint (/oauth2/authorize). Because of this, the consent screens presented to the resource owner do not accurately reflect the specific resource servers the client will ultimately access.
Furthermore, the database schemas for authorization codes and refresh tokens lack fields to store stateful resource constraints. When an authorization code is successfully issued, it contains no reference to the resources that the user approved. This violates RFC 8707 Section 2.2, which dictates that the authorization server must record the authorized resources and ensure the subsequent token requests represent a subset of that initial grant.
When the client interacts with the /oauth2/token endpoint, the token generator reads the resource parameter directly from the request body. Instead of verifying this parameter against the authorization code's bound resource, the server evaluates it against a global config array called validAudiences. If the target is present in this global list, the server mints a JWT containing the target in the aud (audience) claim, completing the unauthorized access escalation.
To understand the implementation flaw, examine the conceptual behavior of the token exchange handler and database interaction. The vulnerable state persists because the data layer does not support multi-resource tracking.
Below is a representation of the vulnerable code pattern contrasted with the patched statefulness:
// Vulnerable Token Endpoint Logic
async function handleTokenExchange(req) {
const codeRecord = await db.findAuthCode(req.code);
const requestedResource = req.resource; // Obtained directly from the POST body
if (requestedResource) {
// BUG: The codeRecord has no 'resources' property.
// The check is performed globally, ignoring user-authorized boundaries.
if (!config.validAudiences.includes(requestedResource)) {
throw new OAuthError("invalid_target", "Resource not in global allowlist");
}
}
// Access token is minted for the arbitrary resource requested
return generateAccessToken({
sub: codeRecord.userId,
audience: requestedResource || config.defaultAudience
});
}The fix implements structural changes to store the approved resources into the database. When the /oauth2/token endpoint is queried, validation is performed directly against the database record instead of the global configuration.
// Patched Token Endpoint Logic
async function handleTokenExchange(req) {
const codeRecord = await db.findAuthCode(req.code); // Now retrieves stateful 'resources' array
const requestedResource = req.resource;
if (requestedResource) {
// FIX: Verify the requested resource is a subset of the authorized resources
if (!codeRecord.resources.includes(requestedResource)) {
throw new OAuthError("invalid_target", "The requested resource is not authorized for this grant");
}
}
return generateAccessToken({
sub: codeRecord.userId,
audience: requestedResource
});
}Exploitation of this vulnerability requires the target authorization server to configure multiple resources inside the validAudiences array. No custom exploitation tools are required, as standard OAuth library clients or command-line HTTP clients can trigger the flaw.
An attacker controls a registered OAuth client. The target server has configured https://api.billing.example.com (sensitive) and https://api.stats.example.com (public) in its global allowlist. The attacker initiates the standard authorization flow targeting the public API.
After obtaining the authorization code, the client sends a token request to /oauth2/token but overrides the resource field to point to the sensitive billing API. Because there is no check linking the code to the initial scope, the server returns an access token possessing an audience claim (aud) set to the sensitive billing system.
POST /oauth2/token HTTP/1.1
Host: auth.example.com
Content-Type: application/x-www-form-urlencoded
grant_type=authorization_code&
code=AUTHORIZATION_CODE_HERE&
redirect_uri=https://client.example.com/callback&
client_id=CLIENT_ID&
client_secret=CLIENT_SECRET&
resource=https://api.billing.example.comThe same technique applies to refresh token grants. If a client possesses a valid refresh token, it can issue a refresh request with a modified resource parameter, pivoting its audience access to any target server inside the validAudiences array without prompting the user for consent.
This vulnerability breaks the security boundaries enforced by OAuth consent screens. While the authorization server attempts to maintain a list of valid audiences via configuration, the failure to bind those audiences to specific authorization transactions compromises the isolation of multi-tenant or multi-resource API environments.
If the authorization server is used to authenticate users across both low-security and high-security internal services, any client compromised by an attacker can escalate access tokens to gain privileges on the high-security APIs. This bypasses the zero-trust principle where resource servers rely on the correctness of the token audience claim to deny access to unauthorized clients.
From a CVSS perspective, the vulnerability is classified as Medium (6.4). The attack complexity is low, and no user interaction is required after the initial login. However, the scope of impact changes (Scope: Changed) because the failure allows the client to gain unauthorized privileges on external downstream systems (the resource servers).
The definitive solution is to upgrade to @better-auth/oauth-provider@1.7.0 (or @better-auth/oauth-provider@1.7.0-beta.4). The updated release implements stateful database storage for resource lists and enforces strict subset checks during token exchanges.
Because the patch introduces database schema modifications to track authorized resource boundaries, running migrations is mandatory. Administrators must run the database migration utilities to apply the structural changes.
npx auth migrateFor environments where upgrading is not immediately possible, implement the following workarounds:
validAudiences configuration array to a single, global entry. When only one resource is allowed, cross-resource escalation becomes impossible./oauth2/token endpoint to block requests containing a resource parameter that differs from the default client authorization parameters.CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:C/C:L/I:L/A:N| Product | Affected Versions | Fixed Version |
|---|---|---|
@better-auth/oauth-provider better-auth | >= 1.4.8, < 1.7.0-beta.4 | 1.7.0-beta.4 |
| Attribute | Detail |
|---|---|
| CWE ID | CWE-863 |
| Attack Vector | Network |
| CVSS v3.1 Score | 6.4 |
| Exploit Status | none |
| CISA KEV Status | Not Listed |
| Impact | Incorrect Authorization (Audience Escalation) |
The software performs authorization checks but implements them incorrectly, allowing an actor to access restricted resources or execute unauthorized actions.
A critical remote code execution vulnerability (CVE-2026-102828) exists in simple-git versions 3.15.0 through 4.0.0. The vulnerability is caused by an incomplete blocklist within the library's default safety enforcement plugin, blockUnsafeOperationsPlugin. Attackers who can control Git configuration arguments or supply command flags to rebase operations can execute arbitrary system commands with the privileges of the parent Node.js process.
A critical security control bypass vulnerability exists in @simple-git/argv-parser before version 2.0.1. The package fails to map the VISUAL environment variable to the allowUnsafeEditor rule, allowing attackers who control environment parameters to execute arbitrary commands when Git triggers an interactive editor fallback.
A vulnerability in vLLM prior to 0.30.0 allows an authenticated multi-tenant attacker to infer execution history and prompt structures of other tenants. The multi-turn Responses API ('Harmony' path) fails to propagate the 'cache_salt' parameter during tool-call continuation steps, storing sensitive prompt prefixes in the global, unsalted cache space.
A state desynchronization (cache drift) vulnerability exists in the multimodal Inter-Process Communication (IPC) Least Recently Used (LRU) caches of vLLM. When a multimodal request fails validation after its media hash has been registered on the frontend but before the payload is committed to the backend engine core, the frontend and backend caches drift out of lockstep. A subsequent request reusing the same media triggers an assertion failure in the backend engine core, resulting in a complete denial of service.
CVE-2026-105750 is a medium-severity local file disclosure vulnerability affecting the Docling and Docling-Slim libraries. When processing HTML documents using the optional Playwright rendering backend, the application fail to validate and restrict request URIs using the file:// scheme. This permits an attacker supplying a crafted HTML file to access, render, and exfiltrate local system files.
CVE-2026-102598 is a security bypass and Denial of Service (DoS) vulnerability in the Werkzeug WSGI web application library. In versions prior to 3.1.9, the library's safe_join function fails to sanitize Windows reserved device names containing an empty NTFS Alternate Data Stream (ADS) marker (such as NUL:). This allows remote, unauthenticated attackers to trigger indefinite thread-blocking operations on Windows hosts, resulting in application-wide resource exhaustion.