Skip to content
Info disclosure Write-up Intermediate

DOB disclosed using “Facebook Graph API Reverse Engineering”

Facebook's Graph Timeline API returned different response sizes depending on whether a queried year was before or after the user's birth year, allowing an attacker to infer a hidden birth year. The author used a binary search script to find the year in a few iterations.

Raja Sekar Durairaj Follow

Published on medium.com

Facebook

Raja Sekar Durairaj, 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. 6 min read.

Context

Facebook's Graph Timeline API is the endpoint the Facebook Android application uses to fetch a user's timeline posts. The researcher describes it as a Graph API call that returns a user's timeline year posts, driven by a query_params attribute in the request body. The feature normally returns the posts a user made within a given time window.

The report is the third in a series on Facebook date-of-birth disclosure. The first part covered birth year disclosure via a timeline profile source code data attribute, and the second covered an IDOR on m.facebook.com. This third report is about reverse engineering the Graph Timeline API request pattern to recover a hidden birth year, and it ends with a $5500 bounty.

Setup

The researcher monitored the Facebook timeline API by logging the request and response of the Facebook Android application on his own system. The tool visible in the screenshots is Fiddler, used to inspect the captured request and response bodies. A Node.js script, referred to as graphFBBirth.js, is used to replay the request with modified parameters. No application version, API version or account details beyond the researcher's own profile (www.fb.me/rajsek) and a test user's profile are given.

Finding it

While reviewing the captured traffic, the researcher noticed that the Graph Timeline API follows a pattern to fetch a user's posts. The request carries a query_params attribute, and the value of that attribute determines which timeline year posts come back. If the pattern could be reproduced and varied, the same request could be used to disclose the date of birth of any Facebook user.

The captured request body is shown below, with the Base64-encoded query_params value highlighted.

Fiddler Inspectors view of the Graph Timeline API request body, with the Base64-encoded query_params value highlighted
Graph Timeline API request body attributes From the original on medium.com

The corresponding response body from the same call is shown next.

Raw JSON response from the Graph Timeline API containing a Born on March 4 timeline life event
Graph Timeline post response body attributes From the original on medium.com

Exploitation

Step 1: Isolate the parameter that controls the result

The researcher established that the query_params attribute in the Graph Timeline API request determines which timeline year posts are returned for the user.

Highlighted Base64-encoded string inside the query_params request value
Graph Timeline API request query_params body attributes From the original on medium.com

Step 2: Decode query_params

The highlighted string inside query_params is Base64-encoded. Decoding it reveals the structure of the query: the victim's Facebook user ID 100000550580350, followed by two numbers, 1167638400 and 1199174399.

TextWizard decoding the Base64 string into the timeline section pattern with from and to timestamps
Decoding above Base64 String From the original on medium.com

Appending 000 to each of those two numbers gives 1167638400000 and 119917439900, which represent the number of milliseconds since 1 January 1970, 00:00:00. In other words, the decoded value is the victim's user ID plus a start and end timestamp delimiting the timeline window.

JavaScript Date conversions showing the two timestamps resolve to Jan 1 2007 and Jan 1 2008
javascript snippets: To get date from numbers From the original on medium.com

The screenshot shows the JavaScript date conversions that turn those two millisecond values into calendar dates.

Step 3: Loop over years with a Node.js script

The researcher wrote a Node.js script that logs the API response while changing the year values inside query_params. The script builds the Base64-encoded timeline pattern and posts it to the Graph API.

JavaScript callStart function looping the year from 2007 down to 1900 and calling download for each year
JavaScript callStart function looping the year from 2007 down to 1900 and calling download for each year From the original on medium.com
Node.js download function that Base64-encodes the timeline pattern and posts it to the Facebook Graph API
Node.js download function that Base64-encodes the timeline pattern and posts it to the Facebook Graph API

Step 4: Read the length signal

Running the script produced a log of responses per year. At a specific year, 1990, the response content length dropped to 246 bytes. That year is one before the victim's birth year of 1991 (1991-1). The change in response size therefore gives a clue to the victim's birth year.

Command prompt output of the script printing Yes with response length for each year from 2007 down, with 1990 returning No
Customised Node script result From the original on medium.com

Step 5: Replace the linear loop with a binary search

Instead of iterating over every year, the researcher applied a binary search algorithm to the graphFBBirth.js script. The modified script can guess the birth year of any user in fewer than 7 to 8 iterations.

Step 6: Turn it into a web application

The script was fine-tuned to fetch the victim's date of birth and hosted as a web app on Heroku at https://rajsek-fb-birthyear.herokuapp.com/DOB. The researcher notes that Facebook had already patched the bug by the time of writing, so the application no longer works as expected.

Step 7: Demonstrate against a test user

The test user's profile does not show the date of birth: the About page displays a birthday field hidden behind an "Ask for Siva's birthday" prompt.

Facebook About page of test user Siva Siva showing the Birthday field hidden behind Ask for Siva’s birthday
See DOB information is not visible in this profile From the original on medium.com

Using the graphFBBirth.js script, the researcher was still able to obtain the date of birth of that user. The web application returned 8-5-1991 for the supplied Facebook user ID.

Hack FB user Birth Year web app on Heroku returning the date 8–5–1991 for a given Facebook user ID
Screenshot of FB DOB disclosure Web Application From the original on medium.com

Step 8: Disclosure to Facebook

The report was sent to the Facebook Security Team. Their replies acknowledge the report, forward it to the product team, and later state that a fix is being tested on graph.beta.facebook.com with a request to confirm. On 23 May 2015 Facebook awarded a $5500 bounty for the report.

Facebook Security email from Neal acknowledging the report and forwarding it to the product team
Facebook Security email from Neal acknowledging the report and forwarding it to the product team From the original on medium.com
Facebook Security email from Neal saying a fix is being tested on graph.beta.facebook.com and asking to confirm
Facebook Security email from Neal saying a fix is being tested on graph.beta.facebook.com and asking to confirm
Facebook message dated May 23, 2015 awarding a 5500 USD bounty for the report
Facebook message dated May 23, 2015 awarding a 5500 USD bounty for the report

The researcher also notes that this third report placed him in the top 10 of the Facebook whitehat thanks page.

Facebook Whitehat Thanks page for 2015 listing Raja Sekar Durairaj among responsible disclosure researchers
Sry above one is a year old Screenshot :( From the original on medium.com

Root cause

The timeline query is built client-side as a Base64-encoded string containing the target user ID and a start and end timestamp in milliseconds. The server accepts that encoded value and returns timeline data for the user ID it contains. The report does not describe the server-side code. Because the birth year affects whether posts exist in a given window, the response length changes at the boundary year, which leaks the value even though the date of birth itself is hidden on the profile.

The report does not describe the server-side code, so the exact validation that was missing is not stated. The response size is an observable side channel for the hidden field.

Impact

An attacker who can send the Graph Timeline API request can disclose the date of birth of any Facebook user, including users who have hidden their birthday from their profile. The researcher demonstrated this against a test user whose birthday was not visible. The attack requires the ability to reproduce the request pattern and to observe the response. The modified script can guess the birth year in fewer than 7 to 8 iterations.

Fix

The researcher notes that the bug was patched. The researcher notes that the bug was patched and that the Heroku application no longer works as expected, and the security team's email states that a fix was being tested on graph.beta.facebook.com. A reasonable fix, consistent with the finding, is to stop trusting the client-supplied encoded user ID and time range, authorise the request against the authenticated viewer, and avoid returning responses whose size varies with a hidden field.

Variants to test

  1. Other Base64-encoded query parameters. Look for request bodies where a parameter decodes to an identifier plus timestamps or other structured values. A positive result is a decoded value that contains a user ID or object ID you can change while the server still returns data.
  2. Response-length side channels. Where a hidden field controls whether records exist in a range, vary the range and watch the response size. A positive result is a sharp, repeatable change in length at a boundary that corresponds to the hidden value.
  3. Binary search over numeric ranges. Any endpoint that answers yes or no for a range of years, dates or IDs can be queried in logarithmic time. A positive result is convergence on a single value in a small number of requests.
  4. Mobile API replay. Capture requests from a mobile application and replay them with modified parameters. A positive result is a response that differs from the application's normal behaviour for the same account.
  5. Hidden profile fields. Compare what the web profile shows with what an API returns for the same user. A positive result is a field that is hidden in the UI but present or inferable from an API response.

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 lets you hide your birthday on your profile. If you do that, other people see a prompt asking the birthday owner to share it, not the date itself. The researcher in this report found a way to work out that hidden date anyway, for any Facebook user, by watching how the Facebook Android app talks to Facebook's servers and then changing one value in that conversation.

The trick did not read the birthday directly. It used a side effect: when the app asks Facebook for a user's timeline posts for a particular year, the answer is shorter once the requested year is before the user's birth year. By asking about different years and watching the size of the reply, the researcher could narrow down the birth year. He then automated this with a small program and later a web page, and Facebook fixed the problem and paid him a $5500 bounty.

This was the third report in a series about the same kind of hidden birthday problem. The first two parts covered other ways the birth year leaked; this part is about the Facebook Graph Timeline API.

Background: what an API is, and what was being watched

When you use an app on your phone, the app does not contain all of Facebook's data. It asks Facebook's computers for it. The way one program asks another program for data is called an API (Application Programming Interface). Think of it like a waiter in a restaurant: you (the app) tell the waiter what you want, the waiter goes to the kitchen (Facebook's servers), and brings back a plate (the data). You never walk into the kitchen yourself.

Each request the app sends has a few parts:

  • a request: the message the app sends, saying what it wants.
  • a response: the message the server sends back, containing the data or an error.
  • a request body: the part of the request that carries the details, like which user and which time range you are asking about.
  • a parameter: a named value inside that body, for example query_params.

The Graph Timeline API is the specific API the Facebook Android app uses to fetch a user's timeline posts, meaning the things a person has posted on their profile over time. The report says this API returns a user's timeline year posts, driven by a query_params attribute in the request body.

To study this, the researcher captured the traffic between the Facebook Android app and Facebook's servers on his own computer. The tool visible in the screenshots is Fiddler, a program that sits between an app and the internet and records the requests and responses so you can read them. This is often called inspecting or logging traffic. No app version, API version or account details beyond the researcher's own profile (www.fb.me/rajsek) and a test user's profile are given.

Finding the pattern

While reading the captured traffic, the researcher noticed that the Graph Timeline API follows a pattern to fetch a user's posts. The request carries a query_params attribute, and the value of that attribute decides which timeline year posts come back. If that pattern could be reproduced and varied, the same request could be used to disclose the date of birth of any Facebook user.

The captured request body is shown below, with the Base64-encoded query_params value highlighted. Base64 is a way of writing data using only letters, digits and a couple of symbols, so it can travel safely inside text.

Fiddler Inspectors view of the Graph Timeline API request body, with the Base64-encoded query_params value highlighted
Graph Timeline API request body attributes From the original on medium.com

The corresponding response body from the same call is shown next. A response body is simply the content the server sends back.

Raw JSON response from the Graph Timeline API containing a Born on March 4 timeline life event
Graph Timeline post response body attributes From the original on medium.com

Step by step

Step 1: Find the parameter that controls the result

The researcher established that the query_params attribute in the Graph Timeline API request determines which timeline year posts are returned for the user. In other words, this one value is the dial that selects the time window.

Highlighted Base64-encoded string inside the query_params request value
Graph Timeline API request query_params body attributes From the original on medium.com

Step 2: Decode query_params

The highlighted string inside query_params is Base64-encoded. Decoding it reveals the structure of the query: the victim's Facebook user ID 100000550580350, followed by two numbers, 1167638400 and 1199174399.

TextWizard decoding the Base64 string into the timeline section pattern with from and to timestamps
Decoding above Base64 String From the original on medium.com

Appending 000 to each of those two numbers gives 1167638400000 and 119917439900, which represent the number of milliseconds since 1 January 1970, 00:00:00. A timestamp like this is just a number that stands for a moment in time; computers count milliseconds from a fixed starting point in 1970, which is a common convention. So the decoded value is the victim's user ID plus a start and end timestamp that mark the timeline window.

JavaScript Date conversions showing the two timestamps resolve to Jan 1 2007 and Jan 1 2008
javascript snippets: To get date from numbers From the original on medium.com

The screenshot shows the JavaScript date conversions that turn those two millisecond values into calendar dates. JavaScript is the programming language that runs inside web pages and also in Node.js, a program that runs JavaScript outside the browser.

Step 3: Loop over years with a Node.js script

The researcher wrote a Node.js script, called graphFBBirth.js, that logs the API response while changing the year values inside query_params. The script builds the Base64-encoded timeline pattern and posts it to the Graph API. A script is a small program that automates a repetitive task, here sending the same request many times with one value changed.

JavaScript callStart function looping the year from 2007 down to 1900 and calling download for each year
JavaScript callStart function looping the year from 2007 down to 1900 and calling download for each year From the original on medium.com
Node.js download function that Base64-encodes the timeline pattern and posts it to the Facebook Graph API
Node.js download function that Base64-encodes the timeline pattern and posts it to the Facebook Graph API

Step 4: Read the length signal

Running the script produced a log of responses per year. At a specific year, 1990, the response content length dropped to 246 bytes. A byte is a unit of data size; a shorter response means less data came back. That year is one before the victim's birth year of 1991 (1991-1). The change in response size therefore gives a clue to the victim's birth year.

This is called a side channel: the birthday itself is not in the reply, but something else about the reply (its size) changes depending on the birthday. It is like guessing a locked room's contents by listening to how long the door takes to open.

Command prompt output of the script printing Yes with response length for each year from 2007 down, with 1990 returning No
Customised Node script result From the original on medium.com

Step 5: Replace the linear loop with a binary search

Instead of trying every year one by one, the researcher applied a binary search algorithm to the graphFBBirth.js script. Binary search is the technique of halving the possibilities each time: ask whether the answer is above or below the middle, then repeat on the remaining half. It is how you would find a word in a printed dictionary by opening it in the middle rather than reading from page one. The modified script can guess the birth year of any user in fewer than 7 to 8 iterations, meaning 7 to 8 requests.

Step 6: Turn it into a web application

The script was fine-tuned to fetch the victim's date of birth and hosted as a web app on Heroku, a service that runs web applications online, at https://rajsek-fb-birthyear.herokuapp.com/DOB. The researcher notes that Facebook had already patched the bug by the time of writing, so the application no longer works as expected.

Step 7: Demonstrate against a test user

The test user's profile does not show the date of birth: the About page displays a birthday field hidden behind an "Ask for Siva's birthday" prompt. The About page is the part of a Facebook profile where personal details are listed.

Facebook About page of test user Siva Siva showing the Birthday field hidden behind Ask for Siva’s birthday
See DOB information is not visible in this profile From the original on medium.com

Using the graphFBBirth.js script, the researcher was still able to obtain the date of birth of that user. The web application returned 8-5-1991 for the supplied Facebook user ID.

Hack FB user Birth Year web app on Heroku returning the date 8–5–1991 for a given Facebook user ID
Screenshot of FB DOB disclosure Web Application From the original on medium.com

Step 8: Disclosure to Facebook

The report was sent to the Facebook Security Team. Their replies acknowledge the report, forward it to the product team, and later state that a fix is being tested on graph.beta.facebook.com with a request to confirm. On 23 May 2015 Facebook awarded a $5500 bounty for the report. A bug bounty is a programme where a company pays people for reporting security problems responsibly instead of exploiting them.

Facebook Security email from Neal acknowledging the report and forwarding it to the product team
Facebook Security email from Neal acknowledging the report and forwarding it to the product team From the original on medium.com
Facebook Security email from Neal saying a fix is being tested on graph.beta.facebook.com and asking to confirm
Facebook Security email from Neal saying a fix is being tested on graph.beta.facebook.com and asking to confirm
Facebook message dated May 23, 2015 awarding a 5500 USD bounty for the report
Facebook message dated May 23, 2015 awarding a 5500 USD bounty for the report

The researcher also notes that this third report placed him in the top 10 of the Facebook whitehat thanks page, a public page listing researchers who reported issues.

Facebook Whitehat Thanks page for 2015 listing Raja Sekar Durairaj among responsible disclosure researchers
Sry above one is a year old Screenshot :( From the original on medium.com

Why it worked

The timeline query is built on the client side, meaning inside the app, as a Base64-encoded string containing the target user ID and a start and end timestamp in milliseconds. The server accepts that encoded value and returns timeline data for the user ID it contains. The report does not describe the server-side code. "Authenticated user" means the person actually logged in and making the request.

Because the birth year affects whether posts exist in a given window, the response length changes at the boundary year, which leaks the value even though the date of birth itself is hidden on the profile. The report does not describe the server-side code, so the exact validation that was missing is not stated. The response size is an observable side channel for the hidden field.

This class of problem is often called an IDOR (Insecure Direct Object Reference): the server takes an identifier supplied by the client, such as a user ID, and hands back the object it names without checking that the client is allowed to see it. It is like a hotel where the room number on your key card is trusted without checking that the room is yours.

Impact

An attacker who can send the Graph Timeline API request can disclose the date of birth of any Facebook user, including users who have hidden their birthday from their profile. The researcher demonstrated this against a test user whose birthday was not visible. The attack requires the ability to reproduce the request pattern and to observe the response. The modified script can guess the birth year in fewer than 7 to 8 iterations.

Fix

The researcher notes that the bug was patched. The researcher notes that the bug was patched and that the Heroku application no longer works as expected, and the security team's email states that a fix was being tested on graph.beta.facebook.com. A reasonable fix, consistent with the finding, is to stop trusting the client-supplied encoded user ID and time range, authorise the request against the authenticated viewer, and avoid returning responses whose size varies with a hidden field.

Variants to test

  1. Other Base64-encoded query parameters. Look for request bodies where a parameter decodes to an identifier plus timestamps or other structured values. A positive result is a decoded value that contains a user ID or object ID you can change while the server still returns data.
  2. Response-length side channels. Where a hidden field controls whether records exist in a range, vary the range and watch the response size. A positive result is a sharp, repeatable change in length at a boundary that corresponds to the hidden value.
  3. Binary search over numeric ranges. Any endpoint that answers yes or no for a range of years, dates or IDs can be queried in logarithmic time. A positive result is convergence on a single value in a small number of requests.
  4. Mobile API replay. Capture requests from a mobile application and replay them with modified parameters. A positive result is a response that differs from the application's normal behaviour for the same account.
  5. Hidden profile fields. Compare what the web profile shows with what an API returns for the same user. A positive result is a field that is hidden in the UI but present or inferable from an API response.

Glossary

  • API: a way for one program to ask another program for data or actions, like a waiter carrying orders between you and the kitchen.
  • Request: the message an app sends to a server asking for something.
  • Response: the message a server sends back with the data or an error.
  • Request body: the part of a request that carries the details, such as which user and which time range.
  • Parameter: a named value inside a request, for example query_params.
  • Graph Timeline API: the Facebook API the Android app uses to fetch a user's timeline posts.
  • Timeline: the collection of posts a person has made on their profile over time.
  • Fiddler: a tool that records requests and responses between an app and the internet so you can inspect them.
  • Base64: an encoding that turns data into letters, digits and a few symbols so it can travel as text; it is reversible, not encryption.
  • Decode: to turn encoded data back into its original form.
  • User ID: the number that identifies a particular Facebook account.
  • Timestamp: a number representing a moment in time; here, milliseconds since 1 January 1970, 00:00:00.
  • Millisecond: one thousandth of a second.
  • JavaScript: the programming language that runs in web pages and in Node.js.
  • Node.js: a program that runs JavaScript outside a browser, often used for scripts.
  • Script: a small program that automates a repetitive task.
  • Byte: a unit of data size.
  • Side channel: information leaked indirectly, for example by the size or timing of a response, rather than by the data itself.
  • Binary search: a technique that halves the possibilities each step, like finding a word in a dictionary by opening it in the middle.
  • Iteration: one pass through a repeated step, here one request.
  • Heroku: a service that hosts web applications online.
  • Bug bounty: a programme where a company pays people for responsibly reporting security problems.
  • Authenticated user: the person actually logged in and making the request.
  • IDOR (Insecure Direct Object Reference): when a server takes an identifier supplied by the client and returns the object it names without checking the client is allowed to see it.
  • Client side: code or data handled inside the app or browser, rather than on the server.
  • Server: the computer that stores data and answers requests.
  • Patch: a fix applied to software.

More by Raja Sekar Durairaj

View all

1 more disclosed report, best first.

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.