question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Securely store password reset tokens

See original GitHub issue

As displayed in https://github.com/feathersjs/feathers-authentication-management/blob/master/src/sendResetPwd.js#L37, it doesn’t look like this module hashes the password reset tokens when it adds them to the user’s data store. However, reset tokens are a credential useful to an adversary in the case of a data breach, similar to that of passwords themselves. It is a lot less work to use a reset token to take over a user’s account than it is to brute-force bcrypt hashes.

I think that the reset tokens should be sent, and then the user model patched with the hashed variant of the sent token. This will mitigate a number of situations in which the database can be read (and not necessarily written to) by an adversary. A realistic situation I brought up in a recent blog post is a situation in which the database is directly exposed for reading to the internet due to misconfiguration. An adversary can issue password resets for users and hijack accounts without needing write access to the user models of the applications.

I didn’t issue a PR for this as I’m not entirely familiar with the architecture of Feathers, and it seems that a change of this nature would be a breaking change for existing reset tokens unless the user model was flagged or migrated in some fashion, a non-trivial task when the hashing algorithm and underlying data store can be changed. These are architectural decisions best left to maintainers.

Ways I can see this happening:

  1. In new versions of feathers-authentication-management, patchUser also patches user models with isSecureToken: true as a stopgap, and the code branches to check old, active reset tokens. New reset tokens are hashed and checked against the hashed variant.
  2. Don’t worry about it. Tokens have a short expiration date, and the token not matching just forces a new reset for some users stuck during the migration process.
  3. Migrate old plaintext tokens upon upgrade to the new module. This would likely need some way to detect whether an existing token was hashed, which is fuzzy at best given that the password hash algorithm can be changed out by a user.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
micaksica2commented, Aug 7, 2017

Does that mean you are indifferent at this stage as to which way it goes? If I’m writing the PR for this I’m going to choose the “break old reset tokens” option because it’s by far the easiest to develop and test for. 😀

0reactions
eddyystopcommented, Nov 9, 2018

The a-l-m rewrite has an option.passwordfield. The default is obtained from config/default.json.

Full details at https://github.com/feathers-plus/authentication-local-management/blob/master/misc/upgrading.md

Read more comments on GitHub >

github_iconTop Results From Across the Web

Creating Secure Password Resets With JSON Web Tokens
To accomplish a secure password reset, I will demonstrate how to use JSON Web Tokens (JWT) to generate a URL-safe token.
Read more >
Storing password reset token in DB - what are the implications?
Storing a token in a DB is a fairly common way to handle a reset. Just make sure you also store the username...
Read more >
Authentication Security: Password Reset Best Practices and ...
We'll start with resetting user passwords and what security issues ... favorite browser and check how many access tokens are stored there.
Read more >
10 Password Reset Token Best Practices - CLIMB
1. Use a secure token generation algorithm · 4. Don't send password reset emails from your own email server · 6. Don't store...
Read more >
Implementing a forgot password flow (with pseudo code)
Resetting a password requires sending a token to a user's email address and this provides an opening for attackers. Making sure you have...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found