From 2ec2662e9eb124bb1a62f2d24965f993581785c3 Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Tue, 6 Sep 2016 18:00:20 +0000 Subject: [PATCH] Upgrade/Install: Sanitize file name in `File_Upload_Upgrader`. Merge of [38524] to the 4.0 branch. Built from https://develop.svn.wordpress.org/branches/4.0@38531 git-svn-id: http://core.svn.wordpress.org/branches/4.0@38472 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/includes/class-wp-upgrader.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/wp-admin/includes/class-wp-upgrader.php b/wp-admin/includes/class-wp-upgrader.php index 2bef3eaa6e..81d5143b1c 100644 --- a/wp-admin/includes/class-wp-upgrader.php +++ b/wp-admin/includes/class-wp-upgrader.php @@ -1767,8 +1767,12 @@ class File_Upload_Upgrader { if ( ! ( ( $uploads = wp_upload_dir() ) && false === $uploads['error'] ) ) wp_die( $uploads['error'] ); - $this->filename = $_GET[$urlholder]; + $this->filename = sanitize_file_name( $_GET[ $urlholder ] ); $this->package = $uploads['basedir'] . '/' . $this->filename; + + if ( 0 !== strpos( realpath( $this->package ), realpath( $uploads['basedir'] ) ) ) { + wp_die( __( 'Please select a file' ) ); + } } }