diff --git a/src/wp-includes/functions.php b/src/wp-includes/functions.php index 979536f751..7db3bbafd9 100644 --- a/src/wp-includes/functions.php +++ b/src/wp-includes/functions.php @@ -1923,6 +1923,11 @@ function wp_mkdir_p( $target ) { return @is_dir( $target ); } + // Do not allow path traversals. + if ( false !== strpos( $target, '../' ) || false !== strpos( $target, '..' . DIRECTORY_SEPARATOR ) ) { + return false; + } + // We need to find the permissions of the parent folder that exists and inherit that. $target_parent = dirname( $target ); while ( '.' != $target_parent && ! is_dir( $target_parent ) && dirname( $target_parent ) !== $target_parent ) {