Skip to content
Info disclosure Write-up Intermediate

Twitter Privacy Bypass: Hidden Accounts Found by Email

The Android login flow's duplicate-check step returned the numeric user ID for any submitted phone number or email without authentication, ignoring the account's discoverability setting. An attacker could therefore map many phone numbers and emails to accounts, unmasking users who had opted out of being found by contact details.

medium.com

Published on medium.com

Bug Bounty

Muhammad Asim Shahzad, on medium.com

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 5 min read.

Context

Twitter's discoverability setting lets a user decide whether other people can find their account by the email address or phone number they have on file. When the setting is off, knowing someone's contact details should not reveal which account belongs to them.

The target here is the Android client's login flow. It is a multi-step onboarding process, and one of its steps checks whether the identifier a person has typed already belongs to an existing account, so the app can handle duplicates. That duplicate check is the feature that broke the privacy promise.

AI-generated illustration From the original on medium.com

The illustration at the top of the write-up is AI-generated and carries no technical detail.

Setup

The report does not describe a test account, a device or a tool. What it does establish is the precondition that matters: the duplicate check runs before the user has authenticated, using only the app's guest-level credentials. No session belonging to the victim is needed, and no interaction from the victim is needed either.

Finding it

The researcher, zhirinovskiy, reported the issue to HackerOne on 1 January 2022 as report #1439026, and it was disclosed on 11 February 2022. The observation was that the login-flow step which checks for an existing account returned the matching account's numeric user ID in its response, even when the account owner had switched off discoverability by email or phone.

Two things made that look wrong rather than intended. First, the check ran unauthenticated, so the response was available to anyone who could reach the login flow. Second, the discoverability preference was never consulted on this path at all. The researcher also found that the step returned IDs for suspended accounts.

Exploitation

Step 1: submit an identifier to the duplicate check

The login flow accepts a phone number or an email address and asks the backend whether it belongs to an existing account. The report does not reproduce the request itself, so the exact endpoint, parameters and headers are not available here. What it does state is that the call is made with guest-level credentials only, before any proof of identity.

Step 2: read the user ID out of the response

The response to that check carried the numeric user ID of the matching account. That is the whole leak: the step needed only a yes or no answer to decide how to continue, but it returned an identity instead.

Step 3: resolve the ID to a profile

A user ID resolves to a public profile in one further lookup. The report does not show that lookup. The consequence it draws is that the distance between "this email exists" and "this email is @someone" was zero.

Step 4: repeat at scale

Because the step is unauthenticated and cheap, the same sequence can be run over a list of phone numbers and email addresses. The report notes that anyone with basic scripting could link large lists of identifiers to accounts.

Root cause

The duplicate check was written to answer a question the login flow needed answered, but it answered a bigger one. It looked up the account behind the identifier and returned the account's user ID, without consulting the discoverability preference and without requiring the requester to be authenticated. The privacy rule existed at the feature layer that users see, and was not enforced at the data layer that this particular client path touches.

Existing defences did not stop it because the check was a legitimate part of onboarding: it had to run before authentication to be useful, and it had to look the identifier up to work.

Impact

A single lookup is a privacy leak. Scripted lookups turn it into a database: the report warns that anyone with basic scripting could link huge lists of phone numbers and emails to accounts, data valuable for spam, for selling, and for targeting celebrities and pseudonymous users. For anyone who relies on a separate identity for safety, unmasking is the whole harm.

The conditions are narrow but easy to meet: the attacker needs only the identifier and access to the unauthenticated login step. It records the severity as High on HackerOne, the weakness as Improper Access Control (Generic), no CVE, and a bounty of $5,040.

Fix

The write-up's own recommendations, presented as analysis rather than as what Twitter did, are:

  1. Enforce privacy at the lookup layer, so every path that maps an identifier to an account calls one policy function.
  2. Have pre-authentication steps return decisions, not identities: "continue" or "try again", never a user ID.
  3. Rate limit by identifier and by client, so bulk matching costs real effort rather than a loop.
  4. Watch for enumeration, alerting on guest sessions that try many distinct identifiers.

The write-up includes a sketch of the policy function and a test note:

Python
def resolve_identifier(identifier, requester):    account = accounts.find_by_email_or_phone(normalise(identifier))    if requester.is_unauthenticated():                limiter.hit(f"lookup:{requester.client_id}", identifier)          return NextStep("password")      if account is None or not account.discoverable_by_contact:        return NotFound()                return Found(public_handle(account))
Text
# Test: guest flow must never emit user IDs; hidden account == missing account in response

Variants to test

  • Other pre-authentication lookups. Any signup, password-reset or account-recovery step that takes an email or phone number. A positive result is a response that differs between an existing hidden account and a missing one, or that carries an internal identifier.
  • Response diffing for hidden versus missing accounts. Compare status codes, body length, field names and timing for an account with discoverability off against an identifier that does not exist. A positive result is any observable difference.
  • Identifier-to-profile chains. Take any internal ID returned by a guest-reachable endpoint and try to resolve it to a public profile. A positive result is a profile page or API response for an account whose owner expected not to be findable.
  • Suspended and restricted accounts. The report found IDs returned for suspended accounts; check whether other account states (deactivated, restricted, private) leak through the same path. A positive result is an ID or existence signal for an account in a state that should be invisible.
  • Bulk behaviour. Send many distinct identifiers from one guest session and watch for throttling or alerting. A positive result is sustained unthrottled lookups, which is what makes the leak a database rather than a single disclosure.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 14 min read.

What happened, in plain words

Twitter has a setting that lets you decide whether other people can find your account using the email address or phone number you signed up with. When that setting is switched off, someone who knows your email or phone number should not be able to work out which account belongs to you.

In January 2022, a security researcher called zhirinovskiy found that the Android app's login process broke that promise. During login, the app checks whether the email or phone number you typed already belongs to an account, so it can handle the situation sensibly. That check ran before you had proved who you were, and its reply included the numeric ID of the matching account. A numeric ID can then be turned into a public profile with one more lookup. So anyone who had your email or phone number could find your account, even if you had asked not to be findable.

Twitter fixed the issue and paid a bounty of $5,040. The researcher reported it on 1 January 2022, and it was disclosed publicly on 11 February 2022.

Before going further, a few everyday comparisons will help.

  • An API is the way one piece of software asks another for information, like a waiter taking your order to the kitchen. You do not go into the kitchen yourself; you ask, and something comes back. When the Twitter app checks an email address, it is asking Twitter's servers through an API.
  • A token or cookie is a small piece of proof that you are allowed to ask. Think of a cloakroom ticket: it does not tell the attendant who you are, it just shows you are entitled to collect a coat. Some tickets are handed out to anyone who walks in, which is what "guest-level credentials" means here.
  • Authentication means proving who you are, like showing your passport. Something that runs "unauthenticated" runs before anyone has shown a passport.
  • A user ID is an internal number that identifies an account, a bit like a customer number in a shop's records. It is not usually secret, but it is a direct pointer to a person.
  • Enumeration means working through a list, one item at a time, to find out which items exist. If a website tells you "this email is registered" or "this email is not registered", you can feed it a list and learn which people have accounts.
  • A privacy-setting bypass is when a rule you set is respected in one place but ignored in another. It is like telling a receptionist not to give out your room number, and then finding that the car park barrier prints it on every ticket.

Context

Twitter's discoverability setting lets a user decide whether other people can find their account by the email address or phone number they have on file. When the setting is off, knowing someone's contact details should not reveal which account belongs to them.

The target here is the Android client's login flow. It is a multi-step onboarding process, and one of its steps checks whether the identifier a person has typed already belongs to an existing account, so the app can handle duplicates. That duplicate check is the feature that broke the privacy promise.

AI-generated illustration From the original on medium.com

The illustration at the top of the write-up is AI-generated and carries no technical detail.

Setup

The report does not describe a test account, a device or a tool. What it does establish is the precondition that matters: the duplicate check runs before the user has authenticated, using only the app's guest-level credentials. No session belonging to the victim is needed, and no interaction from the victim is needed either.

In plain terms: the attacker does not need to log in as the victim, does not need the victim to click anything, and does not need to be sitting at the victim's phone. The attacker only needs to be able to reach the login screen and type an email address or phone number into it. That is a very low bar, which is why the finding mattered.

Finding it

The researcher, zhirinovskiy, reported the issue to HackerOne on 1 January 2022 as report #1439026, and it was disclosed on 11 February 2022. The observation was that the login-flow step which checks for an existing account returned the matching account's numeric user ID in its response, even when the account owner had switched off discoverability by email or phone.

Two things made that look wrong rather than intended. First, the check ran unauthenticated, so the response was available to anyone who could reach the login flow. Second, the discoverability preference was never consulted on this path at all. The researcher also found that the step returned IDs for suspended accounts.

Why do those two points matter? A login step that says "this email is already registered, please enter your password" is normal and useful. But a login step that says "this email belongs to account number 12345678" has handed over an identity, not a decision. And because the check never looked at the discoverability setting, the user's choice was simply not part of the calculation. Suspended accounts are supposed to be even less visible than ordinary ones, so returning their IDs too showed the problem was not a one-off.

Exploitation

Step 1: submit an identifier to the duplicate check

The login flow accepts a phone number or an email address and asks the backend whether it belongs to an existing account. The report does not reproduce the request itself, so the exact endpoint, parameters and headers are not available here. What it does state is that the call is made with guest-level credentials only, before any proof of identity.

Why take this step? Because the login flow has to know whether to show "enter your password" or "create a new account". The app cannot decide that on its own; it has to ask the server. The researcher's insight was to look at what the server sent back, not just at what the app displayed.

Step 2: read the user ID out of the response

The response to that check carried the numeric user ID of the matching account. That is the whole leak: the step needed only a yes or no answer to decide how to continue, but it returned an identity instead.

Think of it as asking a librarian "do you have this book?" and being handed a slip with the borrower's membership number on it. The yes or no was all the app needed. The membership number was extra, and it was the part that caused the harm.

Step 3: resolve the ID to a profile

A user ID resolves to a public profile in one further lookup. The report does not show that lookup. The consequence it draws is that the distance between "this email exists" and "this email is @someone" was zero.

In other words, the ID is not a dead end. So the chain is: type an email, receive an ID, look up the ID, see the person. Two short steps, no password, no notification to the account owner.

Step 4: repeat at scale

Because the step is unauthenticated and cheap, the same sequence can be run over a list of phone numbers and email addresses. The report notes that anyone with basic scripting could link large lists of identifiers to accounts.

Why does scale change the severity? One lookup is an embarrassment. A million lookups is a database of who is who, built without anyone's consent.

Root cause

The duplicate check was written to answer a question the login flow needed answered, but it answered a bigger one. It looked up the account behind the identifier and returned the account's user ID, without consulting the discoverability preference and without requiring the requester to be authenticated. The privacy rule existed at the feature layer that users see, and was not enforced at the data layer that this particular client path touches.

A useful comparison is a building with a reception desk that politely refuses to give out room numbers, while the lift panel in the lobby still lists every guest by name. The rule was applied where people ask, not where the information actually lives. Any new path that reaches the same data, such as a new app version or a new login step, can quietly skip the rule unless the rule sits with the data itself.

Existing defences did not stop it because the check was a legitimate part of onboarding: it had to run before authentication to be useful, and it had to look the identifier up to work.

Impact

A single lookup is a privacy leak. Scripted lookups turn it into a database: the report warns that anyone with basic scripting could link huge lists of phone numbers and emails to accounts, data valuable for spam, for selling, and for targeting celebrities and pseudonymous users. For anyone who relies on a separate identity for safety, unmasking is the whole harm.

The conditions are narrow but easy to meet: the attacker needs only the identifier and access to the unauthenticated login step. It records the severity as High on HackerOne, the weakness as Improper Access Control (Generic), no CVE, and a bounty of $5,040.

"Pseudonymous" means someone who uses an account under a name that is not their real one, on purpose. That might be a writer who keeps a separate account for sensitive topics, or someone escaping harassment. For them, the link between a phone number and an account is not a minor detail; it is the thing that keeps them safe. The report lists that harm alongside spam, selling and targeting.

Fix

The write-up's own recommendations, presented as analysis rather than as what Twitter did, are:

  1. Enforce privacy at the lookup layer, so every path that maps an identifier to an account calls one policy function.
  2. Have pre-authentication steps return decisions, not identities: "continue" or "try again", never a user ID.
  3. Rate limit by identifier and by client, so bulk matching costs real effort rather than a loop.
  4. Watch for enumeration, alerting on guest sessions that try many distinct identifiers.

The write-up includes a sketch of the policy function and a test note:

Python
def resolve_identifier(identifier, requester):    account = accounts.find_by_email_or_phone(normalise(identifier))    if requester.is_unauthenticated():                limiter.hit(f"lookup:{requester.client_id}", identifier)          return NextStep("password")      if account is None or not account.discoverable_by_contact:        return NotFound()                return Found(public_handle(account))

Line by line, in plain words:

  • def resolve_identifier(identifier, requester): starts a function that takes two things: the email or phone number being checked, and information about who is asking.
  • account = accounts.find_by_email_or_phone(normalise(identifier)) looks up the account behind the identifier. normalise means tidying the input first, for example removing spaces or matching letter case, so the same address is not treated as two different ones.
  • if requester.is_unauthenticated(): asks whether the person making the request has not logged in. This is the guest case, the one that caused the bug.
  • limiter.hit(f"lookup:{requester.client_id}", identifier) records the attempt against both the client and the identifier, so a script sending many requests can be slowed down or noticed.
  • return NextStep("password") sends back only a decision: move to the password step. No ID, no name, nothing that identifies the account.
  • if account is None or not account.discoverable_by_contact: handles two cases together: the identifier matches no account, or it matches an account whose owner has switched off discoverability by contact details.
  • return NotFound() gives the same answer in both cases, so a hidden account looks exactly like a missing one.
  • return Found(public_handle(account)) is the only path that returns something about the account, and only when the owner allows it, and only the public handle rather than an internal ID.
Text
# Test: guest flow must never emit user IDs; hidden account == missing account in response

This is a note about how to test the fix. It says two things. First, a guest, meaning someone not logged in, should never receive a user ID from this flow. Second, a hidden account and a missing account should produce the same response, so an attacker cannot tell them apart. If those two statements hold, the leak is closed.

Variants to test

These are the places a researcher would look next, and why each one is worth trying.

  • Other pre-authentication lookups. Any signup, password-reset or account-recovery step that takes an email or phone number. A positive result is a response that differs between an existing hidden account and a missing one, or that carries an internal identifier. The reasoning is simple: if one login step forgot the privacy rule, its siblings may have too.
  • Response diffing for hidden versus missing accounts. Compare status codes, body length, field names and timing for an account with discoverability off against an identifier that does not exist. A positive result is any observable difference. "Diffing" just means putting two responses side by side and looking for anything that is not identical, including how long each one took.
  • Identifier-to-profile chains. Take any internal ID returned by a guest-reachable endpoint and try to resolve it to a public profile. A positive result is a profile page or API response for an account whose owner expected not to be findable. This is the second half of the original bug, and it can exist on its own.
  • Suspended and restricted accounts. The report found IDs returned for suspended accounts; check whether other account states (deactivated, restricted, private) leak through the same path. A positive result is an ID or existence signal for an account in a state that should be invisible. The report found IDs returned for suspended accounts too.
  • Bulk behaviour. Send many distinct identifiers from one guest session and watch for throttling or alerting. A positive result is sustained unthrottled lookups, which is what makes the leak a database rather than a single disclosure. This tells you whether the fix addressed the scale problem as well as the disclosure.

Glossary

  • API: the way one piece of software asks another for information or asks it to do something, like a waiter carrying orders to a kitchen.
  • Authentication: proving who you are, for example by logging in with a password.
  • Unauthenticated: running before anyone has proved who they are, with no login required.
  • Guest-level credentials: limited proof of access handed to anyone using the app without logging in, enough to make basic requests but not tied to a person.
  • Token: a small piece of data that proves you are allowed to make a request, like a cloakroom ticket.
  • Cookie: a small piece of data a browser stores and sends back to a site, often used to remember that you are logged in.
  • Session: the period during which a site remembers who you are, usually held together by a cookie or token.
  • Endpoint: a specific address on a server that accepts a particular kind of request, like a particular counter in a shop.
  • Parameter: a named value sent with a request, such as the email address being checked.
  • Header: extra information attached to a request or response, such as what kind of data is being sent.
  • Request: a message one computer sends to another asking for something.
  • Response: the message that comes back.
  • Status code: a number in a response saying broadly what happened, such as success or not found.
  • User ID: an internal number that identifies an account in a system's records.
  • Handle: the public name of an account, such as the @name people see.
  • Profile: the public page for an account.
  • Discoverability setting: a privacy option that decides whether other people can find your account using your email address or phone number.
  • Identifier: an email address or phone number used to point at an account.
  • Duplicate check: a step in signup or login that asks whether the identifier already belongs to an existing account.
  • Login flow: the sequence of screens and requests a person goes through to sign in.
  • Onboarding flow: the multi-step process a new or returning user goes through in an app, of which login is a part.
  • Enumeration: working through a list of inputs to learn which ones exist, for example which emails have accounts.
  • Account enumeration: the specific case of learning which accounts exist.
  • Privacy-setting bypass: when a privacy rule a user set is ignored on some path through the system.
  • Improper Access Control: a weakness where something is reachable or readable by someone who should not have access to it.
  • CWE: a catalogue of common weakness types, used to label security bugs consistently.
  • CVE: a public identifier for a specific known vulnerability.
  • CVSS: a scoring system that rates the severity of a vulnerability.
  • Severity: a rating of how serious a bug is, here recorded as High on HackerOne.
  • Bounty: money paid to a researcher for reporting a valid security issue.
  • HackerOne: a platform where researchers report vulnerabilities to companies and track the reports.
  • Rate limiting: deliberately slowing down or capping how many requests someone can make in a period.
  • Throttling: the practical effect of rate limiting, where requests start being refused or delayed.
  • Alerting: automatic notification to defenders when something suspicious happens.
  • Response diffing: comparing two responses to find any observable difference between them.
  • Pseudonymous: using an account under a name that is not your real one, on purpose.
  • Unmasking: revealing who is behind an account or pseudonym.
  • Suspended account: an account that has been disabled by the platform.
  • Deactivated account: an account its owner has switched off.
  • Restricted account: an account with some functions limited by the platform.
  • Private account: an account whose posts are visible only to approved followers.
  • Policy function: a single piece of code that holds a rule, so every path can call it instead of reimplementing the rule.
  • Data layer: the part of a system where information is actually stored and fetched, as opposed to the screens users see.
  • Feature layer: the part of a system users interact with directly, such as a settings screen.
  • Root cause: the underlying reason a bug exists, as opposed to its visible symptom.
  • Normalise: tidy an input into a standard form before comparing or storing it.
  • Scripting: writing a small program to repeat an action automatically many times.

Similar reports

View all

Same bug class and techniques, clearest first.

Information disclosure

The lesson behind this report.

Data the application should keep private (personal data, internal details, other users' records) reaches someone it should not.