The Lookup That Confirmed Every Email

Easy

· Backend

Incident

SEV-1

BUG-TW-ENUM

Priority: Critical (privacy) · reported by bug bounty

Time to fix: 10 min

Failing checks on the shipped build

  • a private account is not revealed

    discoverability is off: expected {"found":false,"id":null} but got {"found":true,"id":"u2"}

How to work this incident

  1. Read the report: write down the expected behaviour and the actual one in a sentence each.
  2. Reproduce it: run the visible tests and find the failing check that matches the report.
  3. Read the logs and the failing checks for the first value that is wrong — the earliest wrong value is nearer the cause than the loudest error.
  4. Follow the request through the handler, the validation and the service it calls; find the first step whose output disagrees with the report.
  5. Fix the cause rather than the symptom, run the visible tests again, and submit against the hidden ones — then write the root cause down.

Inspired by

Twitter · 2022

Modelled on the Twitter API vulnerability disclosed in 2022. An API endpoint returned the account associated with a submitted email address or phone number — even when the account holder had turned off discoverability by email or phone. Twitter confirmed in August 2022 that the flaw had been used to compile data on about 5.4 million accounts before it was fixed.

This project is a reconstruction: lookup.js answers "which account uses this contact?" for the find-your-friends feature, and it ignores the account's discoverable setting. It also answers a miss with a differently shaped object than a hit, which on its own tells a caller something.

Fix findByContact so it respects discoverability and answers every miss identically.

Code map

var normalize = require("./directory").normalize;

exports.findByContact = function (accounts, contact) {
  var wanted = normalize(contact);
  for (var i = 0; i < accounts.length; i++) {
    var a = accounts[i];
    if (normalize(a.email) === wanted || normalize(a.phone) === wanted) {
      return { found: true, id: a.id };
    }
  }
  return { found: false };
};

Sign in to edit the file, run the tests and submit a fix

A free account — no card, no trial clock. You come straight back here.

The Lookup That Confirmed Every Email — JavaScript Bug Hunt

Modelled on the Twitter API vulnerability disclosed in 2022.

  • Language: JavaScript
  • Layer: Backend
  • Difficulty: Easy
  • Concepts: Security, Privacy, Validation
  • Modelled on: Twitter · 2022
  • Visible tests: a discoverable account is found by email; a private account is not revealed
  • Reward: 50 XP for a complete fix

Incident

  • Severity: SEV-1 (priority: Critical (privacy))
  • Ticket: BUG-TW-ENUM
  • Reported by: bug bounty
  • Time to fix: 10 minutes, the target for an easy incident

Failing checks on the shipped build

  • a private account is not revealed — discoverability is off: expected {"found":false,"id":null} but got {"found":true,"id":"u2"}

How to work this incident

  1. Read the report: write down the expected behaviour and the actual one in a sentence each.
  2. Reproduce it: run the visible tests and find the failing check that matches the report.
  3. Read the logs and the failing checks for the first value that is wrong — the earliest wrong value is nearer the cause than the loudest error.
  4. Follow the request through the handler, the validation and the service it calls; find the first step whose output disagrees with the report.
  5. Fix the cause rather than the symptom, run the visible tests again, and submit against the hidden ones — then write the root cause down.

Briefing

Modelled on the Twitter API vulnerability disclosed in 2022. An API endpoint returned the account associated with a submitted email address or phone number — even when the account holder had turned off discoverability by email or phone. Twitter confirmed in August 2022 that the flaw had been used to compile data on about 5.4 million accounts before it was fixed.

This project is a reconstruction: lookup.js answers "which account uses this contact?" for the find-your-friends feature, and it ignores the account's discoverable setting. It also answers a miss with a differently shaped object than a hit, which on its own tells a caller something.

Fix findByContact so it respects discoverability and answers every miss identically.

Bug report

BUG-TW-ENUM · Priority: Critical (privacy) · Reported by: bug bounty

findByContact(accounts, contact) — accounts are { id, email, phone, discoverable }; contact is an email or a phone number. Compare after directory.normalize (trim, lower-case). It must return exactly:

  • { found: true, id: <id> } when an account has that email or phone AND discoverable is true
  • { found: false, id: null } in EVERY other case — no match, or a match on an account that is not discoverable. The two cases must be indistinguishable.

Observed: a private account's id comes back for its email, and an unknown email returns { found: false } without an id field.

Logs

[contacts] lookup email=… -> id=18830114 (discoverable=false)
[waf] 1.2M lookups from 3 IPs in 24h

The code as shipped

src/contacts/lookup.js (editable)

var normalize = require("./directory").normalize;

exports.findByContact = function (accounts, contact) {
  var wanted = normalize(contact);
  for (var i = 0; i < accounts.length; i++) {
    var a = accounts[i];
    if (normalize(a.email) === wanted || normalize(a.phone) === wanted) {
      return { found: true, id: a.id };
    }
  }
  return { found: false };
};

Read-only context: src/contacts/directory.js.

Open the hunt to start the incident clock, edit the files, run the visible tests and submit against the hidden ones, then write the root cause down. More JavaScript bug hunts.