Page MenuHomePhabricator

Limit the allowed number of open invites for Phacility instances, particularly test instances
Closed, ResolvedPublic

Description

A user created a test instance and then invited a very large number of other users, utilizing the invite email to deliver spam.

The body of the email looks like this:

XXX (YYY ZZZ) has invited you to join Phabricator on Phacility.

<Translated from Chinese: new online earning model monthly income million Jia Wei 5520 song 18 welfare experience local tyrant passion wealth website xxx.com>

To register an account and get started, follow this link:

https://admin.phacility.com/auth/invite/.../

After you register an account, you can log in to your instance here:

https://....phacility.com/

This is so, so stupid, but we should limit:

  • The ratio of open to accepted invites you can have.
  • (Maybe, the number of users you can invite at once.)
  • The maximum invites for a test instance.
  • The maximum number of simultaneous test instances.
  • The "Pending Invites" counter didn't seem to work correctly for this instance.

It would be nice if the first couple of limits were autoscaling and passive so that you can put in a list of 1,200 users and we'll send out, say, 50 invites randomly, then send out 2 more invites each time one gets accepted. That would make it nearly useless for spam but not get in the way of legitimately inviting a lot of users.

Revisions and Commits

Restricted Differential Revision
Restricted Differential Revision
Restricted Differential Revision
Restricted Differential Revision
Restricted Differential Revision
Restricted Differential Revision
Restricted Differential Revision
Restricted Differential Revision
Restricted Differential Revision
Restricted Differential Revision
Restricted Differential Revision
Restricted Differential Revision
Restricted Differential Revision
Restricted Differential Revision
Restricted Differential Revision
Restricted Differential Revision
Restricted Differential Revision
Restricted Differential Revision

Event Timeline

epriestley triaged this task as Normal priority.Jun 4 2018, 10:31 PM
epriestley created this task.

The "Pending Invites" counter didn't seem to work correctly for this instance.

It works fine; the attacker individually cancelled each invite after sending it. It's probably easiest to just put a very low rate limit on this, since no reasonable install needs to bulk-cancel a large number of invites.

I think my plan here is basically:

  • Give instance members a cancelled status instead of deleting them. When canceling an invitation, put the member in this status. When inviting a member, check for an existing canceled invite.
  • There's some adjacent mess with actual invites (the one-time code part) that likely needs cleanup. These are separate objects but we want them to act more or less as one object.
  • Give instances an "outstanding invite" limit. This is the number of invited + cancelled members the instance is permitted to have. It can probably be computed automatically as "20 + (2 * number of actual members)" or similar.
  • Give each member a hasInvited flag or similar. This distinguishes between queued invitations and sent invitations.
  • When you create an invite or a user registers, we invite random queued members up to the "outstanding invite" limit and set their hasInvited flag.
  • When a user creates an instance, hard-limit them if they're a member of too many (test/free/active?) instances already.

That shouldn't impact any legitimate users (if you have 200 actual users to invite, you can still do it without any issues) but should dampen the ability to use invites for spam.

General idea is that when you invite a ton of users, we send out a small number of random invites. As those get accepted, we send out more and more. If they don't get accepted (i.e., you're just spamming) the vast majority of your spam list stays queued.

Possible additional adjustments:

  • Don't include custom messages in test instance invites (attackers can create real instances instead, but at least they have to pick names for them). Seems like complexity with little real deterrent effect, though.
  • CAPTCHA everything.
  • Staff approvals? But: big yuck.
epriestley added a revision: Restricted Differential Revision.Jun 6 2018, 12:19 PM
epriestley added a revision: Restricted Differential Revision.Jun 6 2018, 12:23 PM
epriestley added a revision: Restricted Differential Revision.Jun 6 2018, 12:27 PM
epriestley added a revision: Restricted Differential Revision.Jun 6 2018, 12:36 PM
epriestley added a revision: Restricted Differential Revision.Jun 6 2018, 2:04 PM
epriestley added a revision: Restricted Differential Revision.Jun 7 2018, 1:49 PM
epriestley added a revision: Restricted Differential Revision.Jun 7 2018, 3:30 PM
epriestley added a commit: Restricted Diffusion Commit.Jun 7 2018, 3:38 PM
epriestley added a commit: Restricted Diffusion Commit.
epriestley added a commit: Restricted Diffusion Commit.
epriestley added a commit: Restricted Diffusion Commit.
epriestley added a commit: Restricted Diffusion Commit.
epriestley added a commit: Restricted Diffusion Commit.Jun 8 2018, 1:08 PM
epriestley added a commit: Restricted Diffusion Commit.
epriestley added a commit: Restricted Diffusion Commit.Jun 8 2018, 1:25 PM
epriestley added a commit: Restricted Diffusion Commit.
epriestley added a commit: Restricted Diffusion Commit.
epriestley added a commit: Restricted Diffusion Commit.
epriestley added a commit: Restricted Diffusion Commit.
epriestley added a commit: Restricted Diffusion Commit.
epriestley added a commit: Restricted Diffusion Commit.
epriestley added a revision: Restricted Differential Revision.Jun 8 2018, 1:34 PM
  • I cherry-picked to stable and deployed to admin.
  • I launched a test instance, invited 32 users, and saw only 20 invites actually go out.
  • After accepting two invites, I saw more invites go out.
  • I cancelled some invites, for good measure.

So I think this should be effectively fixed now. Possibly still on deck is throttling/limiting instance launches, but I plan to wait and see if the attackers adapt or not. This channel seems so slow, complicated, and low-value that I imagine this change may be a sufficient barrier on its own.

epriestley lowered the priority of this task from Normal to Low.Jun 8 2018, 1:54 PM
epriestley added a commit: Restricted Diffusion Commit.Jun 8 2018, 11:03 PM
epriestley added a revision: Restricted Differential Revision.Jun 12 2018, 2:12 PM
epriestley added a commit: Restricted Diffusion Commit.Jun 12 2018, 6:51 PM
epriestley added a commit: Restricted Diffusion Commit.Jun 12 2018, 8:19 PM
epriestley claimed this task.

D19485 fixed one small remaining bug; I deployed that to admin.

wait and see if the attackers adapt or not

So far, they haven't. They're still registering about once instance per day, queueing up and canceling thousands of invites, and only having 20 actually send mail.

epriestley added a commit: Restricted Diffusion Commit.Jul 20 2018, 11:33 PM