Skip to content
Info disclosure Write-up Intermediate

View-Facebook-Friends-For-Any-User

A GraphQL endpoint on Facebook's iOS app returned different icons depending on whether two users were friends, allowing an attacker to determine friendship status. The endpoint also unserialized user-provided data, potentially loading content in another user's context.

Philippe Harewood Follow

Published on philippeharewood.com

Using the response from a specific GraphQL call in iOS, it is possible to get an indicator that two users are friends. This is because the call, given the right context, provides the message icon if the two entities in the call are connected, and the friend icon if otherwise.

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's iOS client makes GraphQL calls to graph.facebook.com/graphql/ to render parts of the interface. One of these calls, search/call_to_action, supplies the utility features used when presenting actions to take while searching for Facebook users. The response from that call carries an indicator of the relationship between the viewer and the profile being displayed: the message icon appears when the two entities are connected, and the friend icon appears otherwise.

That indicator is the whole subject of this write-up. If the call can be made with an arbitrary context, the icon becomes an oracle for whether two users are friends.

Setup

Proving the behaviour to Facebook required a specific arrangement of accounts:

  1. Two friends with no other connections.
  2. Private friend lists on those accounts.

Larger test cases tend to get complex to prove, which is why the report points to the Vulnerabilities you shouldn't write about section of Facebook Bug Bounties, The Unofficial Treasure Map for the reasoning about minimal, provable setups.

Finding it

Using the response from a specific GraphQL call in iOS, it is possible to get an indicator that two users are friends. The call, given the right context, provides the message icon if the two entities in the call are connected, and the friend icon if otherwise. From testing, it seems the context is supplied by the caller rather than fixed to the session, so the relationship being rendered may not be the viewer's own.

Exploitation

Step 1: replay the GraphQL call with a chosen context

The proof of concept is the following request:

HTTP
HTTP POST
graph.facebook.com/graphql/
query_id=QUERYID
query_params={"0":1,"1":{"payload":"search/call_to_action?placeholder_id=SOME_URL_ENCODED_DATA", "snipped"}}

This was a GraphQL call to provide some utility features for presenting actions to take when searching for Facebook users. The query_params value carries a payload string pointing at search/call_to_action with a placeholder_id parameter whose value is URL-encoded data (SOME_URL_ENCODED_DATA).

Step 2: supply two identities in the encoded data

In the SOME_URL_ENCODED_DATA section there were fields to provide a context for the viewer as well as the entity being viewed. From testing, it seems the first is the profile displayed from a search result. The second ID is used for context. This means that if one used another ID (not belonging to the session), the alternative context would be provided for the searched profile.

Step 3: read the icon in the response

A list of four profiles was used to demonstrate the behaviour, and in only two cases the message icon showed:

  1. Friend 1
  2. Friend 2
  3. Non-friend
  4. Session user

The last row was empty for the session user, but when viewed from the context of others it presented data. In other words, the icon in the response tells you whether the profile in the first field is friends with the identity supplied in the second field.

Root cause

An end-point was discovered which was unserializing user-provided data. The context identity used to render the call-to-action was taken from that user-provided data rather than being bound to the authenticated session, so the relationship check was performed between two arbitrary users instead of between the viewer and the displayed profile. The report does not describe which defence, if any, was expected to constrain the context.

Impact

This could have leaked whether two users are friends, in addition to the potential for loading user content in the context of another user. The setup used accounts with private friend lists, so the icon revealed a friendship that was not otherwise visible. The report does not state how broadly the technique scales beyond the minimal two-friend setup used to demonstrate it.

Fix

Facebook mitigated the issue on Apr 21, 2018, and confirmed final fixes on Oct 16, 2018.

Timeline

Date Event
Apr 18, 2018 Report sent
Apr 20, 2018 Further investigation by Facebook
Apr 21, 2018 Mitigation by Facebook
Apr 24, 2018 $10,000 bounty awarded by Facebook
Oct 16, 2018 Confirmation of final fixes and disclosure request
  1. Other call-to-action or search GraphQL operations. Look for any operation whose response renders a relationship-dependent element (message button, friend button, follow state). A positive result is an element that changes when you swap only the context identity in the encoded payload.
  2. Other parameters inside the encoded payload. The report identifies two identity fields, one for the displayed profile and one for context. Try supplying a context identity that does not belong to the session and check whether the rendered action reflects that identity's relationship to the displayed profile.
  3. Private-list accounts as the pair under test. Use two accounts that are friends with no other connections and private friend lists. A positive result is the message icon appearing for a pair whose friendship is not otherwise visible to you.
  4. Unserialisation sinks in mobile API payloads. Any parameter that is deserialised server-side and then used for authorisation or rendering decisions is worth probing with a substituted identity. A positive result is a response that reflects another user's context rather than your own.

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's iPhone app talks to Facebook's servers to draw parts of its screens. One of those conversations is a request to a service called GraphQL, which is a way for an app to ask the server for exactly the pieces of information it needs. One particular request, named search/call_to_action, is used when you search for people on Facebook and the app wants to show you buttons you can tap, such as a message button.

The reply to that request contains a small clue about the relationship between two people: whether the person looking and the person being shown are friends. The app shows a message icon when the two are connected, and a friend icon when they are not.

From testing, it seems the request let the caller supply the context identity rather than taking it from the session. Normally the server should work that out from your logged-in session, the same way a bank should know who you are from your login rather than from a form field you fill in. Here, the identity used for the friendship check came from data the caller supplied. That turned the icon into an indicator of whether two users are friends, which could have leaked that relationship.

This write-up explains, from scratch, what was requested, why it worked, and what Facebook did about it.

Background: the pieces involved

Before the steps make sense, here are the basic ideas.

An API is a way for one piece of software to ask another for something, like a waiter taking your order to the kitchen. The app does not cook the data itself; it asks Facebook's servers and gets an answer back.

GraphQL is a style of API where the app sends a query describing what it wants, and the server answers with data shaped to that query. Facebook uses it heavily in its mobile apps.

A session is the server's memory of who you are after you log in. When your app makes a request, it proves which session it belongs to, usually with a cookie or a token. A cookie is a small piece of data your browser or app stores and sends back with each request, like a wristband at an event that proves you paid to get in. A token is a similar proof, often a long string of characters.

A parameter is a named value inside a request, for example placeholder_id=something. Parameters are how the caller passes details to the server.

URL encoding is a way of writing characters inside a web address so they do not break it. Spaces and symbols get replaced with codes such as %20. The report calls the encoded blob SOME_URL_ENCODED_DATA.

Unserialising means turning a stored or transmitted format (such as a string of text) back into a structured object the program can use. It is like unpacking a flat-pack box: the parts arrive as a bundle and the program assembles them. If the bundle comes from the user, the program must be careful about what it assembles.

An oracle, in security, is anything that answers a question you are not supposed to be able to ask. A login page that says "wrong password" versus "no such user" is a small oracle: it tells you which usernames exist. Here, the icon was the oracle: it answered "are these two people friends?"

A private friend list is a setting that hides who your friends are from other people. The point of the finding is that the icon revealed a friendship even when the list was private, because it did not read the list; it asked a different question and got an answer.

Setting up a provable test

To show Facebook the behaviour clearly, the test needed a very specific arrangement of accounts:

  1. Two friends with no other connections.
  2. Private friend lists on those accounts.

The report says larger cases tend to get complex to prove, which is why it points to the section on vulnerabilities you shouldn't write about. With two isolated accounts and private lists, the only way to learn that they are friends is the icon itself. The report points to the Vulnerabilities you shouldn't write about section of Facebook Bug Bounties, The Unofficial Treasure Map for the reasoning about keeping test cases minimal and provable.

Finding it

Using the response from a specific GraphQL call in iOS, it is possible to get an indicator that two users are friends. The call, given the right context, provides the message icon if the two entities in the call are connected, and the friend icon if otherwise.

The key observation is that the context is supplied by the caller rather than fixed to the session. In everyday terms: imagine a form at a hotel reception that asks "who are you?" and "who do you want to visit?". If the receptionist checks the answer you wrote instead of your ID card, you can write someone else's name and learn whether that person knows the guest. That is the shape of the bug.

Exploitation

Step 1: replay the GraphQL call with a chosen context

The proof of concept is the following request:

HTTP
HTTP POST
graph.facebook.com/graphql/
query_id=QUERYID
query_params={"0":1,"1":{"payload":"search/call_to_action?placeholder_id=SOME_URL_ENCODED_DATA", "snipped"}}

Line by line:

  • HTTP POST says this is a request that sends data to the server, rather than just asking for a page. Think of it as submitting a form rather than clicking a link.
  • graph.facebook.com/graphql/ is the address of Facebook's GraphQL service. This is where the app sends its queries.
  • query_id=QUERYID names which stored query the server should run. Facebook keeps queries on its side and the app refers to them by identifier; QUERYID is a placeholder for that identifier.
  • query_params={...} carries the details for the query as a JSON object. JSON is a common text format for structured data, using curly braces for objects and quotes around names. Inside it, "0":1 is one entry, and "1" is another entry whose value is itself an object with a payload field. The payload points at search/call_to_action with a placeholder_id parameter whose value is the URL-encoded data. The word snipped marks where the report shortened the request.

This was a GraphQL call to provide some utility features for presenting actions to take when searching for Facebook users. In other words, it is the request behind the buttons the app offers when you look someone up.

Step 2: supply two identities in the encoded data

In the SOME_URL_ENCODED_DATA section there were fields to provide a context for the viewer as well as the entity being viewed. From testing, it seems the first is the profile displayed from a search result. The second ID is used for context.

So the encoded blob carries two identities: who is being shown, and who is looking. The second one is the interesting one, because it is not tied to the session. This means that if one used another ID (not belonging to the session), the alternative context would be provided for the searched profile. You are effectively telling the server "pretend this other person is looking at this profile" and the server does so when deciding which icon to draw.

Step 3: read the icon in the response

A list of four profiles was used to demonstrate the behaviour, and in only two cases the message icon showed:

  1. Friend 1
  2. Friend 2
  3. Non-friend
  4. Session user

Why four? The list contained two friends, a non-friend and the session user, and the message icon showed in only two cases.

The last row was empty for the session user, but when viewed from the context of others it presented data. In plain terms, the icon in the response tells you whether the profile in the first field is friends with the identity supplied in the second field. Swap the second identity and the answer changes accordingly.

Root cause

An end-point was discovered which was unserialising user-provided data. The context identity used to render the call-to-action was taken from that user-provided data rather than being bound to the authenticated session, so the relationship check was performed between two arbitrary users instead of between the viewer and the displayed profile.

Using the hotel comparison again: the receptionist should check your ID card (the session) to decide who you are. Instead, the receptionist read the name you wrote on the form (the user-provided data) and acted on it. The report does not describe which defence, if any, was expected to constrain the context.

Impact

This could have leaked whether two users are friends, in addition to the potential for loading user content in the context of another user.

The friendship disclosure matters precisely because it works against users with private friend lists: the icon bypasses the visibility setting rather than reading the list itself. If you have hidden your friends, someone should not be able to confirm a friendship by asking a side question and watching which button appears. The report does not state how broadly the technique scales beyond the minimal two-friend setup used to demonstrate it.

Fix

Facebook mitigated the issue on Apr 21, 2018, and confirmed final fixes on Oct 16, 2018.

Timeline

Date Event
Apr 18, 2018 Report sent
Apr 20, 2018 Further investigation by Facebook
Apr 21, 2018 Mitigation by Facebook
Apr 24, 2018 $10,000 bounty awarded by Facebook
Oct 16, 2018 Confirmation of final fixes and disclosure request

If you want to look for similar issues yourself, these are the directions the report suggests. Each one is a way of asking the same underlying question: does the server trust an identity that came from the caller?

  1. Other call-to-action or search GraphQL operations. Look for any operation whose response renders a relationship-dependent element (message button, friend button, follow state). A positive result is an element that changes when you swap only the context identity in the encoded payload. In everyday terms, find other buttons that change depending on who is looking, then try to change who the server thinks is looking.
  2. Other parameters inside the encoded payload. The report identifies two identity fields, one for the displayed profile and one for context. Try supplying a context identity that does not belong to the session and check whether the rendered action reflects that identity's relationship to the displayed profile.
  3. Private-list accounts as the pair under test. Use two accounts that are friends with no other connections and private friend lists. A positive result is the message icon appearing for a pair whose friendship is not otherwise visible to you. This is the cleanest way to show that the icon reveals something new.
  4. Unserialisation sinks in mobile API payloads. Any parameter that is deserialised server-side and then used for authorisation or rendering decisions is worth probing with a substituted identity. A positive result is a response that reflects another user's context rather than your own. A "sink" here just means the place where the unpacked data ends up being used, the point where a careless unpack can turn into a wrong decision.

Glossary

  • API: a way for one piece of software to ask another for data or actions, like a waiter carrying orders between you and the kitchen.
  • Cookie: a small piece of data stored by your browser or app and sent back with requests, often used to prove which session you belong to.
  • GraphQL: a style of API where the caller sends a query describing the data it wants and the server answers with data shaped to that query.
  • JSON: a text format for structured data, using curly braces for objects, square brackets for lists, and quotes around names and text values.
  • Oracle: any response that answers a question you are not supposed to be able to ask, such as an icon that reveals whether two people are friends.
  • Parameter: a named value passed inside a request, such as placeholder_id=something.
  • Payload: the part of a request that carries the actual data being sent, as opposed to the address or the method.
  • Private friend list: a setting that hides who your friends are from other people.
  • Session: the server's memory of who you are after you log in, usually proven by a cookie or token.
  • Sink: the place in a program where data ends up being used, such as a decision about what to show or whether to allow something.
  • Token: a string of characters used as proof of identity or permission, similar in purpose to a cookie.
  • Unserialising: turning stored or transmitted data, such as a string, back into a structured object the program can use.
  • URL encoding: writing characters inside a web address using codes such as %20 so that spaces and symbols do not break the address.

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.