GHSA-WXW3-Q3M9-C3JR: Login CSRF via Insufficient OAuth State Verification in Better Auth
Vulnerability ID: GHSA-WXW3-Q3M9-C3JR
CVSS Score: 6.5
Published: 2026-05-15
Better Auth's OAuth implementation contains a logic flaw in its handling of the state parameter when utilizing the cookie-backed state storage strategy. The application fails to cryptographically bind the generated OAuth state nonce to the stored session metadata, leading to insufficient verification during the callback phase. This omission permits Login Cross-Site Request Forgery (CSRF) and account association attacks when Proof Key for Code Exchange (PKCE) is disabled.
TL;DR
Better Auth fails to verify the OAuth state parameter during callback processing when using the cookie storage strategy without PKCE, enabling Login CSRF attacks.
⚠️ Exploit Status: POC
Technical Details
- CWE ID: CWE-352, CWE-345
- Attack Vector: Network
- CVSS Base Score: 6.5
- Impact: Login CSRF / Account Hijacking
- Exploit Status: Proof of Concept Available
- Authentication Required: None
Affected Systems
- Applications using
better-authwithstoreStateStrategy: "cookie"and without PKCE enabled. -
better-auth: < 9deb7936aba7931f2db4b460141f476508f11bfd (Fixed in:
Post-commit 9deb7936aba7931f2db4b460141f476508f11bfd)
Code Analysis
Commit: 9deb793
Fix OAuth callback accepting mismatched state when cookie-backed state storage is used
Mitigation Strategies
- Upgrade better-auth to the latest patched version containing the state verification fix.
- Switch the storeStateStrategy configuration from "cookie" to "database".
- Enable Proof Key for Code Exchange (PKCE) across all OAuth clients.
Remediation Steps:
- Identify all services utilizing the
better-authlibrary. - Verify the configured
storeStateStrategywithin the Better Auth initialization block. - If using the
cookiestrategy, update thebetter-authdependency to the latest release. - Deploy the updated application build.
- Ensure
pkce: trueis set in the OAuth configuration block to provide defense-in-depth.
References
- GitHub Advisory: Better Auth OAuth callback accepts mismatched state
- Better Auth Security Advisories
- Fix Commit
Read the full report for GHSA-WXW3-Q3M9-C3JR on our website for more details including interactive diagrams and full exploit analysis.
Top comments (0)