Better Auth session mix-up via MySQL/MariaDB serial ID race condition (CVE-2026-134313)
Better Auth before 1.7.16 and 1.8.0-beta.0 before 1.8.0-beta.5 has a race condition when using MySQL or MariaDB serial IDs. The inserted row's ID is read via a separate LAST_INSERT_ID() query that may run on a different pooled connection, so under concurrent load a signing-in user can receive another user's session and act as that user.
Overview
CVE-2026-134313 affects Better Auth packages: better-auth, @better-auth/kysely-adapter, and @better-auth/drizzle-adapter before 1.7.16, and 1.8.0-beta.0 before 1.8.0-beta.5.
The issue is a race condition with MySQL or MariaDB serial IDs. Because the inserted row's ID is read via a separate LAST_INSERT_ID() query that may run on a different pooled connection, concurrent sign-ins can cause one user to receive another user's session. This can lead to session mix-up and account takeover.
Affected versions
- better-auth < 1.7.16 - better-auth 1.8.0-beta.0 through 1.8.0-beta.4 - @better-auth/kysely-adapter versions matching the above - @better-auth/drizzle-adapter versions matching the above
Fixed versions
- 1.7.16 - 1.8.0-beta.5
References
- NVD: https://nvd.nist.gov/vuln/detail/CVE-2026-134313 - Vendor advisory: https://github.com/better-auth/better-auth/security/advisories/GHSA-48c2-w96j-mv3m - Additional reference: https://www.vulncheck.com/advisories/better-auth-before-1.7.16-and-1.8.0-beta.0-before-1.8.0-beta.5-session-mix-up-via-mysql-serial-ids
What to do
1. Identify all applications using better-auth, @better-auth/kysely-adapter, or @better-auth/drizzle-adapter with MySQL or MariaDB. 2. Check the installed versions against the affected ranges above. 3. Upgrade to better-auth 1.7.16 or 1.8.0-beta.5 (or later) and update the corresponding adapter packages to matching fixed versions. 4. If an immediate upgrade is not possible, review the vendor advisory for any interim mitigations and prioritise this fix as a high-severity auth issue. 5. Before changing production, verify the exact advisory and fixed version details against your deployment. 6. After patching, monitor authentication logs for unexpected session reuse or account switching.