Tuesday, April 29, 2014

Account Takeover Using Password Reset Token Prediction

Password Reset Token Prediction Using Password Reset Functionality


While researching and working on bug bounties I have found another way that by using Password Reset Functionality, Token & Link we can Takeover all the users account of a website if that site is vulnerable to this type of attack.

Using this vulnerability the attacker can predict the password reset token for any victims account by sending the password reset request into the victims account and in this way he can also reset all passwords of all the accounts and can successfully compromise the victims account as the password reset link sent to the user includes the password reset token which is predictable by the attacker.

Please Note: The password reset request has to been sent 1st on your own email id and then on the victims email id as if you send it only on your email id then you can't forcely generate it for the vicitms email id. Also keep in mind that the whole tokens each values can be incremental or few values or only one value can be incremental.

Steps to Execute the Attack:
There was a precondition that an attacker shall now the victims email id only :).

1. 1st the attacker sent the password reset request in his own emaild id attackeremailid@gmail.com after that quickly he sends the password reset request on the victims email id victimemailid@gmail.com using the below mentioned password reset request link.  

https://testsite.com/account/resetpassword

2. Now the attacker will receive as password reset link on his own email id attackeremailid@gmail.com the link will be as mentioned below.

https://testsite.com/account/resetpassword?code=GH193733-5mq1-0a37-e051-43fefa0aaed6


3. For token analysis I created 2 test accounts using which I found that if we send the password reset request 1st on our own email id and after that if we quickly send the another password reset request on any victims email id then we can predict the password reset token for any victims account, as the password reset token values GH193733-5mq1-0a37-e051-43fefa0aaed6 for 9th 10th 11th &12th characters are changing in incremental way for the next users password reset token.

4. So as the attackers own password reset token is GH193733-5mq1-0a37-e051-43fefa0aaed6 then he can predict the victims password reset token also and it will be GH193733-6nr2-0a37-e051-43fefa0aaed6


5. The crafted password reset link to reset and compromise the victims account will be as mentioned below.

Crafted Url to Reset the password of the Victims Email ID(i.e account)victimemailid@gmail.com:
https://testsite.com/account/resetpassword?code=GH193733-6nr2-0a37-e051-43fefa0aaed6

Impact: 
The token generated for the password reset link isn’t random for each password request, allowing an attacker to predict the token values for a known email address and reset their password. This provides a trivial route for an attacker to gain access to accounts or cause a  denial of service to users on the Application.

Recommendation:  
The recommended approach is to generate a onetime token on each password reset request which is linked to the user account, the token value shall not be preditcable values and it shall expire once the password has been reset. Additionally, ensure if the identifier is not passed that this won’t default to updating all accounts.
Also the Input from the user should be treated as untrusted and re-validated when sent to the server.

So in this way one can Takeover on any victims accounts using the Password Reset Functionality, Token & Link also this way can be used to find same type of vulnerabilities on many different websites.


Suggestions and Feedbacks are welcome.

2 comments:

  1. Thanks for sharing this brother's. I have just jumped into web app vuln testing pond. Soon I will learn more and more and start to secure web apps.

    ReplyDelete
  2. @Sathish Kumar You are welcome bro....i hope it will be helpful in leanring :)....thats nice to know.....keep learning and all the best for ur future :)

    ReplyDelete

You Have Successfully Posted the Message.