
Octane’s forward-deployed engineers (FDEs) recently found two vulnerabilities in Better Auth. One is a 2FA bypass in the Electron plugin, the other a cross-customer billing bug in the Stripe plugin. Both were confirmed and fixed by the maintainers.
This post covers the vulnerabilities and the process that found them.
What Octane does
Octane operates, trains, and benchmarks LLMs to discover exploitable vulnerabilities in software.
We leverage these models to perform offensive security engagements, and build holistic ai-driven security programs for highly targeted organizations.
The strength of our forward deployed engineers
Security analysis is only as good as its understanding of the system it’s analyzing.
Octane’s forward-deployed engineers supply that understanding. They build detailed context around the target’s architecture, dependencies, trust boundaries, and expected behavior, across every codebase the target touches and the relations between them.
Octane then analyzes the target using that context. It sees the system as it actually works and can follow an attack path from attacker-controlled input to security impact, even when that path crosses several codebases.
The two Better Auth vulnerabilities in this post came directly out of that process. Neither is visible in a single function or a single package. Both appear only once the analysis knows what each component assumes about the others.
The Target: Better Auth
Better Auth is a TypeScript authentication framework that adds sign-in, sessions, and account management to an application.
The project reports 18.7 million weekly downloads and lists OpenAI, Databricks, and Strapi among the organizations that trust it.
Much of its functionality comes from plugins such as two-factor authentication, desktop sign-in, organization management, and Stripe billing. These plugins rely on sessions and user records managed by Better Auth’s core, and each side makes assumptions about what that data means.
Octane found two places where those assumptions did not match. In the Electron plugin, sign-in issued a redeemable authorization code before 2FA was complete, allowing an attacker with the victim’s password to bypass it. In the Stripe plugin, a user could swap in another customer’s ID, and billing operations then targeted that customer.
Bug#1: a desktop login code escaped before 2FA
Advisory: GHSA-9p5w-h4pr-fcrc - High, CVSS 8.1
The Electron plugin connects a desktop app to Better Auth's browser-based login. After the user finishes signing in through the browser, the server creates a short-lived authorization code. The desktop app exchanges that code at /electron/token for a session.
Because the code can produce a full session, Better Auth should create it only after every required authentication step is complete:
When the password is accepted, Better Auth creates a temporary newSession. For users with 2FA enabled, this session confirms only the password. It should not be treated as completed authentication until the second factor is verified.
However, in the affected versions, the Electron hook can treat this temporary session as completed authentication.
When the plugins are registered in the following order:
plugins: [electron(), twoFactor()]The electron hook will run first. The electron plugin will read the temporary session and create a new authorization code before the twoFactor hook can require the TOTP code.
const userId =
ctx.context.session?.user.id ||
ctx.context.newSession?.user.id;The twoFactor hook then deletes the temporary session and returns twoFactorRedirect: true.
At that point the authorization code is already stored in the better-auth.electron cookie.
An attacker can then send that code to the /electron/token endpoint. This endpoint checks state and PKCE, but never validates whether the 2FA process has completed before creating a full session:
const user = await findUserById(tokenRecord.userId);
const session = await createSession(user.id);We reproduced the bypass end to end against Better Auth 1.7.3. The victim is enrolled with a genuine TOTP, but the attack shown below never submits one.
Bug#2: users could change the customer used for billing
Advisory: GHSA-x8j7-xh58-rv6x - Moderate, CVSS 5.9
The Stripe plugin stores stripeCustomerId on the user record. That value is used to link the Better Auth user to the Stripe customer used for billing.
Better Auth plugin fields accept client input by default. Server managed fields must be marked input: false to prevent users from setting them through routes such as /update-user.
In affected versions however the flag was not set for stripeCustomerId:
stripeCustomerId: {
type: "string",
required: false,
}This leaves the field writable through the profile update route. Any authenticated user can replace their Stripe customer mapping with an attacker-chosen value:
POST /api/auth/update-user
{
"stripeCustomerId": "cus_ATTACKER_CHOSEN"
}Once the new ID is saved, Better Auth uses it for later billing operations. If an attacker knows another customer’s Stripe ID, they can cause the billing portal to target that customer. This can expose invoices and billing details and allow the attacker to change payment methods or subscriptions.
We tested this against a real Better Auth server. The Stripe SDK was stubbed so no live customer was affected. The video shows the customer ID being updated and then passed into the billing operations.
The impact of these findings:
For many organizations, 2FA is the final protection after a password is compromised. The Electron vulnerability bypasses this protection by turning a valid password into a fully authenticated session before the second factor is verified. Against a privileged account, this could expose customer data, internal systems, and administrative controls. At scale, leaked credential lists could be used to take over vulnerable 2FA-protected accounts automatically.
The Stripe vulnerability crosses a different boundary. An authenticated attacker who knows another customer’s Stripe ID can make the application open that customer’s billing portal. This could expose invoices and billing details or allow payment methods and subscriptions to be changed or canceled. If customer IDs are exposed at scale, the same path could be used to disrupt multiple customer accounts and their billing relationships.
Why the FDE workflow mattered
Neither vulnerability sits in a single function. Each of these findings was only visible when analysing the full flow of the two components, this is exactly why our FDEs scoped Better Auth’s core and plugins as a single target.
Electron’s hook that creates the authorization code works as intended on its own, it reads the session that was created by the core and does what it’s intended to do. The 2FA hook also functions correctly on its own. It deletes the temporary session and requests a TOPT code. However when combined the vulnerability gets introduced. The Electron plugin has no indication that the session given is not yet proof of a completed authentication flow, and nothing tells /electron/token whether the session code still exists.
The stripe vulnerability is caused in a similar manner, the schema permits stripeCustomerId to be supplied by the client, so the profile route writes it to the user record. The billing route later reads this value and trusts it as a source of truth. Following the complete flow reveals that a value treated as trusted by the billing code can actually be controlled by the user.
The fixes
Both issues were fixed in Better Auth 1.7.16 and 1.8.0-beta.5.
For the Electron plugin, authorization codes are now bound to the browser session that issued them. When the two-factor hook deletes the temporary session, the code loses its authority and /electron/token rejects it. The same advisory also covers a separate secret-disclosure issue in the Electron plugin, which is why the combined advisory is rated High.
For the Stripe plugin, stripeCustomerId is now marked input: false, so it can no longer be set through /update-user, and webhook handling checks that the customer belongs to the user Stripe says it does.
What to do if you use Better Auth
Update core and all plugins together to 1.7.16 or 1.8.0-beta.5.
If you run an affected Electron version, rotate your auth secret and any social provider client secrets. Reordering plugins blocks the 2FA path but not the secret-disclosure issue.
If you use the Stripe plugin, query for stripeCustomerId values shared by more than one user and compare each duplicate with the Stripe customer’s metadata.userId. Updating the package does not repair values written before the update. Repeat the check for organizations if organization billing is enabled.
Disclosure timeline
10 September 2026: Octane reports both issues to Better Auth
28 September 2026: Better Auth acknowledges the reports
29 October 2026: Better Auth pre-announces upcoming security releases
3 November 2026: Advisories published, fixed versions released
Better Auth confirmed and fixed both issues within 54 days of the report. We thank the maintainers for the quick turnaround
Subscribe to our newsletter











