Skip to content

Commit c913245

Browse files
jaapmarcusScIT-Raphael
authored andcommitted
Update /login/ to enforce security token for loginas (hestiacp#1456)
* Update /login/ to enforce security token for loginas * Added missing Security token * Fix issue with Exit FM
1 parent 1503797 commit c913245

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

web/add/user/index.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@
105105
// Flush field values on success
106106
if (empty($_SESSION['error_msg'])) {
107107
$_SESSION['ok_msg'] = sprintf(_('USER_CREATED_OK'),htmlentities($_POST['v_username']),htmlentities($_POST['v_username']));
108-
$_SESSION['ok_msg'] .= " / <a href=/login/?loginas=".htmlentities($_POST['v_username']).">" . _('login as') ." ".htmlentities($_POST['v_username']). "</a>";
108+
$_SESSION['ok_msg'] .= " / <a href=/login/?loginas=".htmlentities($_POST['v_username'])."&token=".htmlentities($_SESSION['token']).">" . _('login as') ." ".htmlentities($_POST['v_username']). "</a>";
109109
unset($v_username);
110110
unset($v_password);
111111
unset($v_email);

web/login/index.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@
1616

1717
// Login as someone else
1818
if (isset($_SESSION['user'])) {
19+
if (empty($_GET['loginas']) ){
20+
header("Location: /list/web/");
21+
exit;
22+
}
1923
if ($_SESSION['user'] == 'admin' && !empty($_GET['loginas'])) {
2024
exec (HESTIA_CMD . "v-list-user ".escapeshellarg($_GET['loginas'])." json", $output, $return_var);
2125
if ( $return_var == 0 ) {
@@ -34,6 +38,7 @@
3438
}
3539

3640
function authenticate_user($user, $password, $twofa = ''){
41+
unset($_SESSION['login']);
3742
if(isset($_SESSION['token']) && isset($_POST['token']) && $_POST['token'] == $_SESSION['token']) {
3843
$v_user = escapeshellarg($user);
3944
$v_ip = escapeshellarg($_SERVER['REMOTE_ADDR']);

web/logout/index.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
<?php
2-
32
session_start();
43

54
if (!empty($_SESSION['look'])) {
5+
66
unset($_SESSION['look']);
7+
header("Location: /");
78
} else {
89
session_destroy();
10+
header("Location: /login/");
911
}
10-
11-
header("Location: /login/");
1212
exit;
1313
?>

0 commit comments

Comments
 (0)