{"id":"CVE-2025-61928","aliases":["CVE-2025-61928","GHSA-99h5-pjcv-gr6v"],"related":[],"kind":"vulnerability","state":"published","title":"Better Auth: Unauthenticated API key creation through api-key plugin","summary":"Better Auth is an authentication and authorization library for TypeScript. In versions prior to 1.3.26, unauthenticated attackers can create or modify API keys for any user by passing that user's id in the request body to the `api/auth/api-key/create` route. `session?.user ?? (authRequired ? null : { id: ctx.body.userId })`. When no session exists but `userId` is present in the request body, `authRequired` becomes false and the user object is set to the attacker-controlled ID. Server-only field validation only executes when `authRequired` is true (lines 280-295), allowing attackers to set privileged fields. No additional authentication occurs before the database operation, so the malicious payload is accepted. The same pattern exists in the update endpoint. This is a critical authentication bypass enabling full an unauthenticated attacker can generate an API key for any user and immediately gain complete authenticated access. This allows the attacker to perform any action as the victim user using the api key, potentially compromise the user data and the application depending on the victim's privileges. Version 1.3.26 contains a patch for the issue.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"Better Auth is an authentication and authorization library for TypeScript. In versions prior to 1.3.26, unauthenticated attackers can create or modify API keys for any user by passing that user's id in the request body to the `api/auth/api-key/create` route. `session?.user ?? (authRequired ? null : { id: ctx.body.userId })`. When no session exists but `userId` is present in the request body, `authRequired` becomes false and the user object is set to the attacker-controlled ID. Server-only field validation only executes when `authRequired` is true (lines 280-295), allowing attackers to set privileged fields. No additional authentication occurs before the database operation, so the malicious payload is accepted. The same pattern exists in the update endpoint. This is a critical authentication bypass enabling full an unauthenticated attacker can generate an API key for any user and immediately gain complete authenticated access. This allows the attacker to perform any action as the victim user using the api key, potentially compromise the user data and the application depending on the victim's privileges. Version 1.3.26 contains a patch for the issue.","source":"cvelist"},{"lang":"en","text":"### **Summary**\n\nA critical authentication bypass was identified in the API key creation and update endpoints. An attacker could create or modify API keys for arbitrary users by supplying a victim’s user ID in the request body. Due to a flaw in how the authenticated user was derived, the endpoints could treat attacker-controlled input as an authenticated user object under certain conditions.\n\n### **Details**\n\nThe vulnerability originated from fallback logic used when determining the current user. When no session was present, the handler incorrectly allowed request-body data to populate the user context used for authorization decisions. Because server-side validation only executed when authentication was required, privileged fields were not properly protected. As a result, the API accepted unauthenticated requests that targeted other users.\n\nThis same pattern affected both the API key creation and update routes.\n\n### **Impact**\n\nUnauthenticated attackers could generate or modify API keys belonging to any user. This granted full authenticated access as the targeted user and, depending on the user’s privileges, could lead to account compromise, access to sensitive data, or broader application takeover.","format":"markdown","source":"ghsa"},{"lang":"es","text":"Better Auth es una biblioteca de autenticación y autorización para TypeScript. En versiones anteriores a la 1.3.26, atacantes no autenticados pueden crear o modificar claves API para cualquier usuario pasando el ID de ese usuario en el cuerpo de la solicitud a la ruta 'api/auth/api-key/create'. 'session?.user ?? (authRequired ? null : { id: ctx.body.userId })'. Cuando no existe ninguna sesión pero 'userId' está presente en el cuerpo de la solicitud, 'authRequired' se vuelve falso y el objeto de usuario se establece en el ID controlado por el atacante. La validación de campos solo del servidor solo se ejecuta cuando 'authRequired' es verdadero (líneas 280-295), permitiendo a los atacantes establecer campos privilegiados. No se produce ninguna autenticación adicional antes de la operación de la base de datos, por lo que la carga útil maliciosa es aceptada. El mismo patrón existe en el endpoint de actualización. Esto es una omisión de autenticación crítica que permite que un atacante no autenticado pueda generar una clave API para cualquier usuario y obtener inmediatamente acceso autenticado completo. Esto permite al atacante realizar cualquier acción como el usuario víctima utilizando la clave API, potencialmente comprometer los datos del usuario y la aplicación dependiendo de los privilegios de la víctima. La versión 1.3.26 contiene un parche para el problema.","source":"nvd"}],"published":"2025-10-09T15:40:50.000Z","modified":"2026-10-19T16:10:00.260Z","severity":{"scorer":"GitHub_M","scheme":"CVSS:4.0","vector":"CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N","score":9.3,"rating":"CRITICAL"},"severities":[{"scorer":"GitHub_M","scheme":"CVSS:4.0","vector":"CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N","score":9.3,"rating":"CRITICAL"},{"scorer":"GitHub","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:L/A:L","score":8.6,"rating":"HIGH"}],"cwes":["CWE-285","CWE-306"],"affected":[{"ranges":[{"version":"< 1.3.26","status":"affected"}],"vendor":"better-auth","product":"better-auth","source":"cvelist"},{"ranges":[{"type":"semver","introduced":"0","status":"affected","fixed":"1.3.26"}],"ecosystem":"npm","package":"better-auth","purl":"pkg:npm/better-auth","source":"ghsa"}],"references":[{"url":"https://github.com/better-auth/better-auth/security/advisories/GHSA-99h5-pjcv-gr6v","tags":["exploit","web","x-refsource-confirm"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/better-auth/better-auth/commit/556085067609c508f8c546ceef9003ee8c607d39","tags":["web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2025-61928","tags":["advisory"],"sources":["ghsa"]},{"url":"https://github.com/better-auth/better-auth","tags":["package"],"sources":["ghsa"]}],"credits":[],"assigner":"GitHub_M","ssvc":{"scorer":"CISA-ADP","exploitation":"poc","automatable":"yes","technicalImpact":"total","date":"2025-10-10T14:23:17.755Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2025-61928","url":"https://www.cve.org/CVERecord?id=CVE-2025-61928","licence":"CVE Terms of Use","modified":"2025-10-10T14:23:23.158Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-99h5-pjcv-gr6v","url":"https://github.com/advisories/GHSA-99h5-pjcv-gr6v","licence":"CC-BY-4.0","modified":"2025-12-09T17:46:14.760Z"},{"source":"nvd","name":"NVD","id":"CVE-2025-61928","url":"https://nvd.nist.gov/vuln/detail/CVE-2025-61928","licence":"Public domain","modified":"2026-10-19T16:10:00.260Z"}],"updatedAt":"2026-11-25T22:59:05.738Z","epss":{"score":0.17779,"percentile":0.97233,"date":"2026-12-01T12:00:22.000Z"}}