Abusing Facebook Access Token with Man-in-the-Middle Attack

Pierluigi Paganini March 12, 2014

The Egyptian penetration tester Ahmed Elsobky discovered a serious flaw that allows attackers to sniff user’s traffic including access token.

Facebook is vulnerable to Man-in-the-Middle Attack, The Egyptian penetration tester Ahmed Elsobky discovered a serious flaw that allows attackers to sniff user’s traffic including private information.
We’d actually received an earlier report from another researcher regarding this same issue. In response to that report, we’ve been working on limiting this behavior when it comes to our official apps, since they’re pre-authorized. For other apps, unfortunately, fully preventing this would mean requiring any site integrating with Facebook to use HTTPS, which simply isn’t practical for right now.” reported Facebook security team.
In the past we have already examined Open URL Redirection url flaws in Facebook platform, similar bugs allow third-party applications to expose the user’s access token at risk. This time the Facebook vulnerability could be exploited by hackers to steal user’s access token which stores information about permissions that have been granted as well as information about the token itself (e.g. Expiration, app generated it). Resuming access tokens allow attackers to access the victim’s data and perform any actions on behalf of the user.
Ahmed Elsobky reported the vulnerability on 5th September 2013, the requirements for the exploit are:

  • The victim must be using a Facebook application(except: Facebook Messenger, Facebook Camera, Facebook for android/ios/symbian since these are pre-authorized apps).
  • The victim must be already logged in and the attacker must be a Man In The Middle!

Let’s assume that the victim is using Skype then the attacker can get an access_token with the full permissions of that application by injecting this basic iframe into any webpage that the victim visits:

 <iframe src=https://www.facebook.com/dialog/oauth?redirect_uri=http%3A%2F%2Flogin.skype.com%2Flogin%2Foauth%3Fapplication%3Daccount&client_id=260273468396&response_type=token width=0 height=0>

“Facebook will accept the HTTP link at the redirect_uri parameter so a GET request would be sent and the user/victim will get a 302 redirect to that HTTP URL with the access_token value of the application with all of its permissions! Then It’s done now and an access token with expires=[the current expiry value]  (usually it’s 0 with Skype and 0=never) is coming for you now to intercept and exploit!> very easy, isn’t it?” reported the expert’s post.

In general an attacker can use this URL/vector (http%3A%2F%2Fwww.facebook.com%2Fconnect%2Flogin_success.html&response_type=token&client_id=[app_id]) as redirect_uri parameter.

The problem is that Facebook allows the HTTP version of the Canvas URL to be used even if the app already has an HTTPS URI (i.e Although Skype has a HTTPS Canvas URL, Facebook allows the HTTP link in redirect_uri parameter) and also Facebook allows the request without any special tokens so anyone can make a request.

hacking facebook access token

Facebook users can prevent Man-In-The-Middle attacks using HTTPS to encrypt traffic that contains sensitive information and following penetration tester’s suggestions:

1- Use “HTTPS Everywhere” Browser Extension(https://www.eff.org/https-everywhere)
2- Don’t use any popular app that doesn’t use a SSL (Secure Socket Layer) because HTTPS Everywhere won’t help you in this case then!

Facebook app developers should never send an access token over unencrypted channel and Facebook users should only trust the encrypted apps and use “HTTPS Everywhere” Browser Extension for automated security.

Pierluigi Paganini

(Security Affairs – Facebook Access Token , hacking)

you might also like

leave a comment