Detect better-auth OAuth State Reuse as Magic Link for Account Takeover (CVE-2026-114607) in Microsoft Sentinel
Detects potential exploitation of CVE-2026-114607, an authentication bypass in the better-auth npm package (>= 1.4.0-beta.18, < 1.7.7). The OAuth 'state' parameter generated during the OAuth sign-in flow can be replayed against the Magic Link verification endpoint, allowing an attacker to sign in as another user (account takeover). Detection focuses on application and reverse-proxy logs showing OAuth state tokens being submitted to magic-link verification endpoints, cross-endpoint token reuse, and anomalous session issuance following magic-link verification without a preceding magic-link email request. Also surfaces the presence of vulnerable better-auth versions via package inventory telemetry.
MITRE ATT&CK
KQL Detection Query
// df00tech DF00-9eef098f84 · https://df00tech.com/detections/CVE-2026-114607 · licence: https://df00tech.com/detections/licence
// better-auth OAuth state replayed to magic-link verify endpoint (CVE-2026-114607)
let magicVerifyPaths = dynamic(["/api/auth/magic-link/verify", "/api/auth/magic-link", "/api/auth/sign-in/magic-link/verify"]);
AppServiceHTTPLogs
| where CsUriStem has_any (magicVerifyPaths)
| where CsUriQuery has "token=" or CsUriQuery has "state="
| extend TokenParam = extract(@"(?:token|state)=([A-Za-z0-9\-_\.]+)", 1, CsUriQuery)
| where isnotempty(TokenParam)
// Correlate with the same token value having been issued as an OAuth state
| join kind=inner (
AppServiceHTTPLogs
| where CsUriStem has "/api/auth/" and (CsUriStem has "callback" or CsUriQuery has "state=")
| extend OauthState = extract(@"state=([A-Za-z0-9\-_\.]+)", 1, CsUriQuery)
| where isnotempty(OauthState)
| project OauthState, OauthTime = TimeGenerated, OauthPath = CsUriStem
) on $left.TokenParam == $right.OauthState
| where TimeGenerated between (OauthTime .. (OauthTime + 1h))
| project TimeGenerated, CsUriStem, CsUriQuery, CIp, UserAgent, TokenParam, OauthPath, OauthTime
| sort by TimeGenerated desc Finds an OAuth state value later presented to a better-auth magic-link verification endpoint within one hour, indicating cross-flow token reuse consistent with CVE-2026-114607.
Data Sources
Required Tables
False Positives & Tuning
- Security scanners or DAST tools that fuzz auth parameters across endpoints.
- Legitimate users who abandon an OAuth flow and then use a magic link, coincidentally sharing infrastructure IPs.
- Log aggregation that normalizes query strings, causing distinct tokens to appear equal.
Other platforms for CVE-2026-114607
Testing Methodology
Validate this detection against 3 adversary techniques from Atomic Red Team. Each test below lists the behaviour to exercise and the telemetry you should expect to see. Executable commands and cleanup steps are further down this page.
- Test 1 OAuth state reuse against magic-link verify endpoint
Expected signal: Web access logs show an OAuth state value followed by a magic-link verify request carrying the same token within seconds.
- Test 2 Magic-link verification without prior email request
Expected signal: A magic-link verification event with no preceding magic-link email request record in better-auth logs.
- Test 3 Vulnerable better-auth version inventory
Expected signal: Package inventory / EDR software telemetry records better-auth version in the vulnerable range (>=1.4.0-beta.18, <1.7.7).
References (6)
- https://github.com/better-auth/better-auth/security/advisories/GHSA-965c-763c-88jm
- https://nvd.nist.gov/vuln/detail/CVE-2026-114607
- https://github.com/better-auth/better-auth/pull/11494
- https://github.com/better-auth/better-auth/commit/ac54bfd67821a7607533af2059858b12bc54e26a
- https://github.com/better-auth/better-auth/releases/tag/v1.7.7
- https://github.com/advisories/GHSA-965c-763c-88jm
Response Playbook
Triage
- Confirm the better-auth version in use from package-lock.json / node_modules; versions >= 1.4.0-beta.18 and < 1.7.7 are vulnerable.
- Identify the token value flagged and determine whether it was first issued as an OAuth 'state' parameter and later presented to a magic-link verify endpoint.
- Check whether a corresponding magic-link email was ever requested/sent for the account the session was issued to; absence strongly indicates exploitation.
- Review the source IP, user agent, and geolocation of the OAuth state issuance versus the magic-link verification to detect mismatch.
Containment
- Upgrade better-auth to >= 1.7.7 immediately across all affected services and redeploy.
- Invalidate all active sessions and force re-authentication for potentially affected accounts; rotate session secrets.
- Temporarily disable the magic-link plugin or add a WAF rule rejecting magic-link verify requests whose token matches an outstanding OAuth state.
Evidence Collection
- Preserve web/reverse-proxy access logs showing the OAuth callback and the magic-link verification requests with full query strings.
- Export better-auth server logs and the verification/session tables (session issuance records, token records) for the affected time window.
Escalation Criteria
- !A session was issued to an account for which no magic-link request exists, treat as confirmed account takeover and escalate to IR.
- !Evidence of multiple accounts targeted or privileged/admin account compromise.
Investigation Guide
Forensic Artifacts
- >
Web/reverse-proxy access logs containing OAuth callback and magic-link verify requests with query strings. - >
better-auth session and verification token database tables. - >
Application logs recording session issuance events and associated user IDs.
Tuning Guidance
Baseline legitimate magic-link verification volume per application. Exclude known scanner IPs and synthetic monitors. If query-string logging is normalized or truncated, enable full URI query capture at the reverse proxy to make token correlation reliable. Tighten the correlation window from 1h as you learn the normal OAuth-to-session latency for your deployment.
Hunting Queries
Finds a single token value appearing across both OAuth and magic-link endpoints, the core indicator of state reuse.
// df00tech DF00-9eef098f84 · https://df00tech.com/detections/CVE-2026-114607 · licence: https://df00tech.com/detections/licence
AppServiceHTTPLogs | where CsUriStem has "/api/auth/magic-link" | extend tok=extract(@"(?:token|state)=([A-Za-z0-9\-_\.]+)",1,CsUriQuery) | summarize endpoints=make_set(CsUriStem), count() by tok | where array_length(endpoints) > 1 ``` df00tech DF00-9eef098f84 · https://df00tech.com/detections/CVE-2026-114607 · licence: https://df00tech.com/detections/licence ```
index=web (uri_path="/api/auth/magic-link*" OR uri_query="*state=*") | rex field=uri_query "(?:token|state)=(?<tok>[A-Za-z0-9\-_\.]+)" | stats dc(uri_path) as paths values(uri_path) as seen by tok | where paths>1 Atomic Red Team Tests
In a lab better-auth instance (< 1.7.7), capture an OAuth state value and replay it against the magic-link verification endpoint.
Command
STATE=$(curl -sic 'http://localhost:3000/api/auth/sign-in/social?provider=github' | grep -oE 'state=[A-Za-z0-9._-]+' | head -1 | cut -d= -f2); curl -s "http://localhost:3000/api/auth/magic-link/verify?token=${STATE}" -c /tmp/ba_session.txt -v Cleanup
rm -f /tmp/ba_session.txt Expected Telemetry
Web access logs show an OAuth state value followed by a magic-link verify request carrying the same token within seconds.
Expected Detection
The KQL/SPL correlation rule fires on the shared token value across OAuth and magic-link endpoints.
Submit a magic-link verify request using a token that was never issued via a sign-in/magic-link email request.
Command
curl -s 'http://localhost:3000/api/auth/magic-link/verify?token=ABORROWEDOAUTHSTATEVALUE1234' -c /tmp/ba_ses2.txt -v Cleanup
rm -f /tmp/ba_ses2.txt Expected Telemetry
A magic-link verification event with no preceding magic-link email request record in better-auth logs.
Expected Detection
Triage logic flags session issuance lacking a corresponding magic-link request.
Enumerate the installed better-auth version to confirm exposure to CVE-2026-114607.
Command
node -e "console.log(require('better-auth/package.json').version)" || cat node_modules/better-auth/package.json | grep '\"version\"' Cleanup
true Expected Telemetry
Package inventory / EDR software telemetry records better-auth version in the vulnerable range (>=1.4.0-beta.18, <1.7.7).
Expected Detection
Software inventory detection flags the vulnerable version.