@better-auth/electron: Desktop sign-in can return the server secret and skip two-factor
Description
Am I affected?
You are affected if your server registers the electron() plugin from @better-auth/electron 1.5.0-beta.12 or later.
The two-factor problem below also needs all of these:
- The server registers
twoFactor(). electron()appears beforetwoFactor()in thepluginsarray.- Users with two-factor turned on can sign in with a password.
Summary
Server secret in the sign-in response. A normal sign-in could return the server's internal auth context instead of the usual response. That context includes the auth secret and the client secrets of configured social providers.
Two-factor skipped. A password sign-in could create a desktop sign-in code before the second factor was checked. That code could be exchanged for a full session.
Impact
Any user who can sign in can read the auth secret and the social provider client secrets. With the auth secret, they can create signed values the server trusts and get a session as another user whose email address they know. The victim does not need to do anything.
With the two-factor problem, an attacker who knows a user's password can get a session for that user without the second factor.
Patches
Upgrade @better-auth/electron and better-auth to 1.7.16, or to 1.8.0-beta.5 on the beta line.
If the plugin has been running, treat the auth secret and every social provider client secret as disclosed, and rotate them. Upgrading does not undo a disclosure that already happened.
Workarounds
Remove the electron() plugin from your server until you upgrade. This disables desktop sign-in.
Placing twoFactor() before electron() blocks the confirmed two-factor path on recent better-auth releases, but it does not fix the server secret problem.
Technical details
After sign-in, the plugin reads a signed transfer cookie to start the desktop handoff. It accepted any value with a valid signature. A signature covers only the cookie value, not its name, so another signed cookie issued during sign-in could be sent back under the transfer cookie name. When no valid transfer request was found, the plugin's after hook returned the whole endpoint context, which Better Auth sent as the response.
For two-factor, the plugin stored the desktop authorization code while the temporary password session still existed. Desktop authorization codes are now bound to the browser session that issued them and stop working once that session ends, whatever the plugin order.
Credit
The server secret problem was discovered by Anthropic's OSS Scanner, as vulnerability ANT-2026-R8Z0P3MG. A related path through anonymous sign-in was discovered by the same scanner, as vulnerability ANT-2026-DDHILQ2X.