Skip to content

Commit 52f2f62

Browse files
authored
Merge pull request hestiacp#2152 from jaapmarcus/fix/missed-csrf-checks
Fix Multiple missed csrf checks + update translations
2 parents c223dbd + d604ac6 commit 52f2f62

File tree

9 files changed

+15
-29
lines changed

9 files changed

+15
-29
lines changed

web/bulk/web/index.php

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
<?php
2+
23
// Init
3-
error_reporting(NULL);
4+
error_reporting(null);
45
ob_start();
56
session_start();
67

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

910
// Check token
10-
if ((!isset($_POST['token'])) || ($_SESSION['token'] != $_POST['token'])) {
11-
header('location: /login/');
12-
exit();
13-
}
11+
verify_csrf($_POST);
1412

1513
$domain = $_POST['domain'];
1614
$action = $_POST['action'];
@@ -37,15 +35,15 @@
3735

3836
foreach ($domain as $value) {
3937
$value = escapeshellarg($value);
40-
exec (HESTIA_CMD.$cmd." ".$user." ".$value." no", $output, $return_var);
38+
exec(HESTIA_CMD.$cmd." ".$user." ".$value." no", $output, $return_var);
4139
$restart='yes';
4240
}
4341

4442
if (isset($restart)) {
45-
exec (HESTIA_CMD."v-restart-web", $output, $return_var);
46-
exec (HESTIA_CMD."v-restart-proxy", $output, $return_var);
47-
exec (HESTIA_CMD."v-restart-dns", $output, $return_var);
48-
exec (HESTIA_CMD."v-restart-web-backend", $output, $return_var);
43+
exec(HESTIA_CMD."v-restart-web", $output, $return_var);
44+
exec(HESTIA_CMD."v-restart-proxy", $output, $return_var);
45+
exec(HESTIA_CMD."v-restart-dns", $output, $return_var);
46+
exec(HESTIA_CMD."v-restart-web-backend", $output, $return_var);
4947
}
5048

5149
header("Location: /list/web/");

web/edit/dns/index.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -150,10 +150,7 @@
150150
if ((!empty($_POST['save'])) && (!empty($_GET['domain'])) && (!empty($_GET['record_id']))) {
151151

152152
// Check token
153-
if ((!isset($_POST['token'])) || ($_SESSION['token'] != $_POST['token'])) {
154-
header('location: /login/');
155-
exit();
156-
}
153+
verify_csrf($_POST);
157154

158155
// Protect input
159156
$v_domain = escapeshellarg($_POST['v_domain']);

web/edit/user/index.php

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,8 @@
2929
exit;
3030
}
3131

32-
// Ensure token is passed before loading page
33-
if ((!$_GET['token']) || ($_SESSION['token'] != $_GET['token'])) {
34-
header('location: /login/');
35-
exit();
36-
}
32+
// Check token
33+
verify_csrf($_GET);
3734

3835
// List user
3936
exec(HESTIA_CMD."v-list-user ".escapeshellarg($v_username)." json", $output, $return_var);
@@ -111,10 +108,6 @@
111108
$php_versions = json_decode(implode('', $output), true);
112109
unset($output);
113110

114-
115-
116-
// Are you admin?
117-
118111
// Check POST request
119112
if (!empty($_POST['save'])) {
120113

web/list/log/index.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?php
2-
error_reporting(NULL);
2+
3+
error_reporting(null);
34
if ($_GET['user'] === 'system') {
45
$TAB = 'SERVER';
56
} else {
@@ -18,14 +19,11 @@
1819
// Data
1920
if (($_SESSION['userContext'] === "admin") && (!empty($_GET['user']))) {
2021
// Check token
21-
if ((!isset($_GET['token'])) || ($_SESSION['token'] != $_GET['token'])) {
22-
header('location: /login/');
23-
exit();
24-
}
22+
verify_csrf($_GET);
2523
$user=escapeshellarg($_GET['user']);
2624
}
2725

28-
exec (HESTIA_CMD."v-list-user-log $user json", $output, $return_var);
26+
exec(HESTIA_CMD."v-list-user-log $user json", $output, $return_var);
2927
check_error($return_var);
3028
$data = json_decode(implode('', $output), true);
3129
$data = array_reverse($data);
1 Byte
Binary file not shown.
1.39 KB
Binary file not shown.
861 Bytes
Binary file not shown.
885 Bytes
Binary file not shown.
862 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)