Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[server] don't allow more than three usages per phone number #13186

Merged
merged 1 commit into from
Sep 23, 2022

Conversation

svenefftinge
Copy link
Member

@svenefftinge svenefftinge commented Sep 21, 2022

Description

Adds checks for phone numbers being used by abusers or used too often (>3)

Related Issue(s)

Fixes #12883

How to test

Release Notes

Restrict reuse of phone numbers for verification

Documentation

Werft options:

  • /werft with-local-preview
    If enabled this will build install/preview
  • /werft with-preview
  • /werft with-integration-tests=all
    Valid options are all, workspace, webapp, ide

Copy link
Contributor

@atduarte atduarte left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is awesome! Thank you, Sven 🙏

Looking at the code out of curiosity found something you will notice also pretty quickly :)

PS: Would it make sense and be sensible to also stop overriding the phone number on delete as part of this (here)? Asking because a potential way for an abuser to avoid both these checks is requesting the account to be deleted.

@@ -59,6 +60,14 @@ export class VerificationService {
if (!this.verifyService) {
throw new Error("No verification service configured.");
}
const isBlockedNumber = this.userDB.countUsagesOfPhoneNumber(phoneNumber);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const isBlockedNumber = this.userDB.countUsagesOfPhoneNumber(phoneNumber);
const isBlockedNumber = this.userDB.isBlockedPhoneNumber(phoneNumber);

@svenefftinge svenefftinge changed the title [server] don't allow more than three usages [server] don't allow more than three usages per phone number Sep 22, 2022
@svenefftinge svenefftinge force-pushed the sefftinge/limit-phone-number-re-12883 branch from 2430319 to 0b53ef5 Compare September 22, 2022 05:26
@svenefftinge svenefftinge force-pushed the sefftinge/limit-phone-number-re-12883 branch from 0b53ef5 to e504643 Compare September 22, 2022 06:21
@svenefftinge svenefftinge marked this pull request as ready for review September 22, 2022 06:22
@svenefftinge svenefftinge requested a review from a team September 22, 2022 06:22
@github-actions github-actions bot added the team: webapp Issue belongs to the WebApp team label Sep 22, 2022
@svenefftinge
Copy link
Member Author

svenefftinge commented Sep 22, 2022

/werft run

👍 started the job as gitpod-build-sefftinge-limit-phone-number-re-12883.3
(with .werft/ from main)

@svenefftinge
Copy link
Member Author

/hold

Copy link
Member

@easyCZ easyCZ left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Requesting changes as per internal thread

@svenefftinge svenefftinge force-pushed the sefftinge/limit-phone-number-re-12883 branch 2 times, most recently from ba37cf5 to 6b55247 Compare September 23, 2022 10:23
@roboquat roboquat added size/L and removed size/M labels Sep 23, 2022
Copy link
Member

@easyCZ easyCZ left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, one comment about correctly distinguishing user errors and server errors.

/hold

throw new Error("The given phone number has been used more than three times.");
}
if (await isBlockedNumber) {
throw new Error("The given phone number is blocked due to abuse.");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we throw this as a user error here? Otherwise it will count towards server errors in our metrics.

* @param phoneNumber
* @returns formatted phone number
*/
export function formatPhoneNumber(phoneNumber: string): string {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@svenefftinge svenefftinge force-pushed the sefftinge/limit-phone-number-re-12883 branch from 6b55247 to dd09f79 Compare September 23, 2022 12:54
@svenefftinge
Copy link
Member Author

svenefftinge commented Sep 23, 2022

/unhold

@roboquat roboquat merged commit 1516e4c into main Sep 23, 2022
@roboquat roboquat deleted the sefftinge/limit-phone-number-re-12883 branch September 23, 2022 13:27
@roboquat roboquat added deployed: webapp Meta team change is running in production deployed Change is completely running in production labels Sep 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
deployed: webapp Meta team change is running in production deployed Change is completely running in production release-note size/L team: webapp Issue belongs to the WebApp team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Limit phone number re-use for verification
4 participants