* upgradeModel: filter the fromPath variable to fix directory traversal vulnerablity.

This commit is contained in:
liugang
2024-04-08 15:10:57 +08:00
parent 2a6cd7a376
commit 9db68b3973
+6 -3
View File
@@ -5150,10 +5150,13 @@ class upgradeModel extends model
foreach($data->files as $file => $check)
{
$dirRoot = $customRoot . DS . dirname($file);
$fileName = basename($file);
if(!preg_match('/[a-z]/', $file[0])) continue;
$fromPath = $this->app->getModuleRoot() . $file;
$toPath = $dirRoot . DS . $fileName;
if(!is_file($fromPath)) continue;
$dirRoot = $customRoot . DS . dirname($file);
$toPath = $dirRoot . DS . basename($file);
/* If the directory doesn't exist and there is no permission to create the directory, set the response and return it. */
if(!is_dir($dirRoot))
{