better-auth: OAuth state can be used as a Magic Link to sign in as another userGHSA-965c-763c-88jm
CRITICALFix: better-auth/better-auth#11494GHSA-965c-763c-88jm is a critical-severity (CVSS 9.1) Improper Authentication vulnerability in better-auth. A fix is available for better-auth — see the affected versions and patch details below.
Exploitation Status
No confirmed exploitation observed yet
- CISA assesses this as automatable — exploitation doesn’t require manual, per-target effort, which raises the odds of mass scanning and opportunistic attacks.
- A successful exploit gives an attacker total control of the affected component, not partial access.
- CISA’s own triage has not observed active exploitation or public proof-of-concept code for this CVE as of its last assessment.
Exploitation and automatability from CISA’s SSVC triage for GHSA-965c-763c-88jm.
EPSS Exploitation Probability
Probability of exploitation in the next 30 days, from FIRST.org EPSS.
How urgent is this, really
GHSA-965c-763c-88jm by exploitation likelihood (EPSS) against impact (CVSS). Outside the shaded patch-first corner.
Where this sits among everything scored
Of 396,966 CVEs with a current EPSS score, this one falls in the < 10% band (highlighted). Counts from FIRST.org, log-scaled.
Real-World Exposure
How broadly this vulnerability is actually deployed: weekly install volume shows current usage, and reverse-dependency count shows how many other packages break if it stays unpatched.
better-authnpmDescription
Am I affected?
You may be affected if you use better-auth from 1.4.0-beta.18 through versions before 1.7.7 with the Magic Link plugin and social or Generic OAuth sign-in.
You are affected if all of these are true:
- Magic Link is enabled with default
storeToken: "plain", or withstoreToken: "hashed"and globalverification.storeIdentifier: "hashed"(including a hashed default). - At least one built-in social provider or Generic OAuth provider is enabled.
- OAuth state uses
account.storeStateStrategy: "database", the default when a database or secondary storage is configured.
Cookie-backed state blocks this path, subject to the OAuth Proxy condition below. With custom hashers, confirm the flows cannot resolve to the same stored identifier.
Summary
Better Auth accepts an OAuth sign-in state value as a Magic Link token. An attacker can start an OAuth sign-in with any email address and use the returned state value to finish a Magic Link sign-in for that address. They never prove that they can read that email.
Impact
An unauthenticated attacker who knows a user's email address can get a normal session for that user, with all of that account's permissions. They need no access to the mailbox, and they do not need to sign in with the OAuth provider or complete an OAuth callback.
If Magic Link sign-up is enabled and no user has the email address, the attacker can instead create an account that Better Auth wrongly marks as email verified, and is signed in to it. The false verified-email flag can also bypass Better Auth's default unproven-account protections when the mailbox owner later signs in, leaving the attacker's session in that account. Applications that trust verified email addresses or email domains may give this account more access, depending on the application.
Patches
The fix is merged for the planned better-auth 1.7.7 release. That package is not available yet.
Upgrade better-auth and installed Better Auth adapters, plugins, and integrations released alongside it together. Upgrade servers sharing verification storage in the same cutover. Request new Magic Links and restart pending OAuth or SAML sign-ins; links and state created before the upgrade cannot complete. Update custom verification.storeIdentifier.overrides rules to match the magic-link: and auth-state: prefixes. There is no user or account data migration, and public token values and API signatures are unchanged.
Workarounds
Until you upgrade to the fixed release, use one of these mitigations:
- Set
account.storeStateStrategyto"cookie". If you also use OAuth Proxy, first configure one dedicated OAuth Proxysecretacross all participating environments that differs from each environment's global Better Auth secret. Cookie-backed state can expose a separate OAuth Proxy account-takeover path when the proxy shares the global secret and implicit account linking is enabled. - Set the Magic Link plugin option
storeTokento"hashed"and leave globalverification.storeIdentifierunset or set it to"plain". Global identifier hashing does not prevent this issue when Magic Link tokens are also hashed. - Turn off Magic Link sign-in, or turn off social and Generic OAuth sign-in.
Setting disableSignUp: true on the Magic Link plugin is not enough. It only stops the creation of new verified accounts. It does not stop the takeover of existing accounts.
Affected Packages
| Ecosystem | Package | Vulnerable range | Fix |
|---|---|---|---|
| 📦npm | better-auth | ≥ 1.4.0-beta.18&&< 1.7.7 | 1.7.7npm install better-auth@1.7.7 |
Detection & mitigation playbook
Open-source dependencyDetect
Scan your dependency tree (package-lock.json, pnpm-lock.yaml, requirements.txt, go.sum, etc.) for better-auth, including transitive dependencies — a direct dependency you never call can still pull in a vulnerable version.
Fix
Update better-auth to 1.7.7 or later, then make sure no transitive (indirect) dependency still pins the vulnerable range — O3 confirms GHSA-965c-763c-88jm is resolved across your whole dependency graph.
Workarounds
Put an independent control in front of the weakness: restrict the affected endpoint or interface to trusted networks, require an additional authentication factor or proxy-level check, and invalidate existing sessions and credentials in case the flaw has already been used.
Frequently Asked Questions
Is GHSA-965c-763c-88jm in your dependencies?
Find it across npm, including transitive dependencies.