Skip to content

Move to stronger password hash#2401

Merged
davidpanderson merged 12 commits into
masterfrom
knr_passwd_hash
Apr 17, 2018
Merged

Move to stronger password hash#2401
davidpanderson merged 12 commits into
masterfrom
knr_passwd_hash

Conversation

@TheAspens

@TheAspens TheAspens commented Mar 8, 2018

Copy link
Copy Markdown
Member

These changes will close issue #2353 and close issue #1644.

@TheAspens TheAspens changed the title WIP: Move to stronger password hash Move to stronger password hash Mar 9, 2018
@TheAspens TheAspens changed the title Move to stronger password hash [WIP] Move to stronger password hash Mar 9, 2018
@TheAspens

TheAspens commented Mar 9, 2018

Copy link
Copy Markdown
Member Author

@drshawnkwang and @tristanolive - can the two of you please review this pull request and see if anything needs to be changed in the Drupal code?

@TheAspens TheAspens changed the title [WIP] Move to stronger password hash Move to stronger password hash Mar 9, 2018
@TheAspens

Copy link
Copy Markdown
Member Author

@davidpanderson - can you please review this as well but if you are ok with it, please don't merge until either @drshawnkwang and @tristanolive have chimed in.

@TheAspens

Copy link
Copy Markdown
Member Author

Also @brevilo and @nicolas17 - since you guys reveiwed the original design - do you guys want to review the implementation real quick?

@brevilo

brevilo commented Mar 12, 2018

Copy link
Copy Markdown
Contributor

FYI, as I added myself as a reviewer David got dropped for an unknown reason, hence I added him back.

@brevilo brevilo left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

A general note: please try to stick to one format/style for arguments lists. That is, where you use spaces around arguments, operators and commas. Ideally use a formatter with your preferred style rules, preferably matching (or closely following) BOINC's. Thanks.

Comment thread html/ops/login_action.php Outdated
function do_passwd_rehash($user,$passwd_hash) {
$database_passwd_hash = password_hash($passwd_hash , PASSWORD_DEFAULT);
$result = $user->update(
"passwd_hash='$database_passwd_hash'"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Here you escape the password hash before its use as part of an SQL clause. If you think it's required, it should be done here as well.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

After reviewing, the hash does not need to be escaped so I have removed it from the referenced line.

Comment thread html/user/am_set_info.php
$query .= " passwd_hash='$password_hash', ";
$database_passwd_hash = password_hash($password_hash , PASSWORD_DEFAULT);
$query .= " passwd_hash='$database_passwd_hash', ";
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Here you escape the password hash before its use as part of an SQL clause. If you think it's required, it should be done here as well.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

After reviewing, the hash does not need to be escaped so I have removed it from the referenced line.

$email_addr = BoincDb::escape_string($email_addr);
$result = $user->update(
"email_addr='$email_addr', passwd_hash='$passwd_hash', email_validated=0"
"email_addr='$email_addr', passwd_hash='$database_passwd_hash', email_validated=0"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Here you escape the password hash before its use as part of an SQL clause. If you think it's required, it should be done here as well.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

After reviewing, the hash does not need to be escaped so I have removed it from the referenced line.

Comment thread html/user/edit_passwd_action.php Outdated
$passwd_hash = md5($passwd.$user->email_addr);
$result = $user->update("passwd_hash='$passwd_hash'");
$database_passwd_hash = password_hash( $passwd_hash, PASSWORD_DEFAULT);
$result = $user->update("passwd_hash='$database_passwd_hash'");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Here you escape the password hash before its use as part of an SQL clause. If you think it's required, it should be done here as well.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

After reviewing, the hash does not need to be escaped so I have removed it from the referenced line.

Comment thread html/user/login_action.php Outdated
function do_passwd_rehash($user,$passwd_hash) {
$database_passwd_hash = password_hash($passwd_hash , PASSWORD_DEFAULT);
$result = $user->update(
"passwd_hash='$database_passwd_hash'"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Here you escape the password hash before its use as part of an SQL clause. If you think it's required, it should be done here as well.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

After reviewing, the hash does not need to be escaped so I have removed it from the referenced line.

Comment thread html/user/login_action.php Outdated
}
// allow authenticator as password
if ($passwd != $user->authenticator) {
if ($passwd != $user->authenticator ) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why the added space? It's inconsistent.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

removed.

Comment thread html/user/lookup_account.php Outdated
function do_passwd_rehash($user,$passwd_hash) {
$database_passwd_hash = password_hash($passwd_hash , PASSWORD_DEFAULT);
$result = $user->update(
"passwd_hash='$database_passwd_hash'"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Here you escape the password hash before its use as part of an SQL clause. If you think it's required, it should be done here as well.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

After reviewing, the hash does not need to be escaped so I have removed it from the referenced line.

Comment thread html/user/lookup_account.php Outdated
if (!strlen($user->passwd_hash)) {
$user->passwd_hash = $auth_hash;
$user->passwd_hash = password_hash($auth_hash , PASSWORD_DEFAULT);
$user->update("passwd_hash='$user->passwd_hash'");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Here you escape the password hash before its use as part of an SQL clause. If you think it's required, it should be done here as well.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

After reviewing, the hash does not need to be escaped so I have removed it from the referenced line.

@TheAspens TheAspens requested a review from tristanolive March 13, 2018 12:56
@TheAspens

Copy link
Copy Markdown
Member Author

I fixed the style issues. Please let me know if you have any other feedback on the change. Thanks!

@drshawnkwang

Copy link
Copy Markdown
Contributor

I looked at the code and checked-out your branch to test it on my Drupal devel. system. My testing shows that there shouldn't be any serious inconsistency with your PR and the drupal codebase. But we should also see if Tristan has any comments. Additionally, we'll work independently to put similar code into the drupal codebase.

@tristanolive

Copy link
Copy Markdown
Contributor

I'd expect some problems to arise with RPCs on the Drupal side, as some were implemented as simple wrappers around BOINC RPCs and others were a bit more involved. In particular, the create_account implementation in Drupal will likely need your changes integrated into it.

As Shawn's tests show, though, there doesn't look to be anything major.

@brevilo brevilo left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks!

@tristanolive

Copy link
Copy Markdown
Contributor

Update for clarity: This PR can go ahead without waiting for corresponding Drupal updates (which should follow before too long).

@TheAspens

Copy link
Copy Markdown
Member Author

@tristanolive - thanks for the clarification. Since I added you as a reviewer can you either approve or remove yourself as a reviewer? Thanks!

@davidpanderson - this touches enough stuff that I would appreciate your review on this - and if you are ok with it, please go ahead and merge it. Thanks!

@drshawnkwang

drshawnkwang commented Apr 3, 2018

Copy link
Copy Markdown
Contributor

I know this PR has 'pass review', but would it be possible to make two minor late changes:

  1. function do_passwd_rehash() - could this be moved into an .inc file, such as user_util, this way the Drupal-BOINC code could load the library and I can use this function?

  2. The file html/inc/password.php - could it be renamed html/inc/password.inc ? This would be make it consistent with the other libraries in that directory. The Drupal code selectively loads .inc files for use as libraries. We would want to require_once this file as you have.

Maybe do_passwd_rehash() could be moved into the password.inc library?

@TheAspens

Copy link
Copy Markdown
Member Author

@drshawnkwang - yes - I can make those. I'm updating this to WIP while I make those changes.

@TheAspens TheAspens changed the title Move to stronger password hash [WIP] Move to stronger password hash Apr 3, 2018
Kevin Reed added 2 commits April 4, 2018 13:46
@TheAspens TheAspens changed the title [WIP] Move to stronger password hash Move to stronger password hash Apr 4, 2018
@TheAspens

Copy link
Copy Markdown
Member Author

@drshawnkwang - please review again and let me know if this matches what you suggested and work for you. Thanks for the feedback.

@drshawnkwang

drshawnkwang commented Apr 4, 2018

Copy link
Copy Markdown
Contributor

@TheAspens , thanks for the changes. I checked out this branch and was able to load the password_compat.inc and user_util.inc libraries in order to use the functions you wrote. Thanks again for making these changes.

@TheAspens

Copy link
Copy Markdown
Member Author

I just found this #1644. Which will also be closed by this change.

@TheAspens

Copy link
Copy Markdown
Member Author

@drshawnkwang @brevilo @tristanolive @davidpanderson - This has been open long enough for any objections to be raised and so it should be good to merge. Can someone go ahead and merge this? Thanks!

@brevilo

brevilo commented Apr 16, 2018

Copy link
Copy Markdown
Contributor

@davidpanderson hasn't signed-off yet so he should do the merge as soon as he's ok with it.

@davidpanderson

Copy link
Copy Markdown
Contributor

This looks fine, but it conflicts with the token PR. Kevin, feel free to merge after resolving that.

Conflicts:
	py/Boinc/setup_project.py
@TheAspens

Copy link
Copy Markdown
Member Author

Ok - I've fixed the merge conflict. Everyone has approved this pull request so if someone can merge it I would appreciate it! (by the rules, I cannot merge my own).

@davidpanderson davidpanderson merged commit ad28e83 into master Apr 17, 2018
@TheAspens TheAspens deleted the knr_passwd_hash branch April 17, 2018 19:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants