Skip to content
IDOR Write-up Intermediate

Disclose Page Admins via Facebook Appointments

A GraphQL batch endpoint accepted a page identifier and date range without checking that the caller had any relationship to that page, so it returned all appointment records for any page. An attacker could enumerate appointments for arbitrary Facebook Pages and learn the identity of the page administrators who created them.

Ramzy Bouyahya Follow

Published on medium.com

Bug Bounty

Ramzy Bouyahya, 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. 4 min read.

Context

Facebook Pages is the product that lets a person or organisation run a public presence on Facebook. A page has administrators, and those administrators are private individuals behind the page. The Pages product also offers appointments, which a page admin can create on their page so that people can book time with the page.

This write-up is about a flaw in that appointments feature. An attacker could send a crafted request to Facebook's GraphQL endpoint and receive back the appointment details of any page, including the identity of the user who created the appointments, that is, the page administrator. The researcher is Ramzy Bouyahya, and the issue was reported to Facebook Security in October 2018.

Setup

The report describes two roles:

  1. A victim, who is the administrator of a page referred to as page_a. The victim creates an appointment on their page.
  2. An attacker, who sends a crafted request to the GraphQL endpoint.

The only tooling shown is a raw HTTP request. The request carries a fb_dtsg value, which is the anti-CSRF token Facebook attaches to authenticated requests, so the attacker is acting as a logged-in Facebook user.

Finding it

The researcher found that the GraphQL endpoint accepted a query that asked for the appointments of a page, identified by pageID, over a date range. The query was sent through the batch endpoint, /api/graphqlbatch/, which lets a client submit several named queries in one request. The response to that query contained details of all appointments, including the user who created them, which is the page admin. That identity should remain private, so the fact that it came back to a user who was not the page admin is what made the behaviour wrong.

Exploitation

Step 1: The victim creates an appointment

The page admin of page_a creates an appointment on their page. This is the normal use of the feature and is the precondition for the attack.

Step 2: The attacker sends a crafted GraphQL batch request

The attacker sends the following request to the GraphQL endpoint:

HTTP
POST /api/graphqlbatch/?dpr=1 HTTP/1.1Host: www.facebook.comUser-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:62.0) Gecko/20100101 Firefox/62.0Accept: */*Content-Type: application/x-www-form-urlencodedConnection: close__user=&__a=1&__dyn=&__req=a&__be=1&__pc=&__rev=&fb_dtsg=AQHJVmZ8roIv%3AAQFBvwa5EaqB&queries={  "o0":{    "doc_id":"1735616686561494",    "query_params":{      "pageID":"ID_PAGE_A",      "startDate":1,      "endDate":9999999999999999    }  }}

The important parts of the request are:

  • POST /api/graphqlbatch/?dpr=1: the batch GraphQL endpoint.
  • Host: www.facebook.com: the request goes to the main Facebook host.
  • Content-Type: application/x-www-form-urlencoded: the body is form-encoded, which is how the batch endpoint receives its parameters.
  • fb_dtsg=AQHJVmZ8roIv%3AAQFBvwa5EaqB: the anti-CSRF token, so the request is authenticated as the attacker's session.
  • queries={...}: a JSON object of named queries. The single query is named o0 and has two fields:
    • doc_id: "1735616686561494": the identifier of the persisted GraphQL document that resolves appointments for a page.
    • query_params: the parameters passed to that document. pageID is set to ID_PAGE_A, the target page. startDate is 1 and endDate is 9999999999999999, a range wide enough to cover every appointment.

Step 3: The response

The API response contained details of all appointments, including the user who created them, that is, the page admin. The report does not reproduce the response body; it only states what it contained.

Root cause

The appointments query resolved by doc_id 1735616686561494 returned appointment records, including the creating user, to a caller who was not the page admin. The report does not describe the server-side code, so the exact check that was missing is not stated; the behaviour is consistent with an authorisation check that was absent or applied to the wrong object.

That protection stops cross-site request forgery, not a logged-in user asking for data they should not see, so it did not prevent this.

Impact

An attacker could enumerate the appointments of any Facebook Page. Because each appointment record included the user who created it, the attack leaked the identity of page administrators, which should remain private.

Fix

Facebook confirmed the issue was patched on October 15, 2018. The report does not describe the change that was made.

Timeline

Date Event
October 12, 2018 Vulnerability reported to Facebook Security.
October 15, 2018 Facebook confirmed the issue was patched.
October 17, 2018 Issue resolved and a bounty of $2000 was awarded.

Variants to test

  1. Other persisted GraphQL documents. Take any doc_id used by the Pages product and replay it through /api/graphqlbatch/ with a pageID you do not administer. A positive result is a response containing records for that page.
  2. Other object identifiers in query_params. Swap pageID for other identifiers the document accepts, such as appointment IDs or user IDs, and see whether the response still returns data belonging to another account. A positive result is data for an object you do not own.
  3. Widening the date range. Set startDate and endDate to cover all time, as in the report, on any endpoint that filters by date. A positive result is records outside the range a normal client would request.
  4. Batch endpoint with several queries. Submit multiple named queries in one queries object, mixing one you are allowed to run with one you are not. A positive result is that the unauthorised query returns data alongside the authorised one, which can also reveal whether per-query authorisation is applied.

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

What happened, in plain words

Facebook Pages is the part of Facebook that lets a person or an organisation run a public presence: a business, a band, a charity. Behind every page there are administrators, the people who post and manage it. Those administrators are private individuals, and Facebook does not show the world who they are.

Pages also offer appointments. A page admin can set up bookable time slots on the page so that customers can arrange to meet or speak with the page. The feature is meant to be a booking calendar, nothing more.

Ramzy Bouyahya found that this booking feature gave away too much. By sending a specially built request to one of Facebook's internal data endpoints, a logged-in user could ask for the appointments of any page, not just their own. The answer came back with the appointment details and, with them, the identity of the person who had created those appointments: the page administrator. That identity is supposed to stay private, so the fact that it came back to a stranger was the bug.

The report was sent to Facebook Security in October 2018, Facebook confirmed a patch on October 15, 2018, and a bounty of $2000 was paid.

The two roles in the story

The report sets up a simple scene with two people:

  1. The victim. This person is the administrator of a page the report calls page_a. They do the ordinary thing: they create an appointment on their own page. This is the normal use of the feature, and it is also the precondition for the attack, because there has to be an appointment to leak.
  2. The attacker. This person is just another logged-in Facebook user. They send a crafted request to Facebook's data endpoint.

The only tool shown in the report is a raw HTTP request. An HTTP request is the message your browser sends to a website when it asks for a page or an action; normally the browser builds it for you, but here it is written out by hand so you can see exactly what is being asked.

The concepts you need first

Before walking through the request, here are the ideas it relies on, explained from zero.

API. An API is a way for one piece of software to talk to another. Think of a restaurant: the menu and the waiter are the API. You do not walk into the kitchen and cook; you ask the waiter for a dish by name, and food comes back. On the web, an API is a set of addresses (endpoints) where a program can ask a server for data or ask it to do something, and the server answers with data.

GraphQL. GraphQL is a style of API where the client describes exactly which pieces of data it wants, in a structured query, and the server returns those pieces. Instead of many fixed addresses, there is often one address that accepts queries. Facebook uses GraphQL heavily for its own apps.

GraphQL batch endpoint. A batch endpoint accepts several queries in one request, packed together and each given a name. It saves round trips: one message carries many questions. The endpoint in this report is /api/graphqlbatch/.

Persisted query and doc_id. Facebook's apps do not send the full text of every GraphQL query, because that would be large and easy to tamper with. Instead, a query is stored on Facebook's side and given an identifier, and the app sends only that identifier. The identifier is called doc_id. Think of it as a dish number on a menu: you say "number 42" and the kitchen knows which dish that is.

Token (here, fb_dtsg). A token is a short value that proves who you are or that a request is legitimate. When you log in to a website, the site gives your browser a token, and the browser sends it back with every request so the server knows the request comes from your session. fb_dtsg is the token Facebook attaches to requests made by a logged-in user. It is also an anti-CSRF token, explained below.

CSRF (cross-site request forgery). Imagine someone forges your signature on a letter. CSRF is the web version: a malicious site tries to make your browser send a request to another site, using your logged-in session, without you intending it. Anti-CSRF tokens stop this, because the malicious site does not know the secret token your browser holds. It is worth being clear: this protection was working here. It stops other sites from acting as you. It does not stop you from asking for data you should not be allowed to see, which is the problem in this report.

Authorisation. Authentication is proving who you are (logging in). Authorisation is what you are allowed to do once you are known. A hotel key card proves you are a guest; authorisation decides which room doors it opens. This bug is an authorisation failure: the request was properly authenticated, but the server did not check whether this user was allowed to see this page's appointments.

Enumeration. Enumeration means walking through a list of identifiers one by one to collect data: page 1, page 2, page 3, and so on. If each request returns something useful, an attacker can harvest data at scale.

HTTP request anatomy. An HTTP request has a method and a path (what you want to do and where), headers (extra information such as who you are and what format you are sending), and a body (the data itself). POST means "I am sending data", as opposed to GET, which means "give me a page".

Finding it

The researcher found that the GraphQL endpoint accepted a query asking for the appointments of a page, identified by a parameter called pageID, over a date range. The query was sent through the batch endpoint, which lets a client submit several named queries in one request. The response contained details of all appointments, including the user who created them, which is the page admin. That identity should stay private, so the fact that it came back to someone who was not the page admin is what made the behaviour wrong.

Exploitation, step by step

Step 1: The victim creates an appointment

The administrator of page_a creates an appointment on their page. Nothing unusual happens here: this is the feature working as designed. It matters only because the attack needs an appointment to exist before it can leak one.

Step 2: The attacker sends a crafted GraphQL batch request

The attacker sends the following request to the GraphQL endpoint:

HTTP
POST /api/graphqlbatch/?dpr=1 HTTP/1.1Host: www.facebook.comUser-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:62.0) Gecko/20100101 Firefox/62.0Accept: */*Content-Type: application/x-www-form-urlencodedConnection: close__user=&__a=1&__dyn=&__req=a&__be=1&__pc=&__rev=&fb_dtsg=AQHJVmZ8roIv%3AAQFBvwa5EaqB&queries={  "o0":{    "doc_id":"1735616686561494",    "query_params":{      "pageID":"ID_PAGE_A",      "startDate":1,      "endDate":9999999999999999    }  }}

Line by line, in plain words:

  • POST /api/graphqlbatch/?dpr=1 HTTP/1.1 is the first line of the request. POST says data is being sent. /api/graphqlbatch/ is the batch GraphQL endpoint, the address that accepts several named queries at once. HTTP/1.1 is the version of the protocol being spoken.
  • Host: www.facebook.com tells the server which site the request is for. The request goes to the main Facebook host.
  • User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:62.0) Gecko/20100101 Firefox/62.0 is the header where a browser announces what it is. Here it describes Firefox on Ubuntu. Servers often use this to decide how to respond.
  • Accept: */* says the client will accept any kind of response.
  • Content-Type: application/x-www-form-urlencoded says how the body is formatted. Form-encoded means the data is written as name=value pairs joined by &, the same format a web form produces when you press submit. This is how the batch endpoint receives its parameters.
  • Connection: close asks the server to close the connection after the response, rather than keeping it open for reuse.
  • __user=&__a=1&__dyn=&__req=a&__be=1&__pc=&__rev=&fb_dtsg=AQHJVmZ8roIv%3AAQFBvwa5EaqB&queries={...} is the body. It is a chain of name=value pairs separated by &. __a=1 and __be=1 are examples of those defaults.
  • fb_dtsg=AQHJVmZ8roIv%3AAQFBvwa5EaqB is the anti-CSRF token. Because it is present, the request is treated as coming from the attacker's logged-in session. The %3A inside it is just an encoded colon, the way special characters are written inside a URL-style body.
  • queries={...} is the payload: a JSON object of named queries. JSON is a text format for structured data, built from names and values in curly braces. Here the object holds one query, named o0.
  • Inside o0, doc_id: "1735616686561494" is the identifier of the stored GraphQL document that resolves appointments for a page. This is the "dish number" from the menu: the server looks up the stored query by this number.
  • query_params holds the values passed to that stored query. pageID: "ID_PAGE_A" names the target page, the victim's page. startDate: 1 and endDate: 9999999999999999 set the date range. The start is a very small number and the end is an enormous one, so the range is wide enough to cover every appointment that could ever exist. The attacker is deliberately asking for everything, not a sensible window.

Why each step was taken: the attacker needs a request that the server will accept as coming from a real logged-in user (hence the token), that names the query the server already knows (hence the doc_id), and that points it at someone else's page (hence pageID). The wide date range removes any doubt that an appointment might fall outside the window and be missed.

Step 3: The response

The API response contained details of all appointments, including the user who created them, that is, the page admin. The report does not reproduce the response body; it only states what it contained.

Why it worked

The stored query identified by doc_id 1735616686561494 returned appointment records, including the creating user, to a caller who was not the page admin. The report does not describe the server-side code, so the exact check that was missing is not stated; the behaviour is consistent with an authorisation check that was absent or applied to the wrong object.

That protection stops cross-site request forgery, not a logged-in user asking for data they should not see, so it did not prevent this.

Impact

An attacker could enumerate the appointments of any Facebook Page. Because each appointment record included the user who created it, the attack leaked the identity of page administrators, which should remain private.

Fix

Facebook confirmed the issue was patched on October 15, 2018. The report does not describe the change that was made.

Timeline

Date Event
October 12, 2018 Vulnerability reported to Facebook Security.
October 15, 2018 Facebook confirmed the issue was patched.
October 17, 2018 Issue resolved and a bounty of $2000 was awarded.

Variants to test

If you are learning from this report, these are the same ideas applied in slightly different places. Each one is a way of asking the same question: does the server check that this user may see this object?

  1. Other persisted GraphQL documents. Take any doc_id used by the Pages product and replay it through /api/graphqlbatch/ with a pageID you do not administer. A positive result is a response containing records for that page.
  2. Other object identifiers in query_params. Swap pageID for other identifiers the document accepts, such as appointment IDs or user IDs, and see whether the response still returns data belonging to another account. A positive result is data for an object you do not own.
  3. Widening the date range. Set startDate and endDate to cover all time, as in the report, on any endpoint that filters by date. A positive result is records outside the range a normal client would request.
  4. Batch endpoint with several queries. Submit multiple named queries in one queries object, mixing one you are allowed to run with one you are not. A positive result is that the unauthorised query returns data alongside the authorised one, which can also reveal whether per-query authorisation is applied.

Glossary

  • API: a way for one program to ask another for data or actions, like a menu and waiter in a restaurant.
  • Appointment (Facebook Pages): a bookable time slot a page admin can create on their page.
  • Attacker: in this report, any logged-in Facebook user who is not an administrator of the target page.
  • Authentication: proving who you are, usually by logging in.
  • Authorisation: what you are allowed to do once you are known; the check this bug was missing.
  • Batch endpoint: an API address that accepts several named queries in one request.
  • Bounty: a reward paid by a company for a responsibly reported security bug.
  • CSRF (cross-site request forgery): tricking a logged-in user's browser into sending a request to another site without their intent.
  • doc_id: the identifier of a GraphQL query stored on the server, sent instead of the full query text.
  • Endpoint: a specific address on a server where a program can send a request.
  • Enumeration: walking through identifiers one by one to collect data at scale.
  • fb_dtsg: Facebook's anti-CSRF token attached to requests from a logged-in user.
  • GraphQL: an API style where the client describes exactly which data it wants and the server returns those fields.
  • Header: extra information attached to an HTTP request, such as the host or the content type.
  • HTTP: the protocol browsers and servers use to exchange requests and responses.
  • JSON: a text format for structured data, built from names and values.
  • Page (Facebook): a public presence for a person or organisation, run by administrators.
  • Page admin: a private individual who manages a Facebook Page.
  • Parameter: a named value sent with a request, such as pageID or startDate.
  • Payload: the part of a request that carries the data being sent.
  • Persisted query: a GraphQL query stored on the server and referenced by an identifier.
  • POST: an HTTP method meaning data is being sent to the server.
  • Query: a structured request for data, in GraphQL a set of fields to return.
  • Session: the state of being logged in, represented by a token the browser sends with each request.
  • Token: a short value that proves identity or legitimacy, sent with requests.
  • User-Agent: a header in which a browser announces what it is.
  • Victim: in this report, the administrator of page_a whose appointment details were exposed.

More from Meta

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Insecure direct object reference (IDOR)

The lesson behind this report.

One user can read or change another user's data, usually by changing an identifier the server trusts without checking who is asking. One of the most paid bug classes on web programs.