Логотип exploitDog
Консоль
Логотип exploitDog

exploitDog

github логотип

GHSA-99h5-pjcv-gr6v

Опубликовано: 09 окт. 2025
Источник: github
Github: Прошло ревью
CVSS3: 8.6

Описание

Better Auth: Unauthenticated API key creation through api-key plugin

Summary

A 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.

Details

The 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.

This same pattern affected both the API key creation and update routes.

Impact

Unauthenticated 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.

Пакеты

Наименование

better-auth

npm
Затронутые версииВерсия исправления

< 1.3.26

1.3.26

EPSS

Процентиль: 41%
0.00191
Низкий

8.6 High

CVSS3

Дефекты

CWE-285
CWE-306

Связанные уязвимости

nvd
4 месяца назад

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

EPSS

Процентиль: 41%
0.00191
Низкий

8.6 High

CVSS3

Дефекты

CWE-285
CWE-306