GHSA-965c-763c-88jm: Critical severity npm/better-auth vulnerability

Published Oct 27, 2026
·
Updated

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.

Affected Software

1 affected componentFixes available
npm/better-auth>=1.4.0-beta.18<1.7.7
1.7.7

Remediation

Recommended actions to resolve this vulnerability, in priority order.

  1. Upgrade

    Upgrade npm/better-auth to a version that resolves this vulnerability.

    Fixed in 1.7.7
  2. Upgrade

    Upgrade better-auth and installed Better Auth adapters, plugins, and integrations to a version that resolves this vulnerability.

    Fixed in 1.7.7
  3. Configuration

    Set account.storeStateStrategy to cookie.

    Better Auth account account.storeStateStrategy = cookie
  4. Configuration

    Set the Magic Link plugin option storeToken to hashed and leave global verification.storeIdentifier unset or set it to plain.

    Better Auth Magic Link and verification storeToken and verification.storeIdentifier = storeToken=hashed; verification.storeIdentifier unset or plain
  5. Configuration

    Update custom verification.storeIdentifier.overrides rules to match the magic-link: and auth-state: prefixes.

    Better Auth custom verification identifier overrides verification.storeIdentifier.overrides = match magic-link: and auth-state: prefixes
  6. Configuration

    Turn off Magic Link sign-in, or turn off social and Generic OAuth sign-in.

    Better Auth sign-in providers Magic Link, social, and Generic OAuth sign-in = disabled
  7. Configuration

    If OAuth Proxy is used, configure one dedicated OAuth Proxy secret across all participating environments that differs from each environment's global Better Auth secret.

    OAuth Proxy secret = one dedicated secret shared across participating environments and different from each environment's global Better Auth secret
  8. Configuration

    With custom hashers, confirm that the Magic Link and OAuth state flows cannot resolve to the same stored identifier.

    Custom Better Auth hashers stored identifier derivation = distinct identifiers for the affected flows
  9. Operational

    Upgrade servers sharing verification storage in the same cutover.

  10. Operational

    Request new Magic Links and restart pending OAuth or SAML sign-ins; links and state created before the upgrade cannot complete.

Event History

Oct 27, 2026
Advisory Published
via GitHub·03:32 PM
Data Sourced
via GitHub·03:32 PM
DescriptionSeverityWeaknessAffected Software

Frequently Asked Questions

1

Which releases need review?

Review better-auth versions from 1.4.0-beta.18 through versions before 1.7.7. Exposure also depends on the enabled sign-in providers and token/state storage configuration.

2

Does a typical database-backed configuration meet the vulnerable conditions?

It can. Magic Link uses storeToken: "plain" by default, and OAuth state defaults to account.storeStateStrategy: "database" when a database or secondary storage is configured; an enabled built-in social or Generic OAuth provider is also required.

3

What does an attacker need to impersonate a user?

The attacker needs to know the target user's email address and be able to start an OAuth sign-in flow. They can use the returned OAuth state value to complete a Magic Link sign-in without proving they can read the target email.

4

Does cookie-backed OAuth state prevent this path?

Cookie-backed OAuth state blocks this path, subject to the OAuth Proxy condition. Deployments using custom hashers should confirm that the OAuth and Magic Link flows cannot resolve to the same stored identifier.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203