Critical Authentication Bypass in better-auth API Keys Plugin Allows Unauthenticated Account Takeover
A critical authentication bypass vulnerability has been identified in the better-auth API keys plugin. This flaw allows unauthenticated attackers to generate privileged API keys for arbitrary users.
A critical authentication bypass vulnerability has been identified in the better-auth API keys plugin. This flaw allows unauthenticated attackers to generate privileged API keys for arbitrary users.
The vulnerability, designated as CVE-2025-61928, affects all versions of the better-auth library prior to version 1.3.26. This library is widely used, with approximately 300,000 weekly npm downloads, and is integral to the authentication processes of various organizations.
The Vulnerability and Exploitation Path
ZeroPath discovered that the vulnerability is located in the createApiKey handler within the API keys plugin. The handler uses a conditional to determine if authentication is necessary, based on the presence of a session and a userId field in the request body.
If no session exists but a userId is provided, the authRequired variable evaluates to false . This bypasses the validation branch that normally blocks privileged fields such as rateLimitMax , remaining , refillAmount , and permissions .
An unauthenticated attacker can exploit this by sending a POST request to /api/auth/api-key/create with a victim's user ID, receiving a valid API key bound to that account.
A critical authentication bypass vulnerability has been identified in the better-auth API keys plugin.
The logic flaw also affects the updateApiKey handler, broadening the attack surface to credential modification. All previous releases containing the API keys plugin are vulnerable.
This issue is significant because API keys typically have longer lifespans than browser sessions and often possess elevated privileges, allowing attackers to bypass multi-factor authentication and potentially take over accounts.
Organizations utilizing the better-auth API keys plugin should upgrade to version 1.3.26 or later, which corrects the authorization flaw. Post-upgrade, all API keys generated during the vulnerability window should be rotated, and unused credentials invalidated.
It is advisable to review application and reverse-proxy logs for unauthorized calls to /api/auth/api-key/create or /api/auth/api-key/update , particularly those lacking authenticated session cookies and containing userId , rateLimitMax , or permissions fields.
Any suspicious log activity should prompt a full credential reissuance for affected accounts, with subsequent monitoring for API usage from unfamiliar IPs or service tokens.
Following responsible disclosure, better-auth's maintainers rapidly released a patch within 24 hours. The GitHub Security Advisory GHSA-99h5-pjcv-gr6v and CVE-2025-61928 were published soon after, demonstrating prompt vendor responsiveness.
Based on reporting by Cyber Security News.
