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.

Thanks,
mae

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.

Regards,
Nilesh

Comments

Popular posts from this blog

Ardilla- New tool for finding SQL Injection and XSS

Three Researchers -- MIT's Adam Kiezun , Stanford's Philip Guo , and Syracuse University's Karthick Jayaraman -- has developed a new tool ' Ardilla ' that automatically finds and exploits SQL injection and cross-site scripting vulnerabilities in Web applications. It creates inputs that pinpoint bugs in Web applications and then generates SQL injection and XSS attacks. But for now Ardilla is for PHP -based Web app only. The researchers say Ardilla found 68 never-before found vulnerabilities in five different PHP applications using the tool -- 23 SQL injection and 45 XSS flaws. More information is awaited. For their attack generation techniques refer to their document at: http://www.cs.washington.edu/homes/mernst/pubs/create-attacks-tr054.pdf

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. T

Combining power of Fiddler with Burp

Both are pretty powerful tools when it comes to intercept and modify http communications. But at some point of time, they become even more powerful combo if tied with each other. They complement each other. In a recent pentest I came across a similar situation where in Burp was not able to intercept a specific kind of traffic and Fiddler came to rescue. The application was designed to upload video. The initial communication was straight forward, I mean logging into application, filling up the video details etc. And all these were easily captured by Burp except the point where you hit the Upload Video and it connects to a different server and surprisingly it was not captured by Burp, not sure why, even after repeated attempts. So, I fired Fiddler to see if the it sees this request. But it's a;ways to play with requests using Burp due to it's various functionalities like, Intruder, Repeaters etc. But it was necessary to capture this request in Burp. So the below steps can be