Make WordPress Core

Changeset 46502


Ignore:
Timestamp:
10/14/2019 07:20:01 PM (7 years ago)
Author:
whyisjake
Message:

Backporting several bug fixes.

  • Query: Remove the static query property.
  • HTTP API: Protect against hex interpretation.
  • Filesystem API: Prevent directory travelersals when creating new folders.
  • Administration: Ensure that admin referer nonce is valid.
  • REST API: Send a Vary: Origin header on GET requests.
  • Customizer: Properly sanitize background images.

Backports [46474], [46475], [46476], [46477], [46478], [46483], [46485] to the 4.0 branch.

Location:
branches/4.0
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • branches/4.0/src/wp-includes/class-wp.php

    r44069 r46502  
    1616         * @var array
    1717         */
    18         public $public_query_vars = array('m', 'p', 'posts', 'w', 'cat', 'withcomments', 'withoutcomments', 's', 'search', 'exact', 'sentence', 'calendar', 'page', 'paged', 'more', 'tb', 'pb', 'author', 'order', 'orderby', 'year', 'monthnum', 'day', 'hour', 'minute', 'second', 'name', 'category_name', 'tag', 'feed', 'author_name', 'static', 'pagename', 'page_id', 'error', 'comments_popup', 'attachment', 'attachment_id', 'subpost', 'subpost_id', 'preview', 'robots', 'taxonomy', 'term', 'cpage', 'post_type');
     18        public $public_query_vars = array( 'm', 'p', 'posts', 'w', 'cat', 'withcomments', 'withoutcomments', 's', 'search', 'exact', 'sentence', 'calendar', 'page', 'paged', 'more', 'tb', 'pb', 'author', 'order', 'orderby', 'year', 'monthnum', 'day', 'hour', 'minute', 'second', 'name', 'category_name', 'tag', 'feed', 'author_name', 'pagename', 'page_id', 'error', 'comments_popup', 'attachment', 'attachment_id', 'subpost', 'subpost_id', 'preview', 'robots', 'taxonomy', 'term', 'cpage', 'post_type', 'embed' );
    1919
    2020        /**
  • branches/4.0/src/wp-includes/functions.php

    r44009 r46502  
    14921492        if ( file_exists( $target ) )
    14931493                return @is_dir( $target );
     1494
     1495        // Do not allow path traversals.
     1496        if ( false !== strpos( $target, '../' ) || false !== strpos( $target, '..' . DIRECTORY_SEPARATOR ) ) {
     1497                return false;
     1498        }
    14941499
    14951500        // We need to find the permissions of the parent folder that exists and inherit that.
  • branches/4.0/src/wp-includes/http.php

    r37120 r46502  
    470470                } else {
    471471                        $ip = gethostbyname( $host );
    472                         if ( $ip === $host ) // Error condition for gethostbyname()
    473                                 $ip = false;
     472                        if ( $ip === $host ) { // Error condition for gethostbyname()
     473                                return false;
     474                        }
    474475                }
    475476                if ( $ip ) {
  • branches/4.0/src/wp-includes/pluggable.php

    r45985 r46502  
    10651065 * @param string $query_arg where to look for nonce in $_REQUEST (since 2.5)
    10661066 */
    1067 function check_admin_referer($action = -1, $query_arg = '_wpnonce') {
    1068         if ( -1 == $action )
    1069                 _doing_it_wrong( __FUNCTION__, __( 'You should specify a nonce action to be verified by using the first parameter.' ), '3.2' );
     1067function check_admin_referer( $action = -1, $query_arg = '_wpnonce' ) {
     1068        if ( -1 === $action )
     1069                _doing_it_wrong( __FUNCTION__, __( 'You should specify a nonce action to be verified by using the first parameter.' ), '3.2.0' );
    10701070
    10711071        $adminurl = strtolower(admin_url());
    … …  
    10861086         */
    10871087        do_action( 'check_admin_referer', $action, $result );
     1088
     1089        if ( ! $result && ! ( -1 === $action && strpos( $referer, $adminurl ) === 0 ) ) {
     1090                wp_nonce_ays( $action );
     1091                die();
     1092        }
     1093
    10881094        return $result;
    10891095}
    … …  
    11001106 */
    11011107function check_ajax_referer( $action = -1, $query_arg = false, $die = true ) {
     1108        if ( -1 === $action )
     1109                _doing_it_wrong( __FUNCTION__, __( 'You should specify a nonce action to be verified by using the first parameter.' ), '3.2.0' );
     1110
    11021111        $nonce = '';
    11031112
    … …  
    22942303}
    22952304endif;
    2296 
  • branches/4.0/src/wp-includes/query.php

    r39963 r46502  
    13991399                        , 'attachment_id'
    14001400                        , 'name'
    1401                         , 'static'
    14021401                        , 'pagename'
    14031402                        , 'page_id'
    … …  
    15971596                        // post is being queried.
    15981597                        $this->is_single = true;
    1599                 } elseif ( '' != $qv['static'] || '' != $qv['pagename'] || !empty($qv['page_id']) ) {
     1598                } elseif ( '' != $qv['pagename'] || !empty($qv['page_id']) ) {
    16001599                        $this->is_page = true;
    16011600                        $this->is_single = false;
  • branches/4.0/tests/phpunit/tests/auth.php

    r30467 r46502  
    102102        }
    103103
     104        /**
     105         * @ticket 29542
     106         */
     107        function test_wp_verify_nonce_with_integer_arg() {
     108                $this->assertFalse( wp_verify_nonce( 1 ) );
     109        }
     110
     111        /**
     112         * @ticket 36361
     113         */
     114        public function test_check_admin_referer_with_no_action_triggers_doing_it_wrong() {
     115                $this->setExpectedIncorrectUsage( 'check_admin_referer' );
     116
     117                // A valid nonce needs to be set so the check doesn't die()
     118                $_REQUEST['_wpnonce'] = wp_create_nonce( -1 );
     119                $result = check_admin_referer();
     120                $this->assertSame( 1, $result );
     121
     122                unset( $_REQUEST['_wpnonce'] );
     123        }
     124
     125        /**
     126         * @ticket 36361
     127         */
     128        public function test_check_ajax_referer_with_no_action_triggers_doing_it_wrong() {
     129                $this->setExpectedIncorrectUsage( 'check_ajax_referer' );
     130
     131                // A valid nonce needs to be set so the check doesn't die()
     132                $_REQUEST['_wpnonce'] = wp_create_nonce( -1 );
     133                $result = check_ajax_referer();
     134                $this->assertSame( 1, $result );
     135
     136                unset( $_REQUEST['_wpnonce'] );
     137        }
     138
    104139        function test_password_length_limit() {
    105140                $passwords = array(
Note: See TracChangeset for help on using the changeset viewer.