Skip to content

Commit dd2a57e

Browse files
author
Serghey Rodin
committed
Vesta CP 0.9.8–20 rXSS to RCE / solves hestiacp#1558
1 parent 2cb01e0 commit dd2a57e

File tree

2 files changed

+6
-31
lines changed

2 files changed

+6
-31
lines changed

web/upload/UploadHandler.php

Lines changed: 5 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1117,37 +1117,12 @@ protected function handle_file_upload($uploaded_file, $name, $size, $type, $erro
11171117
$append_file = $content_range && is_file($file_path) &&
11181118
$file->size > $this->get_file_size($file_path);
11191119
if ($uploaded_file && is_uploaded_file($uploaded_file)) {
1120-
// multipart/formdata uploads (POST method uploads)
1121-
if ($append_file) {
1122-
file_put_contents(
1123-
$file_path,
1124-
fopen($uploaded_file, 'r'),
1125-
FILE_APPEND
1126-
);
1127-
} else {
1128-
chmod($uploaded_file, 0644);
1129-
// move_uploaded_file($uploaded_file, $file_path);
1130-
exec (VESTA_CMD . "v-copy-fs-file ". USERNAME ." {$uploaded_file} '{$file_path}'", $output, $return_var);
1131-
1132-
$error = check_return_code($return_var, $output);
1133-
if ($return_var != 0) {
1134-
//var_dump(VESTA_CMD . "v-copy-fs-file {$user} {$fn} {$path}");
1135-
//var_dump($path);
1136-
//var_dump($output);
1137-
$file->error = 'Error while saving file ';
1138-
// var_dump(VESTA_CMD . "v-copy-fs-file ". USERNAME ." {$uploaded_file} {$file_path}");
1139-
// var_dump($return_var);
1140-
// var_dump($output);
1141-
// exit();
1142-
}
1120+
chmod($uploaded_file, 0644);
1121+
exec (VESTA_CMD . "v-copy-fs-file ". USERNAME ." {$uploaded_file} '{$file_path}'", $output, $return_var);
1122+
$error = check_return_code($return_var, $output);
1123+
if ($return_var != 0) {
1124+
$file->error = 'Error while saving file ';
11431125
}
1144-
} else {
1145-
// Non-multipart uploads (PUT method support)
1146-
file_put_contents(
1147-
$file_path,
1148-
fopen('php://input', 'r'),
1149-
$append_file ? FILE_APPEND : 0
1150-
);
11511126
}
11521127
$file_size = $this->get_file_size($file_path, $append_file);
11531128

web/view/file/index.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
$path = $_REQUEST['path'];
1717
if (!empty($_REQUEST['raw'])) {
1818
header('content-type: image/jpeg');
19-
passthru (VESTA_CMD . "v-open-fs-file " . $user . " " . escapeshellarg($_REQUEST['path']));
19+
passthru (VESTA_CMD . "v-open-fs-file " . $user . " " . escapeshellarg(htmlspecialchars($_REQUEST['path'], ENT_QUOTES, 'UTF-8')));
2020
exit;
2121
}
2222
}

0 commit comments

Comments
 (0)