@better-auth/kysely-adapter is vulnerable to Race Condition
68
CVE Score
Medium
Race Condition
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.
Upgrade both @better-auth/kysely-adapter and better-auth to the patch version. Until you upgrade, stop using generateId: "serial" on MySQL or MariaDB. A single-connection pool does not prevent this issue.
You are affected if you use @better-auth/kysely-adapter within the vulnerable range with MySQL or MariaDB, a connection pool, and advanced.database.generateId: "serial". Other databases and ID settings are not affected.
1.5.0 - 1.7.15
Fixed in 1.7.16@better-auth/kysely-adapter is vulnerable to Race Condition in versions 1.5.0 - 1.7.15.
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.
I consent to receiving marketing communications based on Aikido’s Privacy Policy.
SOC 2Compliant
ISO 27001Compliant
ISO 42001Compliant© All Intel data is openly available and commercially licensed.