Make WordPress Core


Ignore:
Timestamp:
02/03/2025 07:50:50 PM (10 months ago)
Author:
johnbillion
Message:

Security: Add the SensitiveParameter attribute to sensitive parameters.

Values passed to parameters with this attribute will be redacted if present in a stack trace when using PHP 8.2 or later. This reduces the chance that passwords and security keys get accidentally exposed in debug logs and bug reports.

Props petitphp, TobiasBg, jrf, johnbillion.

Fixes #57304

File:
1 edited

Legend:

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

    r59603 r59754  
    599599     *                          otherwise WP_Error.
    600600     */
    601     function wp_authenticate( $username, $password ) {
     601    function wp_authenticate(
     602        $username,
     603        #[\SensitiveParameter]
     604        $password
     605    ) {
    602606        $username = sanitize_user( $username );
    603607        $password = trim( $password );
     
    26322636     * @return string The hash string of the password.
    26332637     */
    2634     function wp_hash_password( $password ) {
     2638    function wp_hash_password(
     2639        #[\SensitiveParameter]
     2640        $password
     2641    ) {
    26352642        global $wp_hasher;
    26362643
     
    26682675     * @return bool False, if the $password does not match the hashed password.
    26692676     */
    2670     function wp_check_password( $password, $hash, $user_id = '' ) {
     2677    function wp_check_password(
     2678        #[\SensitiveParameter]
     2679        $password,
     2680        $hash,
     2681        $user_id = ''
     2682    ) {
    26712683        global $wp_hasher;
    26722684
     
    28642876     * @param int    $user_id  User ID.
    28652877     */
    2866     function wp_set_password( $password, $user_id ) {
     2878    function wp_set_password(
     2879        #[\SensitiveParameter]
     2880        $password,
     2881        $user_id
     2882    ) {
    28672883        global $wpdb;
    28682884
Note: See TracChangeset for help on using the changeset viewer.