NewApp Monitoring is liveSign up free
AgentbeamBeta
Open-source package vulnerability · npm

CVE-2026-114607: better-auth: OAuth state can be used as a Magic Link to sign in as another user

criticalCVSS 3.1 9.1GHSA-965c-763c-88jm

better-auth accepts an OAuth sign-in state value as a Magic Link token. An unauthenticated attacker who knows a victim's email address can start an OAuth sign-in, reuse the state value to complete a Magic Link sign-in, and get a session as that user. Versions from 1.4.0-beta.18 before 1.7.7 are affected. The advisory says 1.7.7 is planned and not yet published.

Published Oct 27, 2026 · Analysis Oct 27, 2026

What an attacker can do

Magic Link tokens and OAuth state values share one verification store and one identifier scheme. The attacker starts an OAuth sign-in with any email address and receives a state value. They present it as the Magic Link token for that address. Better Auth treats it as proof of mailbox ownership that was never given (CWE-287). The attacker does not need the mailbox, and does not need to finish an OAuth callback.

For an existing user, the attacker gets a normal session with all of that account's permissions. If Magic Link sign-up is on and nobody has the email, the attacker creates an account that is wrongly marked email-verified. That flag can bypass the default unproven-account protections when the real owner later signs in, leaving the attacker's session in that account. Apps that trust verified emails or domains may grant that account extra access.

The conditions are specific. Magic Link must use storeToken: "plain", or "hashed" with global verification.storeIdentifier: "hashed". A social or Generic OAuth provider must be enabled. OAuth state must use account.storeStateStrategy: "database", the default when a database or secondary storage is configured. disableSignUp: true on the Magic Link plugin does not stop takeover of existing accounts.

Who is affected

The npm package better-auth from 1.4.0-beta.18 up to but not including 1.7.7 is affected when all the conditions above hold. Cookie-backed OAuth state blocks this path, subject to an OAuth Proxy condition. With custom hashers, confirm the two flows cannot resolve to the same stored identifier.

Check the version:

npm ls better-auth

Then check your config for the magicLink plugin, storeToken, verification.storeIdentifier and account.storeStateStrategy.

better-auth

Ecosystem
npm
Affected
>= 1.4.0-beta.18, < 1.7.7
Fixed in
1.7.7
Check
npm ls better-auth

How to fix it

Upgrade to better-auth 1.7.7 once it is published. The advisory says the fix is merged for that planned release. Upgrade installed Better Auth adapters, plugins and integrations released alongside it together, and upgrade servers sharing verification storage in the same cutover.

npm install [email protected]

After the upgrade, old Magic Links and pending OAuth or SAML state stop working, so users must request new links. Update custom verification.storeIdentifier.overrides rules to match the magic-link: and auth-state: prefixes.

Until then, use one workaround:

  • Set account.storeStateStrategy to "cookie". If you use OAuth Proxy, first set a dedicated OAuth Proxy secret that differs from the global secret.
  • Set Magic Link storeToken to "hashed" and leave global verification.storeIdentifier unset or "plain".
  • Turn off Magic Link, or turn off social and Generic OAuth sign-in.

How to tell if you were hit

Look for sessions created through Magic Link verification where no Magic Link email was sent for that address. Compare your mail-provider send logs with Magic Link verification events.

Check for accounts with emailVerified set to true that were created through the Magic Link route with no matching email delivery. Review sign-ins for known users from unfamiliar IP addresses and devices. Look for OAuth sign-in starts for an email address with no matching callback.

Original advisory

From the GitHub Advisory Database (CC BY 4.0).

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 with storeToken: "hashed" and global verification.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.storeStateStrategy to "cookie". If you also use OAuth Proxy, first configure one dedicated OAuth Proxy secret across 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 storeToken to "hashed" and leave global verification.storeIdentifier unset 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.

Credited to rick-v12, bazumo.

Questions

Does disableSignUp on the Magic Link plugin stop this attack?

No. It only stops creation of new verified accounts. It does not stop takeover of existing accounts, so use one of the listed workarounds or upgrade.

Is better-auth 1.7.7 available yet?

The advisory said the fix is merged for the planned 1.7.7 release and that the package was not available yet. Check npm before relying on it. Until then, apply one of the workarounds.

Does the attacker need access to the victim's mailbox?

No. They only need the victim's email address. They never prove they can read the mailbox, and they do not complete an OAuth callback.

References

How this page is made: the data panel comes from the GitHub Advisory Database, CISA’s KEV catalog, the NVD and FIRST EPSS, and updates twice a day. The analysis is written by an AI model from the sources listed above and checked by automated rules before it is published. Check versions against the vendor's advisory before you act. Methodology

More npm vulnerabilities

All npm entries