Skip to main content

OAuth 2 - How I have hacked Facebook again (..and would have stolen a valid access token)

Well well well, hacking time again :) No much time for big explanation but few weeks ago I was using a little variant of Lassie come home to potentially steal a valid Facebook's access token. In a nutshell reading a blog post of how the great Egor Homakov did hack Github  (see Bug 1. Bypass of redirect_uri validation with /../ ) I though how about Facebook :) ?.

Well here is what I found, I have copied a part of my report to Facebook security :

The redirect_uri in the is not validated correctly. I can bypass the redirect_uri validation with /.\.\../. This might result on stealing the authorization code of a Facebook registered OAuth Client. As an example I would use (that is owned by Facebook). In there is the chance to link an account with Facebook.
Now the correct request is:

but changing the request to:\.\../.\.\../asanso&state=420c2f177072bc328309aab640fa0e9141b0f7de2c1f7d81&scope=email

(please note the redirect_uri changed to\.\../.\.\../asanso)

will end up to be redirected to

The redirect_uri should instead not being accepted.
In order to see how this can be exploited in general let's assume that would also be a Facebook OAuth client with a registered redirect_uri of

I would then change the request from


(please note the redirect_uri=\.\../.\.\../.\.\../asanso/a2f05bb7e38ba6af88f8)

Now gist offers some limited html capability but i can use a cross domain resource, like <img>. In the img I can place <img src=""> or <img src="///">

When the user loads this URL, Github 302-redirects him automatically.


But the user agent loads

As soon as we get victim's CODE we can hit and yes :), we are logged into the victim's account and we have access to private gists.

I used an hypothesis of gist being an OAuth client but this would work with any OAuth client that will have the same situation than gist

The answer from Facebook was pretty quick (same for the fix):


We have looked into this issue and believe that the vulnerability has been patched. Please re-test the issue and follow up with us if you believe that the patch does not fully resolve the issue.


PS: Nice find! :)
 And yep I also got a bounty :)


Unknown said…
why is browser changing

ll said…
@unkown is this a question :) ?

Popular posts from this blog

OpenSSL Key Recovery Attack on DH small subgroups (CVE-2016-0701)

Usual Mandatory Disclaimer: IANAC (I am not a cryptographer) so I might likely end up writing a bunch of mistakes in this blog post... tl;dr The OpenSSL 1.0.2 releases suffer from a Key Recovery Attack on DH small subgroups . This issue got assigned CVE-2016-0701 with a severity of High and OpenSSL 1.0.2 users should upgrade to 1.0.2f. If an application is using DH configured with parameters based on primes that are not "safe" or not Lim-Lee (as the one in RFC 5114 ) and either Static DH ciphersuites are used or DHE ciphersuites with the default OpenSSL configuration (in particular SSL_OP_SINGLE_DH_USE is not set) then is vulnerable to this attack.  It is believed that many popular applications (e.g. Apache mod_ssl) do set the  SSL_OP_SINGLE_DH_USE option and would therefore not be at risk (for DHE ciphersuites), they still might be for Static DH ciphersuites. Introduction So if you are still here it means you wanna know more. And here is the thing. In my last bl

The Curious Case of WebCrypto Diffie-Hellman on Firefox - Small Subgroups Key Recovery Attack on DH

tl;dr Mozilla Firefox prior to version 72 suffers from Small Subgroups Key Recovery Attack on DH in the WebCrypto 's API. The Firefox's team fixed the issue r emoving completely support for DH over finite fields (that is not in the WebCrypto standard). If you find this interesting read further below. Premise In this blog post I assume you are already knowledgeable about Diffie-Hellman over finite fields and related attacks. If not I recommend to read any cryptography book that covers public key cryptography. Here is a really cool simple explanation by David Wong : I found a cooler way to explain Diffie-Hellman :D — David Wong (@cryptodavidw) January 4, 2020 If you want more details about Small Subgroups Key Recovery Attack on DH I covered some background in one of my previous post ( OpenSSL Key Recovery Attack on DH small subgroups (CVE-2016-0701) ). There is also an academic pape r where we examine the issue with some more rigors.

All your Paypal OAuth tokens belong to me - localhost for the win

tl;dr   I was able to hijack the OAuth tokens of EVERY Paypal OAuth application with a really simple trick. Introduction If you have been following this blog you might have got tired of how many times  I have stressed out the importance of the redirect_uri parameter in the OAuth flow. This simple parameter might be source of many headaches for any maintainer of OAuth installations being it a client or a server. Accepting the risk of repeating myself here is two simple suggestions that may help you stay away from troubles (you can always skip this part and going directly to the Paypal Vulnerability section): If you are building an OAuth client,   Thou shall register a redirect_uri as much as specific as you can i.e. if your OAuth client callback is then DO register   NOT JUST h ttps:// or If