Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Best practice for resetting forgotten user passwords

As far as I can think, there are two reasonable ways to reset a user's forgotten password.

  1. Have the user enter their email address and a new plaintext password is sent to their email address.

  2. A link is sent to their email address which has a UID number in the URL. Clicking on this takes the user to a form on the website where they can choose there own new password.

Which method is preferable and why?

If method 1 is used, perhaps a third party could read the email and obtain the new password. If method 2 is used, what is to stop someone methodically going through UID codes to try and access the form to change a user's password?

like image 712
Lars Avatar asked Apr 15 '13 14:04

Lars


People also ask

What are the recommended practices for allowing users to change or recover passwords?

Outdated Password Best Practices These generally include: Ensuring complex passwords are composed of alphabetic (uppercase and lowercase) and numeric characters in addition to special symbols and similar characters. Forcing users to change passwords regularly. Requiring new passwords not previously used by the user.

How would you assist a customer with a password reset?

In summary, if your customer says, “I can't log in!” ask them how they accessed the sign-in page. If they are in the right place, send them a reset link. Send them the correct sign-in link if they're in the wrong place. Verify their email address to make sure they receive the password reset email.

How often should a password be reset?

But how often should you create new passwords? Cybersecurity experts recommend changing your password every three months. There may even be situations where you should change your password immediately, especially if a cybercriminal has access to your account.


2 Answers

The best pattern would be :

  1. User requests password reset. Best is to do it through username, and don't indicate if the username exists or not (to avoid possible users listing through a script)

  2. You generate a record in a new database table with userid, datetime of request (= current datetime), and a GUID you just generated

  3. You send a mail to the user, pointing to password reset page with the GUID (not the userid) as parameter

  4. On this page, you should check that the GUID is existing, and eventually you could put some expiration date (=the user has 1 day to reset, for example)

  5. Don't forget to mark the record as "used" (with an extra field in the table) when the user reset his password, so that you can stop an eventual second try...

It could possibly even more secure, but that is already quite good I think....

like image 51
Laurent S. Avatar answered Sep 19 '22 18:09

Laurent S.


OWASP has a good checklist of https://www.owasp.org/index.php/Forgot_Password_Cheat_Sheet

Here is a quick summary of steps:

  1. Gather Identity Data or Security Questions
  2. Verify Security Questions
  3. Send a Token Over a Side-Channel
  4. Allow user to change password
like image 37
rmblstrp Avatar answered Sep 18 '22 18:09

rmblstrp