Prevent reg lock bypass on alternate phone number forms

This commit is contained in:
Ameya Lokare authored and Jon Chambers committed 2026-04-15 16:37:18 -04:00
1 parent 288b9f82d7
commit bb7d855aca
2 files changed
+38 -1

No files matched your search

@@ -136,7 +136,14 @@ public class RegistrationController {
final PhoneVerificationRequest.VerificationType verificationType =
phoneVerificationTokenManager.verify(requestContext, number, registrationRequest);
final Optional<Account> existingAccount = accounts.getByE164(number);
// There can be at most one existing account for a set of numbers in the same equivalence class, so it's sufficient
// to find the first one.
final Optional<Account> existingAccount = Util.getAlternateForms(number)
.stream()
.map(accounts::getByE164)
.filter(Optional::isPresent)
.map(Optional::get)
.findFirst();
existingAccount.ifPresent(account -> {
final Instant accountLastSeen = Instant.ofEpochMilli(account.getLastSeen());