Skip to content
This repository has been archived by the owner on Apr 3, 2019. It is now read-only.

fix(email): on password reset, hash email with the emailToHashWith value #6579

Merged
merged 1 commit into from Oct 1, 2018

Conversation

vbudhram
Copy link
Contributor

@vbudhram vbudhram commented Sep 24, 2018

Fixes #6571

After some investigating and head scratching, it turns out that the password reset is not using the correct email address to hash the password when the password is reset. I am not sure when this got regressed but suspect it might have been with account recovery.

This PR pdates the completePasswordReset and resetPasswordWithRecoveryKey functions to correctly pass the email that should be hashed with password (emailToHashWith). This value ensures that passwords are always hashed with the original email the account was created with.

Unfortunately, with this bug, we can't have that guarantee anymore because there might be some users that reset their passwords (after performing a primary email change), so their password would be hashed with the new email.

In practice, I don't believe this is an issue because the auth-server will only compare the authPW that the content-server passes to it.

@vbudhram vbudhram added the WIP label Sep 24, 2018
@vbudhram vbudhram added this to the FxA-0: quality milestone Sep 24, 2018
@vbudhram vbudhram self-assigned this Sep 24, 2018
@ghost ghost added the waffle:active label Sep 24, 2018
* @returns {Promise} - resolves when complete
*/
completePasswordReset (password, token, code, relier) {
completePasswordReset (password, token, code, relier, emailToHashWith) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a huge fan of this variable name, but I used it in other parts of the code..so I'll be consistent for time being.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 for consistency, at least until we get around to a cleanup like https://github.com/mozilla/fxa-auth-server/issues/2344

@@ -1173,6 +1174,47 @@ define(function (require, exports, module) {
});
});

describe('completeAccountPasswordResetWithRecoveryKey', () => {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Noticed I didn't add a test for this before.

@vbudhram vbudhram requested a review from a team September 25, 2018 14:26
@vbudhram
Copy link
Contributor Author

@mozilla/fxa-devs I think this is ready for r!

@vbudhram
Copy link
Contributor Author

Looks like email timeout errors, will restart in a bit.

Copy link

@shane-tomlinson shane-tomlinson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

r+, LGTM, thanks @vbudhram!

@shane-tomlinson shane-tomlinson merged commit 9312cc9 into master Oct 1, 2018
@ghost ghost removed the waffle:review label Oct 1, 2018
@shane-tomlinson shane-tomlinson deleted the issue-6571-incorrect-password-change-email branch October 1, 2018 12:41
@SorinaFlorean
Copy link

Verified as fixed on Train 122.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants