Skip to content
CSRF Write-up Intermediate

Facebook CSRF full account takeover

A GET request used to add an email address to a Facebook account lacked any checks, allowing an attacker to add their own email to a victim's account by tricking the victim into making the request. The attacker could then use the password reset feature to take over the victim's account.

Josip Franjkovic Follow

Published on josipfranjkovic.com

Bounty$8,450 View original

Some cross site request forgeries are mere annoyance (like logout CSRF), some can be useful (example: changing name of user), and some - like the one I found - can be pretty devastating.

Josip Franjković, on josipfranjkovic.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 contact importer let a user link an external address book, such as an Outlook.com (Hotmail) contact book, to their Facebook account. Approving Facebook's access to that contact book caused the email address to be added to the user's Facebook account. The researcher found that the request performing this addition could be replayed against other users, turning a convenience feature into a full account takeover primitive.

The author notes that cross site request forgeries vary in severity: some are a mere annoyance (logout CSRF), some can be useful (changing the name of a user), and some, like this one, can be pretty devastating. The finding has similarities to Dan Melamed's earlier work, referenced through an archive.org link.

Setup

To exploit this, you need:

  • a Facebook account (the attacker's),
  • an Outlook.com (Hotmail) email address that is not bound to that Facebook account,
  • a victim with a Facebook account.

The Outlook email must not be bound to the attacker's Facebook account.

Finding it

The researcher used the "Find contacts on Facebook" flow from the attacker account and logged all requests. Among them was a GET request to the contact importer login endpoint:

HTTP
https://m.facebook.com/contact-importer/login/?api_instance=1&api_ver=wave5&auth_token=TOKEN

This request is what adds the email to the account when Facebook is approved to access Outlook's contact book. The important observation is that the request has no checks: it can be repeated as many times as you want. The problem, as the author puts it, is that it works for OTHER users too. Nothing in the request ties the email addition to the account that originally authorised the Outlook import.

Exploitation

The course of action to take over the victim's account is described as follows.

Step 1: Capture the importer request

Use "Find contacts on Facebook" from the attacker account and log all requests.

Step 2: Identify the endpoint

Find the /contact-importer/login request in the captured traffic. It is the GET request shown above, carrying api_instance, api_ver and auth_token parameters.

Step 3: Remove the email from the attacker account

Remove the added email from your (attacker) account.

Step 4: Make the victim issue the request

Get the victim to somehow make the /contact-importer/login request. The author notes there are infinite possibilities here; the report does not describe a specific delivery method.

Step 5: The email is added silently

Once the victim's browser issues the request, the email is now added to the victim's account, silently.

Step 6: Reset the password

Use "Forgot your password" to take over the account.

A video demonstrating the vulnerability is linked from the report.

Or watch on YouTube
From the original on josipfranjkovic.com

Root cause

The contact importer login endpoint performs the email addition without any checks and can be replayed indefinitely. The request is a GET and has no checks, so it can be repeated as many times as you want and works for other users too. The observable behaviour is that the request has no checks and works for other users. The report does not describe the server side validation in more detail; the observable behaviour is that the request has no checks and works for other users.

Impact

An attacker who can get a victim to issue the request can attach an email address they control to the victim's Facebook account and then use the "Forgot your password" flow to take over the account. The email is added to the victim's account silently. The attack requires the attacker to hold a Facebook account and an Outlook.com email not bound to it, and requires the victim to make the request; how that is achieved is left open in the report.

Fix

Facebook fixed the bug. The timeline in the report is:

Time Event
August 13, 2013, 07:00 Bug reported
August 13, 2013, 19:40 Better PoC and video sent to Facebook team
August 14, 2013, 01:00 Facebook team replies
August 14, 2013, 03:00 Bug is fixed

The author thanks Facebook's security team for running their bug bounty program and for the quick patch, noting it took them only 2 hours to roll out a working patch.

Variants to test

  • Replay a captured contact importer or account linking request from a second account. A positive result is the linked email or identity appearing on the second account without any confirmation.
  • Look for GET requests that perform state changes in account recovery or identity linking flows, and check whether their tokens are bound to the issuing account. A positive result is the same token working across accounts.
  • Test whether an email added through an importer can be used in the password reset flow without further verification. A positive result is a reset link or code arriving at the attacker controlled address for the victim's account.
  • Check other third party contact book integrations for the same pattern: authorise once, capture the request, then replay it in another session. A positive result is the external address being attached to the other account silently.

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

What happened, in plain words

Facebook has a feature that lets you connect an outside address book, such as your Outlook.com (Hotmail) contacts, to your Facebook account. When you approve Facebook's access to that contact book, the email address is added to your Facebook account. That is meant to be a convenience: one click and your email is on file.

The researcher found that the request which performs this addition could be replayed against other people. In other words, a request that was meant to add an email to your own account could be made to add that email to somebody else's account instead. Because the email being added belongs to the attacker, the attacker can then use the "Forgot your password" flow to take over the victim's account.

To understand why this matters, it helps to know what a few everyday web concepts mean.

  • A request is a message your browser sends to a website's server, asking it to do something or to give you a page. When you click a link or submit a form, your browser sends a request.
  • A GET request is a particular kind of request, the kind normally used just to fetch a page. Its details are visible in the address bar, and it can be triggered simply by loading a URL, for example by an image tag or a link on another site.
  • A token is a short piece of text that a server hands out to identify a session or an action. Think of it like a cloakroom ticket: whoever holds the ticket can collect the coat. If a ticket is not tied to a particular person, anyone holding it can use it.
  • Cross site request forgery (CSRF) is a class of bug where an attacker makes a victim's browser send a request to a site the victim is logged into, without the victim meaning to. The site sees a request coming from the victim's browser and treats it as the victim's own action.

CSRF bugs come in different sizes. The author points out that some are a mere annoyance, such as a logout CSRF that just logs you out. Some can be useful to an attacker, such as changing the name of a user. And some, like this one, can be pretty devastating. The finding has similarities to earlier work by Dan Melamed, which the report links to through an archive.org copy.

Setting up

To exploit this, you need three things:

  1. A Facebook account, which is the attacker's account.
  2. An Outlook.com (Hotmail) email address that is not already bound to that Facebook account.
  3. A victim who has a Facebook account.

The Outlook email must not be bound to the attacker's Facebook account.

Finding the request

The researcher used the "Find contacts on Facebook" flow from the attacker account and logged all the requests the browser made during it. Logging requests means recording every message the browser sends, which you can do with the developer tools built into every browser.

Among those requests was a GET request to the contact importer login endpoint:

HTTP
https://m.facebook.com/contact-importer/login/?api_instance=1&api_ver=wave5&auth_token=TOKEN

Line by line, in plain words:

  • https://m.facebook.com is the address of Facebook's mobile site, the version of Facebook designed for phones.
  • /contact-importer/login/ is the path that identifies the contact importer login feature on that site.
  • The ? marks the start of the parameters, the extra pieces of information sent along with the request.
  • api_instance=1 is one parameter. An API (application programming interface) is a way for one piece of software to talk to another; here it is Facebook's own internal interface that the page uses behind the scenes. This parameter tells the server which instance of that interface is being used.
  • api_ver=wave5 is another parameter, naming the version of the interface.
  • auth_token=TOKEN is the token parameter. In the real request, TOKEN is replaced by the actual token value, which is a secret and is redacted here.

This request is what adds the email to the account when Facebook is approved to access Outlook's contact book. The important observation is that the request has no checks: it can be repeated as many times as you want. The problem, as the author puts it, is that it works for OTHER users too. Nothing in the request ties the email addition to the account that originally authorised the Outlook import.

Taking over the account

The course of action to take over the victim's account is described as follows.

Step 1: Capture the importer request

Use "Find contacts on Facebook" from the attacker account and log all requests. The reason for this step is to see exactly what the browser sends when the email is legitimately added to the attacker's own account, so that the same request can be reused later.

Step 2: Identify the endpoint

Find the /contact-importer/login request in the captured traffic. It is the GET request shown above, carrying the api_instance, api_ver and auth_token parameters. The reason for this step is to isolate the one request that performs the email addition, out of all the requests the page made.

Step 3: Remove the email from the attacker account

Remove the added email from your (attacker) account.

Step 4: Make the victim issue the request

Get the victim to somehow make the /contact-importer/login request. The author notes there are infinite possibilities here; the report does not describe a specific delivery method. The reason for this step is that the request has to come from the victim's browser, so that the server applies the change to the victim's account rather than the attacker's.

Step 5: The email is added silently

Once the victim's browser issues the request, the email is now added to the victim's account, silently. The reason this matters is that the victim gets no prompt or confirmation, so there is nothing to notice or cancel.

Step 6: Reset the password

Use "Forgot your password" to take over the account.

A video demonstrating the vulnerability is linked from the report.

Or watch on YouTube
From the original on josipfranjkovic.com

Why it worked

The contact importer login endpoint performs the email addition without any checks and can be replayed indefinitely. The request is a GET, so it can be triggered cross site, meaning another website can cause the victim's browser to load that URL. The request has no checks and works for other users too. The report does not describe the server side validation in more detail; the observable behaviour is that the request has no checks and works for other users.

What an attacker could do with it

An attacker who can get a victim to issue the request can attach an email address they control to the victim's Facebook account and then use the "Forgot your password" flow to take over the account. The email is added to the victim's account silently. The attack requires the attacker to hold a Facebook account and an Outlook.com email not bound to it, and requires the victim to make the request; how that is achieved is left open in the report.

The fix

Facebook fixed the bug. The timeline in the report is:

Time Event
August 13, 2013, 07:00 Bug reported
August 13, 2013, 19:40 Better PoC and video sent to Facebook team
August 14, 2013, 01:00 Facebook team replies
August 14, 2013, 03:00 Bug is fixed

The author thanks Facebook's security team for running their bug bounty program and for the quick patch, noting it took them only 2 hours to roll out a working patch.

Things worth testing elsewhere

These are patterns to look for in other features, not steps that were run against Facebook.

  • Replay a captured contact importer or account linking request from a second account. A positive result is the linked email or identity appearing on the second account without any confirmation.
  • Look for GET requests that perform state changes in account recovery or identity linking flows, and check whether their tokens are bound to the issuing account. A positive result is the same token working across accounts.
  • Test whether an email added through an importer can be used in the password reset flow without further verification. A positive result is a reset link or code arriving at the attacker controlled address for the victim's account.
  • Check other third party contact book integrations for the same pattern: authorise once, capture the request, then replay it in another session. A positive result is the external address being attached to the other account silently.

Glossary

  • API: a way for one piece of software to talk to another, here Facebook's internal interface used by its own pages.
  • API instance: a particular running copy of that interface, named by the api_instance parameter.
  • API version: the version of the interface, named by the api_ver parameter.
  • Attacker: the person trying to take over someone else's account.
  • Auth token: a short piece of text issued by a server to identify a session or authorise an action; whoever holds it can use it.
  • Contact importer: the Facebook feature that links an outside address book, such as Outlook.com contacts, to a Facebook account.
  • Cross site request forgery (CSRF): a bug where an attacker makes a victim's browser send a request to a site the victim is logged into, without the victim meaning to.
  • Endpoint: the specific address and path on a server that handles a particular request.
  • GET request: a request normally used to fetch a page, whose details are visible in the URL and which can be triggered by loading a link or image.
  • Logging requests: recording every message the browser sends, for example with the browser's developer tools.
  • Parameter: an extra piece of information sent with a request, usually after the ? in a URL.
  • Password reset flow: the "Forgot your password" process that sends a reset message to the email address on file.
  • PoC: proof of concept, a demonstration that a bug can actually be exploited.
  • Replay: sending a captured request again, possibly in a different context.
  • Request: a message a browser sends to a server asking it to do something or return a page.
  • State change: any action that alters data on the server, such as adding an email address to an account.
  • Token binding: tying a token to the specific account it was issued for, so it cannot be used by anyone else.
  • Victim: the person whose account is being taken over.

More by Josip Franjkovic

View all

7 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.

Cross-site request forgery (CSRF)

The lesson behind this report.

Another site makes a signed-in user's browser perform an action they did not intend.