Intel

AIKIDO-2026-543668

better-auth is vulnerable to Race Condition

GHSA-48c2-w96j-mv3mPublished 6 days ago
November 4, 2026

68

CVE Score

Medium

Race Condition

Are you affected? Scan for Free

TL;DR

When MySQL or MariaDB is used with advanced.database.generateId: "serial", the Kysely and Drizzle adapters inserted a row on the connection pool and then read the new ID back with a separate LAST_INSERT_ID() query. Because LAST_INSERT_ID() is scoped to a connection, that second query could run on a different pooled connection and return the ID of a row inserted by another concurrent request. Under ordinary load, a user signing in could receive another user's session and act as that user, and a sign-up could return another user's record. The attacker cannot choose which account they receive. The fix uses the ID reported by the insert itself and fails instead of guessing when no ID is reported.

How do I fix this?

Upgrade better-auth and any directly installed Kysely or Drizzle adapter to the patch version. Until you upgrade, stop using generateId: "serial" on MySQL or MariaDB. A single-connection pool does not prevent this issue.

Who does this affect?

You are affected if you are using a version that falls within the vulnerable range, your database is MySQL or MariaDB, you set advanced.database.generateId: "serial", and you use the default Kysely adapter or the Drizzle adapter with a connection pool. Other databases and other ID settings are not affected.

Versions

0.0.1 - 1.7.15

Fixed in 1.7.16

Background info

better-auth is vulnerable to Race Condition in versions 0.0.1 - 1.7.15.

Get secure today,
quickly and for free.

Secure your code, cloud, and runtime in one central system. Connect a repo to discover what the reasoning agents find in your codebase.

No credit card required | Scan results in 32 seconds.

Trusted by 150k+ orgs
  • Revolut
  • n8n
  • Lovable
  • Deel
  • Prove
  • Omnea