Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RFC]: Increase security of resetToken by only storing hashed version in the database #6855

Closed
1 task
cannikin opened this issue Nov 10, 2022 · 2 comments
Closed
1 task
Labels
release:feature This PR introduces a new feature topic/auth topic/security

Comments

@cannikin
Copy link
Member

cannikin commented Nov 10, 2022

Summary

Similar to passwords, the idea has been floated to hash the resetToken before storing in the DB. This way if the DB itself is ever compromised, the resetToken could not be used to change any user's password.

Motivation

This was proposed by Kalcode in our Discord chat in response to the resetToken vulnerability we posted this week. This proposed feature would not have helped in that scenario, but is an additional layer of security we could add to dbAuth in general.

Detailed proposal

Right now the forgotPassword handler in the auth function receives a single argument, user, which is meant to be used to notify the user of their resetToken (extract the email and resetToken from the user object and send them an email).

I'd propose that this handler now receives two arguments: the user object (so that any necessary data like email and firstName can be accessed) as well as the "plain text" resetToken:

handler: (user, resetToken) => {
  // ...
}

This is the only time the plain text resetToken is available. user.resetToken (the value saved in the DB in the User table) is the result of hashing the plain text resetToken. When the end user follows the link to reset their password, the plain text resetToken is in the URL, and then on the server side we apply the same hash algorithm and can look up their user record in the database with that value.

Are you interested in working on this?

  • I'm interested in working on this
@cannikin cannikin added topic/auth release:feature This PR introduces a new feature topic/security labels Nov 10, 2022
@cannikin cannikin added this to Main Nov 10, 2022
@redwoodjs-bot redwoodjs-bot bot moved this to Triage in Main Nov 14, 2022
@jaiakt
Copy link
Contributor

jaiakt commented Apr 12, 2023

I'll take a stab at this

@thedavidprice
Copy link
Contributor

closed with #8041

@github-project-automation github-project-automation bot moved this from Triage to Done in Main Apr 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release:feature This PR introduces a new feature topic/auth topic/security
Projects
Status: Done
Development

No branches or pull requests

3 participants