Skip to content

Verifying a previously uncompleted phone may link to incorrect user ID #2430

@kostasb

Description

@kostasb

Bug report

When verifying a phone, auth.updateUser({ phone: '...' }) may link to a different auth.users record than the currently authenticated user during the verification process, even if auth.getUser() reports the correct user ID beforehand.

  • I confirm this is a bug with Supabase, not with my own application.
  • I confirm I have searched the Docs, GitHub Discussions, and Discord.

Describe the bug

Phone verification identifies the user by searching for the provided phone number in the phone_change column, rather than relying solely on the active session.

Unlike the phone column, the phone_change column does not enforce uniqueness. If multiple auth.users records contain the same phone number in phone_change due to uncompleted or abandoned verification attempts, auth may update another user's phone field upon successful OTP verification

This occurs because the lookup updates the first matching record in phone_change, which might not belong to the currently authenticated user.

To Reproduce

Leave an unverified phone number record for one user and assign the same phone number for another user.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions