Better Auth OAuth Provider Authorization Bypass Vulnerability
An authorization bypass vulnerability exists in Better Auth's OAuth provider, allowing low-privilege users to create OAuth clients despite configured clientPrivileges, potentially leading to unauthorized client registration and increased phishing risks.
An authorization bypass vulnerability affects the OAuth provider component of Better Auth, specifically versions 1.4.8-beta.7 through 1.6.4 and 1.7.0-beta.0 through 1.7.0-beta.1. This flaw allows any authenticated, low-privilege user to create OAuth clients, bypassing the intended restrictions set by the clientPrivileges configuration. The vulnerability stems from the client creation endpoints (adminCreateOAuthClient and createOAuthClient) not enforcing the clientPrivileges check before creating new OAuth clients. This bypass allows attackers to register OAuth clients with attacker-controlled redirect URIs and metadata, potentially leading to phishing attacks and abuse of trust assumptions in OAuth/OIDC flows. Defenders should implement detections to identify unauthorized OAuth client creation attempts.
Attack Chain
- An attacker authenticates to the Better Auth application with a low-privilege account.
- The attacker crafts a POST request to either
/api/auth/oauth2/create-clientor a custom endpoint that routes toadminCreateOAuthClient. - The attacker includes parameters for
client_name,redirect_uris, and other client metadata within the POST request body. - The
createOAuthClientEndpointfunction is called without first performing aclientPrivilegesauthorization check. - A new OAuth client is created and persisted in the system.
- The attacker now controls a registered OAuth client with attacker-defined redirect URIs.
- The attacker can potentially use this client for phishing attacks or to bypass consent flows if
skip_consentis enabled (ifadminCreateOAuthClientis exposed). - The attacker exploits the newly created OAuth client to gain unauthorized access to resources or user data.
Impact
This vulnerability allows unauthorized users to create OAuth clients, potentially leading to several negative consequences. Attackers can register clients with malicious redirect URIs, which can be used in phishing campaigns to steal user credentials or OAuth tokens. In scenarios where the adminCreateOAuthClient endpoint is exposed, attackers can create clients that bypass user consent, further increasing the risk of successful attacks. The impact is significant because it breaks the intended access control mechanism of the clientPrivileges configuration, affecting applications that rely on it to restrict client registration. Successful exploitation can lead to unauthorized access to user data, compromised accounts, and damaged trust in the application.
Recommendation
- Monitor web server logs for POST requests to the
/api/auth/oauth2/create-clientendpoint, especially from users who should not have client creation privileges. Implement the “Detect Unauthorized OAuth Client Creation Attempt” Sigma rule below, using webserver logs (category: “webserver”, product: “linux”). - Apply the necessary patches to upgrade
@better-auth/oauth-providerto a version that addresses this vulnerability (>= 1.6.5 or >= 1.7.0-beta.2). - Audit your application’s OAuth client registration process to ensure that the
clientPrivilegescheck is enforced correctly. - If using
adminCreateOAuthClient, ensure it is not exposed to low-privilege authenticated users to prevent theskip_consentbypass. - Deploy the “Detect OAuth Client Creation with Skip Consent” Sigma rule if your deployment exposes the admin client creation endpoint.
Detection coverage 2
Detect Unauthorized OAuth Client Creation Attempt
highDetects attempts to create OAuth clients by users lacking the necessary privileges based on POST requests to the create-client endpoint.
Detect OAuth Client Creation with Skip Consent
mediumDetects OAuth client creation requests with the skip_consent parameter, which may indicate an attempt to bypass user consent.
Detection queries are kept inside the platform. Get full rules →