0-click account takeover in Better Auth
The Expo integration's authorization proxy endpoint signed any caller-supplied OAuth state value with the application secret, without verifying that Better Auth had issued it. An unauthenticated attacker could use this signing oracle to forge email-verification JWTs and session-cache cookies, enabling account takeover without victim interaction.
strix.ai
Published on strix.ai
Strix found a critical account takeover in Better Auth's Expo integration. No password, inbox access, or victim interaction required.
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
How it worked
Root cause
The proxy signed caller-supplied state without checking it was issued by Better Auth, and the same secret was reused across OAuth state, email tokens, and session cache, allowing signature crossover.
Impact
An unauthenticated attacker could take over any account by changing the victim's email and obtaining a session, with no password, inbox access, or victim interaction required; the session-cache forgery path did not work against the jwe strategy.
What the attacker needed
Victim's email address known; no authentication required; no victim interaction
The fix
The proxy should tie state to a login flow the server actually created, and separate signing keys should be used for OAuth state, email tokens, and session data; the text says the issue was fixed in version 1.7.16.
How it was found
- Send a request to the Expo authorization proxy with an authorization URL containing a crafted state value.
- Receive the signed state in the Set-Cookie header.
- Convert the signature to base64url and build a JWT for the email-verification endpoint.
- Submit the forged token to the verify-email endpoint to change the victim's email and obtain a session.
- For the session-cache path, use the proxy to sign a forged session cache payload and a matching session-token cookie.
- Send the forged cookies to the get-session endpoint to obtain a valid session.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
A signing key is like a wax seal that proves a message came from the server. Here, a login helper would stamp any message an outsider handed to it, so the outsider could create fake permission slips for changing an account's email or creating a session. Because the server trusted its own stamp, it accepted the fakes.
What is Account takeover?
Getting into someone else's account through a flaw in sign-in, password reset, second factor, single sign-on or session handling.