Skip to main content

Secure Forgot Password Implemantion

I got a message from Mae Bualat about secure implementation of forgot password mechanism. Although, his way also sounded secure to me, I suggested him more alternatives. It's always arguable the approaches, but these are my personal arguments as per my limited knowledge.
Following is the communication between us:
Hi Mr. Nilesh Kumar,

I've come across your blog while looking for some references on the web for a secured password recovery scheme. I suppose, as a security specialist, you may have inputs to help me work on it.

Am looking for a secure password recovery implementation. The process that I am looking into is this: user will need to supply email address used on account registration then birthday, then user will need to supply new password, then the system will send a verification link to his registered email to finalize and confirm the process.But aside from this, am still currently looking for some ways to securely implement this process.

Any idea will be highly appreciated.


I wrote:
Hi Mae,
Your implementation in the first glance looks reasonably secure to me, but again it depends on various scenarios as how rigorously you implement it, ie, no. of security questions and how personal they are as date of birth is not so personal now a days. Instead you may use mother's maiden name.
So, leaving the type of security questions you implement on you, I would suggest the following Do's and Don'ts. It's my personal assumption and may and may not be the best solution:

1. Don't rely on an email mechanism to send temporary password/ cleartext (actual ) password/ or any other sensitive instructions to the user's registered email. It may seem secure but there's always a risk of sniffing the passwords/ other sensitive instructions on how to reset the password over the unencrypted internet.
2. Don't display user's password on the webpage after answering some secret questions. The risk here is the page may be cached on the computer and anybody with little computer knowledge may have access to it. And this also implied that that the application is not storing the password in hashed form in the database, that is again a weak implementation.
3. Don't use password hints as to be displayed on the webpage, which is again guessable.

Now this should be reasonably secure mechanism:
1. Use a multistage password set mechanism where in you may ask username, registered email and some other information such as DOB, ZIP, customer no. etc.More are the questions, the more secure it is. Once all validated correctly, go to next stage, otherwise display generic message "Invalid Data".
2. Next stage, ask at least 3 personal security questions (like mother's maiden name, name of your first vacation place etc) already preset while user was registered. If correct go to next stage.
3. At this stage, finally, present user with new password reset form. Enforce all password complexity guidelines. One more thing you can dot to more it more secure is, as soon as the user is done with providing correct personal security answer as stage 2, immediately send a long random token to his registered e-mail. And then do require him to supply that long random token on this final new password reset page. This will act as 2-factor authentication.

Apart from that, all by-default security best practices you should follow, such as storing user's answers in salted hash in the DB, Don't use using HTTP method, Invalidate old password ONLY when user is done with setting new password successfully, Send an email informing user that password has been changed, Lock out the account for a certain period and then unlock it etc.

So in short, Don't use email to send sensitive information, use email for a out-of-band authentication purpose. This way, it might be reasonably secure implementation.



Popular posts from this blog

File Upload through Null Byte Injection

Sometimes, during file upload we come across situation wherein there would be check on the file extension at the client side as well as server side too. If the application does allow only .jpeg extension to be uploaded, the client side java script checks for the extension of the file before passing the request. We all know that how easily this can be defeated.
Some applications, checks for the extension at the server side also. That's not easy to bypass. However there are some ways with which it still can be bypassed. Most of server side scripts are written in high level languages such as Php, Java etc who still use some C/C++ libraries to read the file name and contents. That leads to the problem. In C/C++ a line ends with /00 or which is called Null Byte. So whenever the interpreter sees a null byte at the end of the a string, it stops reading thinking it has reached at the end of the string.
This can be used for the bypass. It works for many servers, specially php servers. Th…

SQL Injection in search field

Earlier I had written about performing SQL injection in search field and how to do a DoS attack and privilege escalation using 'Like' operators. Now another SQLi exploitation I came across recently. That too in the search field. This becomes important as lots of people don't pay much attention on the search forms/ fields in the application. My aim is to show that a search form can also be exploited with SQL Injection. The following queries are based on a real world exploitation. The steps and data are for just illustration purpose only. Suppose, the search form provides the details of users who have accessed the application some time and their login time details etc, we just need to provide their name in the search box provided. All the data were being going as Post request. So, to just fingerprint the database, I provide, 'nil'+'esh' in the search field and it successfully gives me the results. That means the database behind the application is concatenat…

Insecure protocols

Some basic insecure protocols and risk associated with them: