[VD:LocalFileSystem] Security fixes, directory traversal vulnerability

fixes

This issue was found by Michał Majchrowicz & Livio Victoriano AFINE
Team. We give them a special thanks.
This commit is contained in:
nao-pon
2023-06-02 00:04:05 +09:00
parent db34731b94
commit bb9aaa7b09
@@ -373,9 +373,13 @@ class elFinderVolumeLocalFileSystem extends elFinderVolumeDriver
// realpath() returns FALSE if the file does not exist
if ($path === false || strpos($path, $this->root) !== 0) {
if (DIRECTORY_SEPARATOR !== '/') {
$dir = str_replace('/', DIRECTORY_SEPARATOR, $dir);
$name = str_replace('/', DIRECTORY_SEPARATOR, $name);
}
// Directory traversal measures
if (strpos($dir, '..' . DIRECTORY_SEPARATOR) !== false || substr($dir, -2) == '..') {
$dir = $this->root;
}
if (strpos($name, '..' . DIRECTORY_SEPARATOR) !== false) {
$name = basename($name);
}