All posts

better-auth’s Magic Link takeover: am I affected, and what to change.

CVE-2026-114607 (CVSS 9.1) lets an attacker sign in as anyone whose email they know on some better-auth setups. Fixed in 1.7.7, with workarounds.

Published
Reading time
6 min
By
Girish Babu GV

What happened#

On 30 September 2026 the better-auth maintainers published a security advisory titled “OAuth state usable as a Magic Link”. It says that in affected versions, the value used as OAuth sign-in state is also accepted as a Magic Link token. An attacker starts an OAuth sign-in for the victim’s email address, then presents the returned state value as if it were a Magic Link. The attacker never needs to open the victim’s mailbox.

The advisory’s impact section is plain: the attacker ends up with a normal session carrying that account’s permissions. If Magic Link sign-up is enabled and no account exists yet for that email, the attacker can create one that is wrongly marked as email verified. It adds that setting disableSignUp: true on the Magic Link plugin does not stop takeover of accounts that already exist.

GitHub added the same advisory to its reviewed Advisory Database on 27 October, where it is tagged CWE-287 (improper authentication) and shows the same 9.1 rating; the database page also records NVD publishing it on 22 October. The reporters credited are rick-v12 and bazumo.

Key facts from the advisory
ItemValue
CVE / advisoryCVE-2026-114607 / GHSA-965c-763c-88jm
SeverityCritical, CVSS 3.1 base score 9.1 (network, no privileges, no user interaction)
Packagebetter-auth (npm)
Affected1.4.0-beta.18 up to, but not including, 1.7.7
Patched1.7.7
WeaknessCWE-287, improper authentication

The fix, in pull request #11494, makes Magic Link redeem only records that were issued for Magic Link. According to the pull request, Magic Link identifiers now carry a magic-link: prefix, database-backed OAuth and SAML state carries an auth-state: prefix, and Magic Link checks each record’s purpose before consuming it. The 1.7.7 release notes describe it as fixing a critical Magic Link account-takeover vulnerability, and say 1.7.7 shipped on 30 September.

Am I affected?#

The advisory says all three of these conditions must hold. If any one is false, the advisory does not list you as exposed.

What has to be true (all three)
ConditionWhere to look
Magic Link is enabled with storeToken: "plain", or with storeToken: "hashed" plus global verification.storeIdentifier: "hashed"Your magicLink plugin options and your verification settings in the better-auth config
At least one built-in social provider or Generic OAuth provider is enabledsocialProviders and the genericOAuth plugin in the same config
OAuth state uses the database strategy (account.storeStateStrategy), which is the default when a database or secondary storage is configuredThe account options; if you never set it and you have a database, you are probably on the default

Separately, you need to be on a version below 1.7.7. If you use the OAuth Proxy plugin, the release notes say a related fix stops it accepting sign-in state as a provider profile, and that all OAuth Proxy participants should be upgraded together.

What to do now#

  1. Find the version that is actually running, not just the one in your repo. A lockfile updated on a laptop says nothing about production.
  2. Upgrade to 1.7.7 or later, and keep related adapters, plugins and integrations on the same release. The advisory says servers that share verification storage should be upgraded in the same change.
  3. Expect some sign-in friction. The advisory says links and OAuth or SAML state created before the upgrade will not complete, so users must request a new Magic Link and restart pending sign-ins. It says no schema or account data migration is needed.
  4. If you use custom storage rules, the advisory says to update any custom identifier rules so they recognise the magic-link: and auth-state: prefixes.
  5. Look at your logs for Magic Link sign-ins that don’t match a Magic Link email you sent. The sources I read don’t say what exploitation looks like, so that is a general suggestion, not something from the advisory.
Check, then update
# Which version is installed?
npm ls better-auth

# Upgrade, then deploy
npm install better-auth@latest

# Confirm after the deploy, on the server itself
npm ls better-auth

If you can’t upgrade today, the advisory lists these workarounds. Any one of them is described as enough to remove a condition above:

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

What the sources don’t say#

  • Whether anyone has exploited this in the wild. The advisory doesn’t mention it either way.
  • How many projects are running a vulnerable combination. The advisory describes the conditions but gives no numbers.
  • What exploitation would look like in logs. Neither the advisory nor the fix says.
  • Other better-auth advisories. Searching turned up separate Magic Link and OAuth state issues with different identifiers and fix versions. I did not read those for this post, so don’t treat this one as the whole picture for the library.

My take#

My own opinion, not from the advisory.

The pattern here is two features that are fine alone and dangerous together: a one-time token and an OAuth state value ended up in the same storage, and nothing checked what each record was for. If you build or review authentication, “what was this token issued for?” is a question worth asking of every token you accept. Practically, a critical fix that is a month old and needs a particular combination of settings is easy to miss, so I’d spend ten minutes on the three-condition check this week.

Sources#

Keep reading

Esc