Skip to content
Info disclosure Write-up Intermediate

Determine-A-User-From-A-Private-Phone-Number

A GraphQL root call allowed looking up a user's Facebook identity from a phone number even when the phone number's privacy settings restricted lookup to friends only. An attacker could determine which user owns a specific phone number regardless of that user's privacy settings.

Philippe Harewood Follow

Published on philippeharewood.com

Given a phone number that has been set to private for non-friends, it is possible to determine the user who owns this number.

Philippe, on philippeharewood.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. 4 min read.

Context

Facebook lets a user control who can find them by phone number. Two settings matter here: the phone number itself can be set to "Only Me" under "Contact Information" in the profile, and the question "Who can look you up using the phone number you provided?" can be set to "Only Friends", which the report describes as the lowest setting possible.

The feature involved in the bug is a GraphQL root call named phone_number_to_loyalty_user. It belongs to a product still in testing at the time, described in a TechCrunch post about "Facebook Rewards" QR codes that offer discounts for offline purchases. The call maps a phone number to a Facebook user, which is exactly the kind of lookup the privacy settings above are meant to restrict.

Setup

The preconditions for the issue are stated directly in the report:

  1. The phone number is set to "Only Me" in "Contact Information" in the user profile.
  2. "Who can look you up using the phone number you provided?" is set to "Only Friends" (the lowest setting possible).
  3. The user whose number is being looked up is not a friend of the person doing the lookup.

No special tooling is described. The researcher used the methodology from Inti De Ceukelaire's article "How I got your phone number through Facebook" in the exploit demonstration, and credits the recon methodology in the "Scrutiny on the Bug Bounty" presentation by Shubs (@infosec_au) and Naffy (@nnwakelam) as the basis for identifying assets and endpoints at scale.

Finding it

The base case is a simple lookup via facebook.com, which shows that the user can be looked up as a friend.

That is the expected case. The interesting question is what happens for a non-friend, and the report shows that the ordinary lookup path does not return the user in that situation.

The ordinary lookup does not return the user for a non-friend. The GraphQL root call returns the owning user for a number set to private for non-friends. That mismatch between the two paths is the bug.

Exploitation

Step 1: call the GraphQL root call with the target phone number

The proof of concept is a single GraphQL root call query. The request is:

Text
phone_number_to_loyalty_user({phone_number:PHONE_NUMBER}){fb_user}

The call takes the phone number as its argument and asks for the fb_user field. The response is:

JSON
{
    "response": {
        "fb_user": {
            "id": "USER_ID", "url": "https://www.facebook.com/username", "name": "FirstName LastName"
        }
    }
}

The response identifies the owner of the number directly: the numeric user id, the profile URL and the full name. No friendship is required, and the number can be set to private for non-friends. The researcher notes that the root call belongs to a feature still in testing, the Facebook Rewards QR code product.

Root cause

The report does not describe the server-side code, so the exact mistake is not stated. What it shows is that the phone_number_to_loyalty_user root call resolves a phone number to a user without applying the "Who can look you up using the phone number you provided?" setting, while the normal facebook.com lookup does apply it.

Impact

A malicious user could determine which user owns a specific phone number regardless of that user's privacy settings. The conditions are the ones in the setup: the number set to "Only Me", the lookup setting at "Only Friends", and no friendship between attacker and victim.

Fix

Facebook fixed the issue on May 9, 2017, the day after the report was sent and the same day it was escalated. The report does not say what the fix changed.

Timeline

Date Event
May 8, 2017 Report sent
May 9, 2017 Escalation by Facebook
May 9, 2017 Fixed by Facebook
May 17, 2017 Bounty awarded by Facebook

Variants to test

  1. Enumerate other GraphQL root calls that take a phone number, email address or other identifier and return a user object. A positive result is a response containing an id, profile URL or name for an identifier whose owner has restricted discoverability.
  2. Compare every new or in-testing feature that resolves identifiers against the equivalent legacy lookup path, using an account that is not a friend and has the strictest settings. A positive result is any discrepancy where the new path returns the user and the legacy path does not.
  3. Test the same root call with identifiers belonging to accounts that have never interacted with the attacker, to confirm the result does not depend on prior contact. A positive result is a resolved user for a completely unrelated account.
  4. Check whether the response fields can be widened, for example by requesting additional fields on fb_user, to see how much profile data the call exposes. A positive result is extra fields returned beyond what the feature needs.

Thanks

The researcher thanks Inti De Ceukelaire for the groundwork explaining the risk of phone number lookups, and Shubs (@infosec_au) and Naffy (@nnwakelam) for the recon methodology in "Scrutiny on the Bug Bounty", which helped build a base methodology for identifying assets and endpoints at scale.

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. 10 min read.

What happened, in plain words

Facebook lets you decide who can find you by your phone number. You can hide the number itself, and you can also say that only your friends may look you up using it. The idea is simple: if you set both to the strictest option, a stranger should not be able to type your number into Facebook and learn who you are.

This report shows that one part of Facebook ignored those settings. A feature that was still being tested, connected to a rewards programme with QR codes, had a way of asking the system "which user owns this phone number?". That question answered honestly even when the number belonged to someone who had hidden it and had allowed lookups only by friends. The person asking did not need to be a friend.

The report shows the normal lookup does not return the user for a non-friend, while the newer path does. The report was sent on 8 May 2017, Facebook escalated and fixed it the next day, and a bounty was awarded on 17 May 2017.

Background concepts, from zero

Before walking through the steps, here are the ideas you need. None of them require any prior security knowledge.

  • Privacy setting: a switch in your account that says who is allowed to see or use a piece of your information. Here, two switches matter: whether your phone number is visible at all, and who may use it to find you.
  • Lookup: typing something (a name, an email, a phone number) into a search box and getting an account back. Facebook's normal search is a lookup.
  • Friend vs non-friend: Facebook treats people you have added as friends differently from strangers. Many features only work between friends.
  • API: a way for one piece of software to ask another piece of software for information, without a human clicking buttons. Think of it as a waiter: you tell the waiter what you want from the kitchen, and the waiter brings it back. You never walk into the kitchen yourself. A website's own pages use APIs behind the scenes, and so do mobile apps.
  • GraphQL: a style of API where the client sends a description of exactly which pieces of data it wants, and the server returns those pieces in a matching shape. Instead of many fixed addresses (one per thing), there is usually one address, and the request text says what to fetch. It is a bit like ordering at a restaurant by writing a list ("one soup, no bread, extra salt") rather than picking from numbered menu items.
  • Root call / query: a named entry point in a GraphQL API. You call it by name and give it arguments, and it returns data. In this report the name is phone_number_to_loyalty_user.
  • Argument: a value you hand to a call so it knows what you are asking about. Here the argument is the phone number.
  • Field: a named piece of data inside a response, such as id, url or name.
  • Response: what the server sends back, usually in JSON, a text format that looks like labelled boxes inside boxes.
  • JSON: a way of writing data as text using curly braces, quotes and colons. It is readable by both humans and programs.
  • Endpoint: a specific address on a server that accepts a particular kind of request. Different endpoints can enforce different rules, which is the heart of this bug.
  • Access control / authorisation: the rules that decide whether a given person is allowed to do a given thing. When one endpoint checks the rules and another does not, that is an access control bug.
  • Recon (reconnaissance): the exploratory work of mapping out what a system contains: which addresses exist, which features are live, which are in testing. It is like walking around a building to note which doors exist before trying any of them.
  • Bounty: a payment a company makes to someone who reports a security problem responsibly.

The two settings that matter

Facebook gives a user control over who can find them by phone number. Two settings are relevant:

  1. The phone number itself can be set to "Only Me" under "Contact Information" in the profile. That means the number is not shown to other people.
  2. The question "Who can look you up using the phone number you provided?" can be set to "Only Friends", which the report calls the lowest setting possible. That means only people you have added as friends may use your number to find your account.

Together these are meant to make a number effectively private to strangers. The rest of the report is about a path that ignored them.

The feature involved

The call at the centre of the bug is a GraphQL root call named phone_number_to_loyalty_user. It belongs to a product that was still in testing at the time, described in a TechCrunch post about "Facebook Rewards" QR codes that offer discounts for offline purchases. In plain terms: a rewards scheme where a code could be scanned in a shop. That is exactly the kind of connection the privacy settings above are supposed to restrict.

Setup: what had to be true

The report states the preconditions directly:

  1. The phone number is set to "Only Me" in "Contact Information" in the user profile.
  2. "Who can look you up using the phone number you provided?" is set to "Only Friends" (the lowest setting possible).
  3. The user whose number is being looked up is not a friend of the person doing the lookup.

In other words, the victim has done everything right, and the attacker is a stranger. No special tooling is described. The researcher used the methodology from Inti De Ceukelaire's article "How I got your phone number through Facebook" in the exploit demonstration, and credits the recon methodology in the "Scrutiny on the Bug Bounty" presentation by Shubs (@infosec_au) and Naffy (@nnwakelam) as the basis for identifying assets and endpoints at scale.

Finding it: start from normal behaviour

The researcher began with the ordinary case, because you cannot spot something abnormal until you know what normal looks like. A simple lookup via facebook.com shows that a user can be found by phone number when the searcher is a friend.

That is the expected case: the setting says friends may look you up, and a friend can. The interesting question is what happens for a non-friend. The report shows that the ordinary lookup path does not return the user in that situation.

The normal web lookup does not return the user for a non-friend. The GraphQL root call returns the owning user for a number set to private for non-friends. That mismatch between the two paths is the bug. One door checks your badge; the other door next to it does not.

Exploitation

Step 1: call the GraphQL root call with the target phone number

The proof of concept is a single GraphQL root call query. The request is:

Text
phone_number_to_loyalty_user({phone_number:PHONE_NUMBER}){fb_user}

Line by line, in plain words:

  • phone_number_to_loyalty_user is the name of the root call. It is the entry point being asked.
  • ({phone_number:PHONE_NUMBER}) is the argument list. It says: this call takes a value called phone_number, and here is the number to use. PHONE_NUMBER is a placeholder for the real number.
  • {fb_user} is the list of fields wanted back. It says: give me the fb_user object, the Facebook user connected to that number.

So the whole request reads as: "Using this phone number, tell me which Facebook user it belongs to." The response is:

JSON
{
    "response": {
        "fb_user": {
            "id": "USER_ID", "url": "https://www.facebook.com/username", "name": "FirstName LastName"
        }
    }
}

Line by line:

  • The outer { and } wrap the whole reply.
  • "response" is the top-level box holding the answer.
  • "fb_user" is the user object that was asked for.
  • "id": "USER_ID" is the numeric account identifier. USER_ID is a placeholder for the real value.
  • "url": "https://www.facebook.com/username" is the profile address. username is a placeholder.
  • "name": "FirstName LastName" is the full name. FirstName LastName is a placeholder.

The response identifies the owner of the number directly: the numeric user id, the profile URL and the full name. No friendship is required, and the number can be set to private for non-friends. The researcher notes that the root call belongs to a feature still in testing, the Facebook Rewards QR code product.

Root cause

The report does not describe the server-side code, so the exact mistake is not stated. What it shows is that the phone_number_to_loyalty_user root call resolves a phone number to a user without applying the "Who can look you up using the phone number you provided?" setting, while the normal facebook.com lookup does apply it. In everyday terms: the building has a front desk that checks visitors, and a side door added later for a new service that nobody thought to connect to the same check.

Impact

A malicious user could determine which user owns a specific phone number regardless of that user's privacy settings. The conditions are the ones in the setup: the number set to "Only Me", the lookup setting at "Only Friends", and no friendship between attacker and victim.

Fix

Facebook fixed the issue on May 9, 2017, the day after the report was sent and the same day it was escalated. The report does not say what the fix changed.

Timeline

Date Event
May 8, 2017 Report sent
May 9, 2017 Escalation by Facebook
May 9, 2017 Fixed by Facebook
May 17, 2017 Bounty awarded by Facebook

Variants to test

These are the follow-up checks the technical write-up lists. They are written for someone who now understands the basic idea and wants to look for the same class of mistake elsewhere.

  1. Enumerate other GraphQL root calls that take a phone number, email address or other identifier and return a user object. A positive result is a response containing an id, profile URL or name for an identifier whose owner has restricted discoverability. In plain words: find other doors that answer the same kind of question, and see whether any of them skip the badge check.
  2. Compare every new or in-testing feature that resolves identifiers against the equivalent legacy lookup path, using an account that is not a friend and has the strictest settings. A positive result is any discrepancy where the new path returns the user and the legacy path does not. In plain words: if the old door says no and the new door says yes, the new door is the problem.
  3. Test the same root call with identifiers belonging to accounts that have never interacted with the attacker, to confirm the result does not depend on prior contact. A positive result is a resolved user for a completely unrelated account. In plain words: make sure the answer is not just because the two accounts had some earlier connection.
  4. Check whether the response fields can be widened, for example by requesting additional fields on fb_user, to see how much profile data the call exposes. A positive result is extra fields returned beyond what the feature needs. In plain words: ask for more than the feature normally asks for, and see whether the server hands it over.

Thanks

The researcher thanks Inti De Ceukelaire for the groundwork explaining the risk of phone number lookups, and Shubs (@infosec_au) and Naffy (@nnwakelam) for the recon methodology in "Scrutiny on the Bug Bounty", which helped build a base methodology for identifying assets and endpoints at scale.

Glossary

  • API: a way for software to ask another piece of software for information, without a human clicking through pages.
  • Argument: a value passed to a call so it knows what you are asking about, such as a phone number.
  • GraphQL: an API style where the client describes exactly which pieces of data it wants and the server returns them in a matching shape.
  • JSON: a text format for data using curly braces, quotes and colons, readable by humans and programs.
  • Lookup: searching for an account using an identifier such as a name, email address or phone number.
  • Non-friend: someone you have not added as a friend on the platform.
  • Privacy setting: a switch in an account that says who may see or use a piece of information.
  • Recon (reconnaissance): exploratory mapping of what a system contains, such as which addresses and features exist.
  • Response: what a server sends back after a request.
  • Root call / query: a named entry point in a GraphQL API that you call with arguments to get data back.
  • Rate limiting: a limit on how often the same request can be made in a period of time.
  • QR code: a square barcode that a phone camera can scan to open a link or trigger an action.

More by Philippe Harewood

View all

56 more disclosed reports, best first.

More from Meta

View all

The newest disclosed reports for this program.

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.