Make WordPress Core

Changeset 59754


Ignore:
Timestamp:
02/03/2025 07:50:50 PM (4 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

Location:
trunk/src
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/class-wp-importer.php

    r56396 r59754  
    196196     * @return array
    197197     */
    198     public function get_page( $url, $username = '', $password = '', $head = false ) {
     198    public function get_page(
     199        $url,
     200        $username = '',
     201        #[\SensitiveParameter]
     202        $password = '',
     203        $head = false
     204    ) {
    199205        // Increase the timeout.
    200206        add_filter( 'http_request_timeout', array( $this, 'bump_request_timeout' ) );
  • trunk/src/wp-admin/includes/upgrade.php

    r59465 r59754  
    4545     * }
    4646     */
    47     function wp_install( $blog_title, $user_name, $user_email, $is_public, $deprecated = '', $user_password = '', $language = '' ) {
     47    function wp_install(
     48        $blog_title,
     49        $user_name,
     50        $user_email,
     51        $is_public,
     52        $deprecated = '',
     53        #[\SensitiveParameter]
     54        $user_password = '',
     55        $language = ''
     56    ) {
    4857        if ( ! empty( $deprecated ) ) {
    4958            _deprecated_argument( __FUNCTION__, '2.6.0' );
     
    564573     *                           usually passed instead of the actual password.
    565574     */
    566     function wp_new_blog_notification( $blog_title, $blog_url, $user_id, $password ) {
     575    function wp_new_blog_notification(
     576        $blog_title,
     577        $blog_url,
     578        $user_id,
     579        #[\SensitiveParameter]
     580        $password
     581    ) {
    567582        $user      = new WP_User( $user_id );
    568583        $email     = $user->user_email;
  • trunk/src/wp-includes/class-wp-application-passwords.php

    r59084 r59754  
    460460     * @return string The chunked password.
    461461     */
    462     public static function chunk_password( $raw_password ) {
     462    public static function chunk_password(
     463        #[\SensitiveParameter]
     464        $raw_password
     465    ) {
    463466        $raw_password = preg_replace( '/[^a-z\d]/i', '', $raw_password );
    464467
  • trunk/src/wp-includes/class-wp-xmlrpc-server.php

    r59748 r59754  
    286286     * @return WP_User|false WP_User object if authentication passed, false otherwise.
    287287     */
    288     public function login( $username, $password ) {
     288    public function login(
     289        $username,
     290        #[\SensitiveParameter]
     291        $password
     292    ) {
    289293        if ( ! $this->is_enabled ) {
    290294            $this->error = new IXR_Error( 405, sprintf( __( 'XML-RPC services are disabled on this site.' ) ) );
     
    331335     * @return bool Whether authentication passed.
    332336     */
    333     public function login_pass_ok( $username, $password ) {
     337    public function login_pass_ok(
     338        $username,
     339        #[\SensitiveParameter]
     340        $password
     341    ) {
    334342        return (bool) $this->login( $username, $password );
    335343    }
  • trunk/src/wp-includes/class-wpdb.php

    r59159 r59754  
    750750     * @param string $dbhost     Database host.
    751751     */
    752     public function __construct( $dbuser, $dbpassword, $dbname, $dbhost ) {
     752    public function __construct(
     753        $dbuser,
     754        #[\SensitiveParameter]
     755        $dbpassword,
     756        $dbname,
     757        $dbhost
     758    ) {
    753759        if ( WP_DEBUG && WP_DEBUG_DISPLAY ) {
    754760            $this->show_errors();
  • trunk/src/wp-includes/ms-functions.php

    r59738 r59754  
    939939 * @return bool
    940940 */
    941 function wpmu_signup_blog_notification( $domain, $path, $title, $user_login, $user_email, $key, $meta = array() ) {
     941function wpmu_signup_blog_notification(
     942    $domain,
     943    $path,
     944    $title,
     945    $user_login,
     946    $user_email,
     947    #[\SensitiveParameter]
     948    $key,
     949    $meta = array()
     950) {
    942951    /**
    943952     * Filters whether to bypass the new site email notification.
     
    10741083 * @return bool
    10751084 */
    1076 function wpmu_signup_user_notification( $user_login, $user_email, $key, $meta = array() ) {
     1085function wpmu_signup_user_notification(
     1086    $user_login,
     1087    $user_email,
     1088    #[\SensitiveParameter]
     1089    $key,
     1090    $meta = array()
     1091) {
    10771092    /**
    10781093     * Filters whether to bypass the email notification for new user sign-up.
     
    11761191 * @return array|WP_Error An array containing information about the activated user and/or blog.
    11771192 */
    1178 function wpmu_activate_signup( $key ) {
     1193function wpmu_activate_signup(
     1194    #[\SensitiveParameter]
     1195    $key
     1196) {
    11791197    global $wpdb;
    11801198
     
    13281346 * @return int|false Returns false on failure, or int $user_id on success.
    13291347 */
    1330 function wpmu_create_user( $user_name, $password, $email ) {
     1348function wpmu_create_user(
     1349    $user_name,
     1350    #[\SensitiveParameter]
     1351    $password,
     1352    $email
     1353) {
    13311354    $user_name = preg_replace( '/\s+/', '', sanitize_user( $user_name, true ) );
    13321355
     
    16121635 * @return bool Whether the email notification was sent.
    16131636 */
    1614 function wpmu_welcome_notification( $blog_id, $user_id, $password, $title, $meta = array() ) {
     1637function wpmu_welcome_notification(
     1638    $blog_id,
     1639    $user_id,
     1640    #[\SensitiveParameter]
     1641    $password,
     1642    $title,
     1643    $meta = array()
     1644) {
    16151645    $current_network = get_network();
    16161646
     
    18461876 * @return bool
    18471877 */
    1848 function wpmu_welcome_user_notification( $user_id, $password, $meta = array() ) {
     1878function wpmu_welcome_user_notification(
     1879    $user_id,
     1880    #[\SensitiveParameter]
     1881    $password,
     1882    $meta = array()
     1883) {
    18491884    $current_network = get_network();
    18501885
     
    22722307 * @param array  $meta     Signup meta data.
    22732308 */
    2274 function add_new_user_to_blog( $user_id, $password, $meta ) {
     2309function add_new_user_to_blog(
     2310    $user_id,
     2311    #[\SensitiveParameter]
     2312    $password,
     2313    $meta
     2314) {
    22752315    if ( ! empty( $meta['add_to_blog'] ) ) {
    22762316        $blog_id = $meta['add_to_blog'];
  • trunk/src/wp-includes/pluggable-deprecated.php

    r47060 r59754  
    102102 * @param bool $remember Optional. Remember that the user is logged in
    103103 */
    104 function wp_setcookie($username, $password = '', $already_md5 = false, $home = '', $siteurl = '', $remember = false) {
     104function wp_setcookie(
     105    $username,
     106    #[\SensitiveParameter]
     107    $password = '',
     108    $already_md5 = false,
     109    $home = '',
     110    $siteurl = '',
     111    $remember = false
     112) {
    105113    _deprecated_function( __FUNCTION__, '2.5.0', 'wp_set_auth_cookie()' );
    106114    $user = get_user_by('login', $username);
     
    169177 * @return bool True on successful check, false on login failure.
    170178 */
    171 function wp_login($username, $password, $deprecated = '') {
     179function wp_login(
     180    $username,
     181    #[\SensitiveParameter]
     182    $password,
     183    $deprecated = ''
     184) {
    172185    _deprecated_function( __FUNCTION__, '2.5.0', 'wp_signon()' );
    173186    global $error;
  • 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
  • trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-users-controller.php

    r59357 r59754  
    13111311     * @return string|WP_Error The sanitized password, if valid, otherwise an error.
    13121312     */
    1313     public function check_user_password( $value, $request, $param ) {
     1313    public function check_user_password(
     1314        #[\SensitiveParameter]
     1315        $value,
     1316        $request,
     1317        $param
     1318    ) {
    13141319        $password = (string) $value;
    13151320
  • trunk/src/wp-includes/user.php

    r59657 r59754  
    151151 * @return WP_User|WP_Error WP_User on success, WP_Error on failure.
    152152 */
    153 function wp_authenticate_username_password( $user, $username, $password ) {
     153function wp_authenticate_username_password(
     154    $user,
     155    $username,
     156    #[\SensitiveParameter]
     157    $password
     158) {
    154159    if ( $user instanceof WP_User ) {
    155160        return $user;
     
    229234 * @return WP_User|WP_Error WP_User on success, WP_Error on failure.
    230235 */
    231 function wp_authenticate_email_password( $user, $email, $password ) {
     236function wp_authenticate_email_password(
     237    $user,
     238    $email,
     239    #[\SensitiveParameter]
     240    $password
     241) {
    232242    if ( $user instanceof WP_User ) {
    233243        return $user;
     
    302312 * @return WP_User|WP_Error WP_User on success, WP_Error on failure.
    303313 */
    304 function wp_authenticate_cookie( $user, $username, $password ) {
     314function wp_authenticate_cookie(
     315    $user,
     316    $username,
     317    #[\SensitiveParameter]
     318    $password
     319) {
    305320    global $auth_secure_cookie;
    306321
     
    343358 *                               null is passed in and this isn't an API request.
    344359 */
    345 function wp_authenticate_application_password( $input_user, $username, $password ) {
     360function wp_authenticate_application_password(
     361    $input_user,
     362    $username,
     363    #[\SensitiveParameter]
     364    $password
     365) {
    346366    if ( $input_user instanceof WP_User ) {
    347367        return $input_user;
     
    28472867 *                      be created.
    28482868 */
    2849 function wp_create_user( $username, $password, $email = '' ) {
     2869function wp_create_user(
     2870    $username,
     2871    #[\SensitiveParameter]
     2872    $password,
     2873    $email = ''
     2874) {
    28502875    $user_login = wp_slash( $username );
    28512876    $user_email = wp_slash( $email );
     
    30353060 * @return WP_User|WP_Error WP_User object on success, WP_Error object for invalid or expired keys.
    30363061 */
    3037 function check_password_reset_key( $key, $login ) {
     3062function check_password_reset_key(
     3063    #[\SensitiveParameter]
     3064    $key,
     3065    $login
     3066) {
    30383067    global $wp_hasher;
    30393068
     
    33723401 * @param string  $new_pass New password for the user in plaintext
    33733402 */
    3374 function reset_password( $user, $new_pass ) {
     3403function reset_password(
     3404    $user,
     3405    #[\SensitiveParameter]
     3406    $new_pass
     3407) {
    33753408    /**
    33763409     * Fires before the user's password is reset.
     
    49334966 * @return true|WP_Error True on success, WP_Error on failure.
    49344967 */
    4935 function wp_validate_user_request_key( $request_id, $key ) {
     4968function wp_validate_user_request_key(
     4969    $request_id,
     4970    #[\SensitiveParameter]
     4971    $key
     4972) {
    49364973    global $wp_hasher;
    49374974
Note: See TracChangeset for help on using the changeset viewer.