Skip to content

Commit ec2910f

Browse files
committed
webui add missing token validation
(cherry picked from commit 0879588)
1 parent d294015 commit ec2910f

File tree

13 files changed

+74
-6
lines changed

13 files changed

+74
-6
lines changed

web/bulk/backup/exclusions/index.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@
99
$backup = $_POST['system'];
1010
$action = $_POST['action'];
1111

12+
// Check token
13+
if ((!isset($_POST['token'])) || ($_SESSION['token'] != $_POST['token'])) {
14+
header('Location: /login/');
15+
exit();
16+
}
17+
1218
switch ($action) {
1319
case 'delete': $cmd='v-delete-user-backup-exclusions';
1420
break;

web/delete/backup/exclusion/index.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@
99
$user=$_GET['user'];
1010
}
1111

12+
// Check token
13+
if ((!isset($_GET['token'])) || ($_SESSION['token'] != $_GET['token'])) {
14+
header('Location: /login/');
15+
exit();
16+
}
17+
1218
if (!empty($_GET['system'])) {
1319
$v_username = escapeshellarg($user);
1420
$v_system = escapeshellarg($_GET['system']);

web/download/web-log/index.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,3 @@
2424
echo $file . "\n";
2525
}
2626
}
27-
28-
?>

web/edit/file/index.php

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,20 @@
2929
$content = '';
3030
$path = $_REQUEST['path'];
3131
if (!empty($_POST['save'])) {
32+
33+
// Check token
34+
if ((!isset($_POST['token'])) || ($_SESSION['token'] != $_POST['token'])) {
35+
header('Location: /login/');
36+
exit();
37+
}
38+
39+
exec (HESTIA_CMD . "v-open-fs-file ".escapeshellarg($user)." ".escapeshellarg($path), $devnull, $return_var);
40+
if ($return_var != 0) {
41+
print 'Error while opening file';
42+
exit;
43+
}
44+
$devnull=null;
45+
3246
$fn = tempnam ('/tmp', 'vst-save-file-');
3347
if ($fn) {
3448
$contents = $_POST['contents'];
@@ -39,7 +53,7 @@
3953
chmod($fn, 0644);
4054

4155
if ($f) {
42-
exec (HESTIA_CMD . "v-copy-fs-file {$user} {$fn} ".escapeshellarg($path), $output, $return_var);
56+
exec (HESTIA_CMD . "v-copy-fs-file ".escapeshellarg($user)." ".escapeshellarg($fn)." ".escapeshellarg($path), $output, $return_var);
4357
$error = check_return_code($return_var, $output);
4458
if ($return_var != 0) {
4559
print('<p style="color: white">Error while saving file</p>');
@@ -50,7 +64,7 @@
5064
}
5165
}
5266

53-
exec (HESTIA_CMD . "v-open-fs-file {$user} ".escapeshellarg($path), $content, $return_var);
67+
exec (HESTIA_CMD . "v-open-fs-file ".escapeshellarg($user)." ".escapeshellarg($path), $content, $return_var);
5468
if ($return_var != 0) {
5569
print 'Error while opening file'; // todo: handle this more styled
5670
exit;
@@ -64,6 +78,7 @@
6478
<form id="edit-file-form" method="post">
6579
<!-- input id="do-backup" type="button" onClick="javascript:void(0);" name="save" value="backup (ctrl+F2)" class="backup" / -->
6680
<input type="submit" name="save" value="Save" class="save" />
81+
<input type="hidden" name="token" value="<?=$_SESSION['token']?>" />
6782

6883

6984
<textarea name="contents" class="editor" id="editor" rows="4" style="display:none;width: 100%; height: 100%;"><?=htmlentities($content)?></textarea>

web/edit/ip/index.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,13 @@
5151

5252
// Check POST request
5353
if (!empty($_POST['save'])) {
54+
55+
// Check token
56+
if ((!isset($_POST['token'])) || ($_SESSION['token'] != $_POST['token'])) {
57+
header('Location: /login/');
58+
exit();
59+
}
60+
5461
$v_ip = escapeshellarg($_POST['v_ip']);
5562

5663
// Change Status

web/generate/ssl/index.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,12 @@
2727
exit;
2828
}
2929

30+
// Check token
31+
if ((!isset($_POST['token'])) || ($_SESSION['token'] != $_POST['token'])) {
32+
header('Location: /login/');
33+
exit();
34+
}
35+
3036
// Check input
3137
if (empty($_POST['v_domain'])) $errors[] = __('Domain');
3238
if (empty($_POST['v_country'])) $errors[] = __('Country');

web/restart/service/index.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@
55
session_start();
66
include($_SERVER['DOCUMENT_ROOT']."/inc/main.php");
77

8+
// Check token
9+
if ((!isset($_GET['token'])) || ($_SESSION['token'] != $_GET['token'])) {
10+
header('Location: /login/');
11+
exit();
12+
}
13+
814
if ($_SESSION['user'] == 'admin') {
915
if (!empty($_GET['srv'])) {
1016
if ($_GET['srv'] == 'iptables') {

web/schedule/backup/index.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@
55
session_start();
66
include($_SERVER['DOCUMENT_ROOT']."/inc/main.php");
77

8+
// Check token
9+
if ((!isset($_GET['token'])) || ($_SESSION['token'] != $_GET['token'])) {
10+
header('Location: /login/');
11+
exit();
12+
}
13+
814
$v_username = escapeshellarg($user);
915
exec (HESTIA_CMD."v-schedule-user-backup ".$v_username, $output, $return_var);
1016
if ($return_var == 0) {

web/schedule/restore/index.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@
66

77
include($_SERVER['DOCUMENT_ROOT']."/inc/main.php");
88

9+
// Check token
10+
if ((!isset($_GET['token'])) || ($_SESSION['token'] != $_GET['token'])) {
11+
header('Location: /login/');
12+
exit();
13+
}
14+
915
$backup = escapeshellarg($_GET['backup']);
1016

1117
$web = 'no';

web/start/service/index.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@
55
session_start();
66
include($_SERVER['DOCUMENT_ROOT']."/inc/main.php");
77

8+
// Check token
9+
if ((!isset($_GET['token'])) || ($_SESSION['token'] != $_GET['token'])) {
10+
header('Location: /login/');
11+
exit();
12+
}
13+
814
if ($_SESSION['user'] == 'admin') {
915
if (!empty($_GET['srv'])) {
1016
if ($_GET['srv'] == 'iptables') {

0 commit comments

Comments
 (0)