Opened 18 months ago
Last modified 3 months ago
#59824 new defect (bug)
PHP Warning raised in pluggable.php when passing NULL instead of a string
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Awaiting Review | Priority: | normal |
Severity: | normal | Version: | 6.3.3 |
Component: | Security | Keywords: | has-patch reporter-feedback |
Focuses: | administration, privacy | Cc: |
Description
The error message is related to the hash_equals(): Expected known_string to be a string, null given in /var/www/../wp-includes/pluggable.php on line 2577
Hackers often pass NULL when attempting to trigger a leaked server warning message while accessing wp-login.php. This can be easily fixed by introducing type checking in pluggable.php:
function wp_check_password( $password, $hash, $user_id = '' ) { global $wp_hasher; // If the hash is still md5... if (is_string($hash) && strlen( $hash ) <= 32 ) { $check = hash_equals( $hash, md5( $password ) ); //$hash is the **known_string** and it must be of type string //The rest of the function
Change History (3)
This ticket was mentioned in PR #8232 on WordPress/wordpress-develop by @debarghyabanerjee.
3 months ago
#1
- Keywords has-patch added; needs-patch removed
#2
@
3 months ago
- Keywords reporter-feedback added
@budiony Thanks for the report and sorry nobody got back to you sooner.
There is no code path in WordPress core that allows a null
value to be passed to check_password()
. Every call to wp_check_password()
is preceded with either a guard condition for an empty password or with a string manipulation function that casts a null value to a string.
Do you have a plugin installed on your site that calls check_password()
or otherwise deals with authentication or passwords on your site? I suspect that such a plugin (or theme) is the actual root cause of the warning you're seeing on your site.
@debarghyabanerjee Please be more careful with your PRs. Attempting to fix a problem without first being able to reproduce it is not helpful and not a good use of your time or that of people who review the PR. An AI-generated PR summary is fine as long as you verify that everything that is says is accurate, which this is not.
#3
@
3 months ago
Hi! @johnbillion, sorry, my bad, I didn't check how Core was using this function, I verified the issue by calling the wp_check_password() function by passing null, and I was getting the Error, that's why I raised a PR for it.
Additionally, I wrote the PR description myself, and just used AI to fix it grammatically.
I will be more careful from the next PR. Thanks for mentioning. Really appreciate your valuable feedback, and sorry for the mistake.
Trac Ticket: Core-59824
## Summary
hash_equals()
function in thewp_check_password()
function would throw an error when it received a null value as one of its arguments. This issue occurs when the hash comparison logic inadvertently passes null, causing PHP to raise a TypeError in certain edge cases, especially when a hacker attempts to pass null values in an attack. The fix ensures that both the hash and the plaintext password are properly validated as strings before callinghash_equals()
andCheckPassword()
.## Changes
$hash
and the result ofmd5($password)
are valid strings.$wp_hasher->CheckPassword()
to ensure both$password
and$hash
are strings.## Why is this important?