Summary
A flaw in better-auth's phone number plugin can allow authentication flows to associate a phone number with an account before that number is verified. If a victim later uses a valid phone OTP for that number, the session may be created for an attacker-controlled account, potentially exposing information the victim enters.
Affected context
The issue affects the phone number plugin in the specified better-auth release ranges. It becomes risky when sign-up or another account flow saves a phone number without verifying ownership, and phone OTP sign-in later uses that number to select an account.
Exploit preconditions
- Attack surface: Phone number registration and OTP sign-in flows
- Required access: An attacker must be able to create or control an account and associate the victim's phone number with it through an affected flow
- Trigger point: The victim completes phone OTP sign-in using the number associated with the attacker-controlled account
- Why exploitation is possible: Account selection relies on a phone number that may have been stored without verifying that the account holder controls it
Why this happens
The authentication flow does not consistently establish phone-number ownership before using the number as an account identifier. This is an improper authentication pattern mapped to CWE-287, because an unverified identity attribute can influence which account receives an authenticated session.
Potential impact
- A victim's OTP sign-in session could be associated with an attacker-controlled account
- Information the victim enters during that session may be visible to the attacker controlling the account
- Users could be misled about which account they have authenticated into
- Trust in phone-based account verification could be reduced
General mitigation guidance
Defensive patterns include verifying control of a phone number before treating it as an account identifier, and ensuring that verification is enforced consistently across sign-up and other account flows. Authentication should bind the OTP challenge to the intended account and verified phone number, with explicit checks before creating a session. Applications can also minimize sensitive information shown or collected before account identity is confirmed, and apply least privilege to sessions and account operations.
How teams detect issues like this
- Review phone-number sign-up and account-update paths for persistence before ownership verification
- Check that OTP verification is bound to the same account and phone number throughout the authentication flow
- Use static analysis or code review checks to flag account lookup and session creation based on unverified identity attributes
- Apply policy checks requiring verification before phone numbers can be used for authentication or account recovery

