Make WordPress Core


Ignore:
Timestamp:
02/11/2025 11:12:03 AM (3 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/class-wpdb.php

    r59754 r59803  
    24132413
    24142414        if ( ! $placeholder ) {
    2415             // If ext/hash is not present, compat.php's hash_hmac() does not support sha256.
    2416             $algo = function_exists( 'hash' ) ? 'sha256' : 'sha1';
    24172415            // Old WP installs may not have AUTH_SALT defined.
    24182416            $salt = defined( 'AUTH_SALT' ) && AUTH_SALT ? AUTH_SALT : (string) rand();
    24192417
    2420             $placeholder = '{' . hash_hmac( $algo, uniqid( $salt, true ), $salt ) . '}';
     2418            $placeholder = '{' . hash_hmac( 'sha256', uniqid( $salt, true ), $salt ) . '}';
    24212419        }
    24222420
Note: See TracChangeset for help on using the changeset viewer.