Make WordPress Core

Changeset 63099


Ignore:
Timestamp:
08/06/2026 07:37:16 PM (5 weeks ago)
Author:
desrosj
Message:

Security: Backport the WordPress 7.0.3 security fixes to the 6.1 branch.

  • Users: Ensure a proper email address is used before sending email confirmations.
  • Formatting: Prevent stack overflow in safecss_filter_attr.
  • Multisite: Enforce the active signup policy for existing users.
  • HTTP API: Improve compliance with IPv4 Special-Purpose Address Space.
  • Users: Prevent Usernames from mangling HTML
  • Canonical: Only redirect for publicly viewable post types.
  • Administration: When wp_is_large_user_count(), ensure that the post author is always added to author dropdown.
  • Editor: Fix output for Post Date.

Merges [63060],[63061],[63062],[63063],[63064],[63065],[63067] to the 6.1 branch.

Props xknown, westonruter, jeremyfelt, peterwilsoncc, paulkevan, lucasbustamante, jorbin, desrosj, vortfu, dmsnell, johnbillion, ehtis, batmoo, lancewillett, jonsurrell, isabel_brison, bernhard-reiter, tyxla, aduth.

Location:
branches/6.1
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • branches/6.1/package-lock.json

    r61960 r63099  
    43134313                },
    43144314                "@wordpress/block-library": {
    4315                         "version": "7.14.15",
    4316                         "resolved": "https://registry.npmjs.org/@wordpress/block-library/-/block-library-7.14.15.tgz",
    4317                         "integrity": "sha512-YXPXX3ZwZP5i6/iLZMEjEgAhEsEbc92cWGO/VPmmk1/YEjdAyp2gvOHcstJVAnq8Qz1pcRnctKyKiC5I/uHS+g==",
     4315                        "version": "7.14.16",
     4316                        "resolved": "https://registry.npmjs.org/@wordpress/block-library/-/block-library-7.14.16.tgz",
     4317                        "integrity": "sha512-gi01kh+LEPC4hfKYwdlyWk4gvm9OiuvhfaJbufp1VTXs2dQEjS9XLUb44muQnTIw5eOiFxT2b4H5u39WThpnxQ==",
    43184318                        "requires": {
    43194319                                "@babel/runtime": "^7.16.0",
  • branches/6.1/package.json

    r61960 r63099  
    8484                "@wordpress/block-directory": "3.15.15",
    8585                "@wordpress/block-editor": "10.0.10",
    86                 "@wordpress/block-library": "7.14.15",
     86                "@wordpress/block-library": "7.14.16",
    8787                "@wordpress/block-serialization-default-parser": "4.17.1",
    8888                "@wordpress/blocks": "11.16.4",
  • branches/6.1/src/js/_enqueues/admin/inline-edit-post.js

    r53352 r63099  
    306306
    307307                        // The post author no longer has edit capabilities, so we need to add them to the list of authors.
    308                         $(':input[name="post_author"]', editRow).prepend('<option value="' + $('.post_author', rowData).text() + '">' + $('#' + t.type + '-' + id + ' .author').text() + '</option>');
     308                        $(':input[name="post_author"]', editRow).prepend(
     309                                new Option(
     310                                        $('#' + t.type + '-' + id + ' .author').text(),
     311                                        $('.post_author', rowData).text()
     312                                )
     313                        );
    309314                }
    310315                if ( $( ':input[name="post_author"] option', editRow ).length === 1 ) {
  • branches/6.1/src/wp-admin/includes/user.php

    r56867 r63099  
    4545        }
    4646
     47        $errors = new WP_Error();
     48
    4749        $pass1 = '';
    4850        $pass2 = '';
     
    7981
    8082        if ( isset( $_POST['email'] ) ) {
    81                 $user->user_email = sanitize_text_field( wp_unslash( $_POST['email'] ) );
     83                $maybe_email = wp_unslash( $_POST['email'] );
     84                if ( is_string( $maybe_email ) && is_email( $maybe_email ) ) {
     85                        $user->user_email = $maybe_email;
     86                } else {
     87                        $errors->add( 'invalid_email', __( '<strong>Error:</strong> The email address is not correct.' ), array( 'form-field' => 'email' ) );
     88                }
    8289        }
    8390        if ( isset( $_POST['url'] ) ) {
     
    139146                $user->use_ssl = 1;
    140147        }
    141 
    142         $errors = new WP_Error();
    143148
    144149        /* checking that username has been typed */
  • branches/6.1/src/wp-includes/blocks/post-date.php

    r54257 r63099  
    3232
    3333        if ( isset( $attributes['isLink'] ) && $attributes['isLink'] ) {
    34                 $formatted_date = sprintf( '<a href="%1s">%2s</a>', get_the_permalink( $post_ID ), $formatted_date );
     34                $formatted_date = sprintf( '<a href="%1$s">%2$s</a>', esc_url( get_the_permalink( $post_ID ) ), esc_html( $formatted_date ) );
     35        } else {
     36                $formatted_date = esc_html( $formatted_date );
    3537        }
    3638
  • branches/6.1/src/wp-includes/canonical.php

    r54793 r63099  
    921921
    922922        if ( get_query_var( 'name' ) ) {
     923                $publicly_viewable_post_types = array_filter( get_post_types( array( 'exclude_from_search' => false ) ), 'is_post_type_viewable' );
     924
    923925                /**
    924926                 * Filters whether to perform a strict guess for a 404 redirect.
     
    941943                if ( get_query_var( 'post_type' ) ) {
    942944                        if ( is_array( get_query_var( 'post_type' ) ) ) {
    943                                 // phpcs:ignore WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare
    944                                 $where .= " AND post_type IN ('" . join( "', '", esc_sql( get_query_var( 'post_type' ) ) ) . "')";
     945                                $post_types = array_intersect( get_query_var( 'post_type' ), $publicly_viewable_post_types );
     946                                if ( empty( $post_types ) ) {
     947                                        return false;
     948                                }
     949                                $where .= " AND post_type IN ('" . implode( "', '", esc_sql( $post_types ) ) . "')";
    945950                        } else {
     951                                if ( ! in_array( get_query_var( 'post_type' ), $publicly_viewable_post_types, true ) ) {
     952                                        return false;
     953                                }
    946954                                $where .= $wpdb->prepare( ' AND post_type = %s', get_query_var( 'post_type' ) );
    947955                        }
    948956                } else {
    949                         $where .= " AND post_type IN ('" . implode( "', '", get_post_types( array( 'public' => true ) ) ) . "')";
     957                        $where .= " AND post_type IN ('" . implode( "', '", esc_sql( $publicly_viewable_post_types ) ) . "')";
    950958                }
    951959
  • branches/6.1/src/wp-includes/http.php

    r54157 r63099  
    558558                if ( $ip ) {
    559559                        $parts = array_map( 'intval', explode( '.', $ip ) );
    560                         if ( 127 === $parts[0] || 10 === $parts[0] || 0 === $parts[0]
    561                                 || ( 172 === $parts[0] && 16 <= $parts[1] && 31 >= $parts[1] )
    562                                 || ( 192 === $parts[0] && 168 === $parts[1] )
     560
     561                        /*
     562                         * These IP address ranges are not considered valid external hosts for HTTP requests.
     563                         *
     564                         * If the host resolves to an IP address in these ranges, the request will be rejected unless the 'http_request_host_is_external' filter allows it.
     565                         *
     566                         * References:
     567                         *
     568                         * - IPv4 Special-Purpose Address Space: https://www.iana.org/assignments/iana-ipv4-special-registry/iana-ipv4-special-registry.xhtml
     569                         * - IPv4 Multicast Address Assignments: https://www.rfc-editor.org/rfc/rfc5771.html
     570                         */
     571                        if ( 127 === $parts[0] || 10 === $parts[0] || 0 === $parts[0]          // 127.0.0.0/8 (loopback), 10.0.0.0/8 (private), 0.0.0.0/8 (this network).
     572                                || ( 172 === $parts[0] && 16 <= $parts[1] && 31 >= $parts[1] )     // 172.16.0.0/12 (private).
     573                                || ( 192 === $parts[0] && 168 === $parts[1] )                      // 192.168.0.0/16 (private).
     574                                || ( 192 === $parts[0] && 0 === $parts[1] && 0 === $parts[2] )     // 192.0.0.0/24 (IETF protocol assignments).
     575                                || ( 192 === $parts[0] && 0 === $parts[1] && 2 === $parts[2] )     // 192.0.2.0/24 (TEST-NET-1).
     576                                || ( 192 === $parts[0] && 88 === $parts[1] && 99 === $parts[2] )   // 192.88.99.0/24 (6to4 relay anycast).
     577                                || ( 198 === $parts[0] && 51 === $parts[1] && 100 === $parts[2] )  // 198.51.100.0/24 (TEST-NET-2).
     578                                || ( 203 === $parts[0] && 0 === $parts[1] && 113 === $parts[2] )   // 203.0.113.0/24 (TEST-NET-3).
     579                                || ( 169 === $parts[0] && 254 === $parts[1] )                      // 169.254.0.0/16 (link-local and cloud metadata).
     580                                || ( 100 === $parts[0] && 64 <= $parts[1] && 127 >= $parts[1] )    // 100.64.0.0/10 (CGNAT).
     581                                || ( 198 === $parts[0] && 18 <= $parts[1] && 19 >= $parts[1] )     // 198.18.0.0/15 (benchmarking).
     582                                || ( 224 <= $parts[0] && 239 >= $parts[0] )                        // 224.0.0.0/4 (multicast).
     583                                || 240 <= $parts[0]                                                // 240.0.0.0/4 (reserved, includes 255.255.255.255 broadcast).
    563584                        ) {
    564585                                // If host appears local, reject unless specifically allowed.
  • branches/6.1/src/wp-includes/kses.php

    r61950 r63099  
    25132513                        );
    25142514
     2515                        // Bail if the recursive function stripping hit a PCRE error (e.g. stack/backtrack limit).
     2516                        if ( null === $css_test_string ) {
     2517                                continue;
     2518                        }
     2519
    25152520                        /*
    25162521                         * Disallow CSS containing \ ( & } = or comments, except for within url(), var(), calc(), etc.
    25172522                         * which were removed from the test string above.
    25182523                         */
    2519                         $allow_css = ! preg_match( '%[\\\(&=}]|/\*%', $css_test_string );
     2524                        $allow_css = 0 === preg_match( '%[\\\(&=}]|/\*%', $css_test_string );
    25202525
    25212526                        /**
  • branches/6.1/src/wp-includes/user.php

    r54477 r63099  
    153153                                /* translators: %s: User name. */
    154154                                __( '<strong>Error:</strong> The username <strong>%s</strong> is not registered on this site. If you are unsure of your username, try your email address instead.' ),
    155                                 $username
     155                                esc_html( $username )
    156156                        )
    157157                );
     
    178178                                /* translators: %s: User name. */
    179179                                __( '<strong>Error:</strong> The password you entered for the username %s is incorrect.' ),
    180                                 '<strong>' . $username . '</strong>'
     180                                '<strong>' . esc_html( $username ) . '</strong>'
    181181                        ) .
    182182                        ' <a href="' . wp_lostpassword_url() . '">' .
     
    250250                                /* translators: %s: Email address. */
    251251                                __( '<strong>Error:</strong> The password you entered for the email address %s is incorrect.' ),
    252                                 '<strong>' . $email . '</strong>'
     252                                '<strong>' . esc_html( $email ) . '</strong>'
    253253                        ) .
    254254                        ' <a href="' . wp_lostpassword_url() . '">' .
     
    33473347                                /* translators: %s: Link to the login page. */
    33483348                                __( '<strong>Error:</strong> This email address is already registered. <a href="%s">Log in</a> with this address or choose another one.' ),
    3349                                 wp_login_url()
     3349                                esc_url( wp_login_url() )
    33503350                        )
    33513351                );
     
    33953395                                /* translators: %s: Admin email address. */
    33963396                                __( '<strong>Error:</strong> Could not register you&hellip; please contact the <a href="mailto:%s">site admin</a>!' ),
    3397                                 get_option( 'admin_email' )
     3397                                esc_attr( get_option( 'admin_email' ) )
    33983398                        )
    33993399                );
     
    36183618 * @since 3.0.0
    36193619 * @since 4.9.0 This function was moved from wp-admin/includes/ms.php so it's no longer Multisite specific.
     3620 * @since 7.0.3 Added the `$user_id` parameter, which is sent with the `personal_options_update` action.
     3621 *
     3622 * @param int $user_id Optional. The ID of the user whose email is being changed. Defaults to `$_POST['user_id']` if set, otherwise 0.
    36203623 *
    36213624 * @global WP_Error $errors WP_Error object.
    36223625 */
    3623 function send_confirmation_on_profile_email() {
     3626function send_confirmation_on_profile_email( $user_id = 0 ) {
    36243627        global $errors;
     3628
     3629        // Maintain backward compatibility for those relying on a check based on $_POST['user_id'].
     3630        if ( ! $user_id && isset( $_POST['user_id'] ) ) {
     3631                $user_id = (int) $_POST['user_id'];
     3632        }
    36253633
    36263634        $current_user = wp_get_current_user();
     
    36293637        }
    36303638
    3631         if ( $current_user->ID != $_POST['user_id'] ) {
     3639        if ( 0 === $current_user->ID || $current_user->ID !== (int) $user_id ) {
    36323640                return false;
    36333641        }
     
    36433651                        );
    36443652
     3653                        $_POST['email'] = addslashes( $current_user->user_email );
    36453654                        return;
    36463655                }
     
    36563665                        delete_user_meta( $current_user->ID, '_new_email' );
    36573666
     3667                        $_POST['email'] = addslashes( $current_user->user_email );
    36583668                        return;
    36593669                }
  • branches/6.1/src/wp-login.php

    r54224 r63099  
    11301130                                        /* translators: %s: Link to the login page. */
    11311131                                        __( 'Check your email for the confirmation link, then visit the <a href="%s">login page</a>.' ),
    1132                                         wp_login_url()
     1132                                        esc_url( wp_login_url() )
    11331133                                ),
    11341134                                'message'
     
    11401140                                        /* translators: %s: Link to the login page. */
    11411141                                        __( 'Registration complete. Please check your email, then visit the <a href="%s">login page</a>.' ),
    1142                                         wp_login_url()
     1142                                        esc_url( wp_login_url() )
    11431143                                ),
    11441144                                'message'
  • branches/6.1/src/wp-signup.php

    r54192 r63099  
    990990                        break;
    991991                case 'gimmeanotherblog':
    992                         validate_another_blog_signup();
     992                        if ( 'all' === $active_signup || 'blog' === $active_signup ) {
     993                                validate_another_blog_signup();
     994                        } else {
     995                                _e( 'Site registration has been disabled.' );
     996                        }
    993997                        break;
    994998                case 'default':
Note: See TracChangeset for help on using the changeset viewer.