mirror of
https://github.com/itflow-org/itflow
synced 2026-12-05 18:49:01 +00:00
Security: end a user's other sessions when their password changes - each session carries a stamp of the password it signed in with and the agent and client portal checks sign out any that no longer match, covering a self change, an admin setting it, the incident-response reset, portal reset links and invites, and View as contact; a portal self change keeps the browser that made it on a new session id
This commit is contained in:
@@ -8,7 +8,7 @@ $sql = mysqli_query(
|
||||
$mysqli,
|
||||
"SELECT role_is_admin, role_name, user_archived_at, user_avatar, user_config_force_mfa,
|
||||
user_config_records_per_page, user_config_theme_dark, user_email, user_name, user_role_id,
|
||||
user_status, user_token, user_type FROM users
|
||||
user_password, user_status, user_token, user_type FROM users
|
||||
LEFT JOIN user_settings ON users.user_id = user_settings.user_id
|
||||
LEFT JOIN user_roles ON user_role_id = role_id
|
||||
WHERE users.user_id = $session_user_id"
|
||||
@@ -16,6 +16,11 @@ $sql = mysqli_query(
|
||||
|
||||
$row = mysqli_fetch_assoc($sql);
|
||||
|
||||
$session_stamp_current = userSessionStamp($row['user_password'] ?? '');
|
||||
if ($row) {
|
||||
unset($row['user_password']);
|
||||
}
|
||||
|
||||
$session_name = escapeSql($row['user_name']);
|
||||
$session_email = $row['user_email'];
|
||||
$session_avatar = $row['user_avatar'];
|
||||
@@ -51,6 +56,14 @@ if ($session_user_archived_at !== null) {
|
||||
redirect("/login.php");
|
||||
}
|
||||
|
||||
// Check the password hasn't changed since this session signed in - by them elsewhere,
|
||||
// an admin, or the incident-response reset (userSessionStamp())
|
||||
if (!hash_equals($session_stamp_current, (string) ($_SESSION['user_session_stamp'] ?? ''))) {
|
||||
session_unset();
|
||||
session_destroy();
|
||||
redirect("/login.php");
|
||||
}
|
||||
|
||||
// Load user client permissions (allow + deny lists)
|
||||
$user_client_access_sql = "SELECT client_id, permission_type FROM user_client_permissions WHERE user_id = $session_user_id";
|
||||
$user_client_access_result = mysqli_query($mysqli, $user_client_access_sql);
|
||||
|
||||
Reference in New Issue
Block a user