Introduce detaintPathAllowAbsolute. Use it to protect against Path Traversal in files view. Fixes GHSA-8fw2-wh82-vv4h
parent
7aabf146ba
commit
3b379e99c0
|
@ -1884,6 +1884,16 @@ function generateConnKey() {
|
|||
return rand(1, 999999);
|
||||
}
|
||||
|
||||
function detaintPathAllowAbsolute($path) {
|
||||
// Strip out :// because php:// is a way to inject code apparently
|
||||
$path = str_replace('://', '', $path);
|
||||
// Remove any absolute paths, or relative ones that want to go up
|
||||
do {
|
||||
$path = str_replace('../', '', $path, $count);
|
||||
} while($count);
|
||||
return $path;
|
||||
}
|
||||
|
||||
function detaintPath($path) {
|
||||
|
||||
// Strip out :// because php:// is a way to inject code apparently
|
||||
|
|
|
@ -23,7 +23,7 @@ if (!canView('Events')) {
|
|||
return;
|
||||
}
|
||||
|
||||
$path = (!empty($_REQUEST['path'])) ? $_REQUEST['path'] : ZM_DIR_EVENTS;
|
||||
$path = (!empty($_REQUEST['path'])) ? detaintPathAllowAbsolute($_REQUEST['path']) : ZM_DIR_EVENTS;
|
||||
$is_ok_path = false;
|
||||
foreach (ZM\Storage::find() as $storage) {
|
||||
$rc = strstr($path, $storage->Path(), true);
|
||||
|
|
Loading…
Reference in New Issue