Summary
Better Auth's OAuth callback logic can implicitly link an OAuth identity to a local account based solely on the provider's email_verified claim, without confirming the local account's own email verification status.
If an attacker pre-registers a victim's email address, they may be able to bind the victim's OAuth identity to the attacker-controlled account during login or one-tap flows.
Affected context
This vulnerability appears in Better Auth deployments that:
- Use OAuth providers with
email_verifiedclaims and rely on auto-linking behavior - Allow sign-up via
/sign-up/emailor similar email-based registration flows - Enable one-tap or flows where the library decides account linking automatically
The issue manifests when the library trusts the OAuth provider's email_verified: true assertion as sufficient proof to link identities, regardless of whether the corresponding local user record has emailVerified set.
Exploit preconditions
- Attack surface: Public authentication endpoints relying on Better Auth's OAuth callback and one-tap flows.
- Required access: Ability to initiate OAuth sign-in flows and to pre-register email addresses using the normal sign-up endpoint.
- Trigger point: The OAuth callback handler (
handleOAuthUserInfo) performing auto-linking based on the provider'semail_verifiedclaim. - Why exploitation is possible: The account-linking logic treats the provider's
email_verifiedflag as sufficient evidence of identity, without enforcing a matching verification state on the local user row, enabling a pre-registered email to be linked to an attacker-controlled account.
Why this happens
The root cause is an authentication and identity-proofing flaw where external OAuth assertions are over-trusted.
Specifically, the account linking gate accepts email_verified: true from the OAuth provider as a decisive signal for identity equivalence, without requiring a consistent verification state on the local user object.
This falls under CWE-287 (Improper Authentication) and CWE-345 (Insufficient Verification of Data Authenticity), as the system fails to rigorously validate that the authenticated OAuth identity corresponds to a fully verified local account before allowing linkage.
Abstractly, the insecure pattern is "implicit account linking based on third-party claims without enforcing local verification and consistent identity ownership checks."
Potential impact
- An attacker may bind a victim's OAuth identity to an attacker-controlled local account.
- Users could experience partial or full account takeover in applications relying on Better Auth for OAuth login.
- Sensitive data associated with the victim's account may be exposed to the attacker.
- Downstream actions performed via the compromised session could affect authorization, billing, or stored user consents.
General mitigation guidance
Effective mitigation focuses on tightening identity linking rules and reducing implicit trust in third-party assertions:
- Require both sides of the link to meet strict verification criteria (for example, the local user's email must be verified before any OAuth-based linking is accepted).
- Treat OAuth provider
email_verifiedas one signal among many, not as a sole authority, and consider additional checks such as explicit user confirmation or secure out-of-band verification. - Implement explicit, user-driven account linking flows instead of silent or automatic linking, ensuring the active, authenticated user approves the connection.
- Enforce clear separation between "account creation", "email verification", and "identity linking" steps to avoid hidden coupling that bypasses verification.
- Design authentication logic using least-privilege principles, granting minimal linkage rights to newly created or unverified accounts.
How teams detect issues like this
To detect similar vulnerabilities, teams can:
- Review authentication and OAuth integration code for any auto-link or "magic" linking paths that depend solely on provider claims like
email_verified. - Use static analysis or policy checks to flag code paths where external identity assertions are trusted without cross-checking against local verification flags.
- Incorporate security-focused code review checklists that explicitly ask how identities are linked across providers and what verification barriers exist.
- Examine audit logs for suspicious patterns, such as multiple distinct logins or devices associating with the same email or OAuth identity shortly after account creation.

