Better Auth API keys Vulnerability Let Attackers Create Privileged Credentials For Arbitrary Users
A critical vulnerability, identified as CVE-2025-61928, has been discovered in the better-auth library's API keys plugin. This vulnerability allows attackers to generate privileged credentials for any user without authentication.
A critical vulnerability, identified as CVE-2025-61928, has been discovered in the better-auth library's API keys plugin. This vulnerability allows attackers to generate privileged credentials for any user without authentication.
The issue affects better-auth, a TypeScript authentication framework with approximately 300,000 weekly downloads on npm. The flaw poses a risk of widespread account compromises, especially for applications that utilize API keys for automated access. The better-auth library is used by both startups and large enterprises, including Equinor.
The vulnerability originates from the createApiKey handler within the plugin. Typically, this function derives user context from an active session to ensure security checks. However, if a request lacks a session but contains a userId in the body, the code erroneously sets an "authRequired" flag to false, bypassing critical validations and allowing the handler to create a user object from attacker-supplied data.
As a result, unauthorized attackers can send POST requests to the /api/auth/api-key/create endpoint with a target user's ID, name, and optional privileged fields such as rate limits or permissions. The response returns a valid API key linked to the victim's account, bypassing multi-factor authentication and enabling unauthorized access. The vulnerability also affects update endpoints, increasing the risk.
A critical vulnerability, identified as CVE-2025-61928, has been discovered in the better-auth library's API keys plugin.
API keys often provide long-term, elevated privileges for automation, making this vulnerability particularly dangerous. Attackers could impersonate users, access sensitive data, or conduct malicious activities across services.
Only deployments utilizing the API keys plugin are affected. Due to the wide adoption of better-auth, the exposure is significant. It is advised to upgrade to better-auth version 1.3.26 or later, which addresses the authorization check issue.
Users are recommended to rotate all API keys created via the plugin, invalidate unused keys, and audit logs for suspicious unauthenticated requests to create or update endpoints, particularly those involving userId or high-privilege values.
The maintainers promptly addressed the issue following its disclosure on Mon, Oct 2, 2023. The advisory ( GHSA-99h5-pjcv-gr6v ) was published on Sun, Oct 8, 2023, via GitHub, and the CVE was assigned the following day.
Based on reporting by Cyber Security News.
