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

Import external bcrypt plugin for password hashing #217

Merged
merged 1 commit into from
Feb 27, 2024
Merged

Conversation

ypcs
Copy link
Contributor

@ypcs ypcs commented Feb 21, 2024

It was noted in #216 that our project template defaults to WordPress default hashing method for password, which is still in 2024 weak MD5. There has for a long time existed mu-plugin, which can be used to replace password hashing with bcrypt.

This plugin hooks to WordPress core password handling functions, and overrides password checks so all obsolete MD5-hashed passwords will be converted to bcrypt (or whatever is in future the PHP default password hashing function).

See source code for more documentation.

Source:
https://raw.githubusercontent.com/roots/wp-password-bcrypt/master/wp-password-bcrypt.php
Original commit: <15f0d8919fb3731f79a0cf2fb47e1baecb86cb26>
License: MIT
Author: Roots
Author URI: https://roots.io

Closes: #216

It was noted in <#216> that
our project template defaults to WordPress default hashing method for
password, which is still in 2024 weak MD5. There has for a long time
existed mu-plugin, which can be used to replace password hashing with
bcrypt.

This plugin hooks to WordPress core password handling functions, and
overrides password checks so all obsolete MD5-hashed passwords will be
converted to bcrypt (or whatever is in future the PHP default password
hashing function).

See source code for more documentation.

Source:
<https://raw.githubusercontent.com/roots/wp-password-bcrypt/master/wp-password-bcrypt.php>
Original commit: <15f0d8919fb3731f79a0cf2fb47e1baecb86cb26>
License: MIT
Author: Roots
Author URI: <https://roots.io>

Closes: #216
@ypcs ypcs self-assigned this Feb 21, 2024
@pekkakortelainen
Copy link
Contributor

Test results below, any sensitive information replaced with asterisks for obvious reasons.

With initial setup:

$ wp user create testuser [email protected] --porcelain
5
$ wp user list --fields=ID,user_login,user_pass
+----+------------+--------------------------------------------------------------+
| ID | user_login | user_pass                                                    |
+----+------------+--------------------------------------------------------------+
| 5  | testuser   | $P$B******************************                           |
+----+------------+--------------------------------------------------------------+

Installed as a must-use plugin as the PR suggests:

$ l /data/wordpress/htdocs/wp-content/mu-plugins/
bedrock-autoloader.php  register-theme-directory.php  seravo-plugin/  wp-password-bcrypt.php

After mu-plugin installation the password hash remains the same (as expected and addressed in #216):

$ wp user list --fields=ID,user_login,user_pass
+----+------------+--------------------------------------------------------------+
| ID | user_login | user_pass                                                    |
+----+------------+--------------------------------------------------------------+
| 5  | testuser   | $P$B******************************                           |
+----+------------+--------------------------------------------------------------+

Force password reset on user:

$ wp user reset-password 5
Reset password for testuser.
Success: Password reset for 1 user.

Check again:

$ wp user list --fields=ID,user_login,user_pass
+----+------------+--------------------------------------------------------------+
| ID | user_login | user_pass                                                    |
+----+------------+--------------------------------------------------------------+
| 5  | testuser   | $2y$10$***************************************************** |
+----+------------+--------------------------------------------------------------+

LGTM, no warnings or errors on PHP 7.4 / 8.1 / 8.2 / 8.3.

@ypcs ypcs merged commit 24ffbac into master Feb 27, 2024
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Seravo doesn't use bcrypt hashing for passwords but rather MD5
2 participants