Make WordPress Core


Ignore:
Timestamp:
02/11/2025 11:12:03 AM (2 months ago)
Author:
johnbillion
Message:

Security: Explicitly require the hash PHP extension and add requirement checks during installation and upgrade.

This extension provides the hash() function and support for the SHA-256 algorithm, both of which are required for upcoming security related changes. This extension is almost universally enabled, however it is technically possible to disable it on PHP 7.2 and 7.3, hence the introduction of this requirement and the corresponding requirement checks prior to installing or upgrading WordPress.

Props peterwilsoncc, ayeshrajans, dd32, SergeyBiryukov, johnbillion.

Fixes #60638, #62815, #56017

See #21022

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/pluggable.php

    r59754 r59803  
    773773        $key = wp_hash( $username . '|' . $pass_frag . '|' . $expiration . '|' . $token, $scheme );
    774774
    775         // If ext/hash is not present, compat.php's hash_hmac() does not support sha256.
    776         $algo = function_exists( 'hash' ) ? 'sha256' : 'sha1';
    777         $hash = hash_hmac( $algo, $username . '|' . $expiration . '|' . $token, $key );
     775        $hash = hash_hmac( 'sha256', $username . '|' . $expiration . '|' . $token, $key );
    778776
    779777        if ( ! hash_equals( $hash, $hmac ) ) {
     
    876874        $key = wp_hash( $user->user_login . '|' . $pass_frag . '|' . $expiration . '|' . $token, $scheme );
    877875
    878         // If ext/hash is not present, compat.php's hash_hmac() does not support sha256.
    879         $algo = function_exists( 'hash' ) ? 'sha256' : 'sha1';
    880         $hash = hash_hmac( $algo, $user->user_login . '|' . $expiration . '|' . $token, $key );
     876        $hash = hash_hmac( 'sha256', $user->user_login . '|' . $expiration . '|' . $token, $key );
    881877
    882878        $cookie = $user->user_login . '|' . $expiration . '|' . $token . '|' . $hash;
Note: See TracChangeset for help on using the changeset viewer.