Filesystem API: Prevent directory travelersals when creating new folders.
Reject file paths that contain sub-directory paths. Props iandunn, xknown, sstoqnov, whyisjake. Built from https://develop.svn.wordpress.org/trunk@46476 git-svn-id: http://core.svn.wordpress.org/trunk@46274 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
608d39faed
commit
2524ba3aec
|
@ -1923,6 +1923,11 @@ function wp_mkdir_p( $target ) {
|
||||||
return @is_dir( $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.
|
// We need to find the permissions of the parent folder that exists and inherit that.
|
||||||
$target_parent = dirname( $target );
|
$target_parent = dirname( $target );
|
||||||
while ( '.' != $target_parent && ! is_dir( $target_parent ) && dirname( $target_parent ) !== $target_parent ) {
|
while ( '.' != $target_parent && ! is_dir( $target_parent ) && dirname( $target_parent ) !== $target_parent ) {
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '5.3-beta3-46475';
|
$wp_version = '5.3-beta3-46476';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||||
|
|
Loading…
Reference in New Issue