Skip to content

Commit

Permalink
Merge pull request from GHSA-x525-54hf-xr53
Browse files Browse the repository at this point in the history
* do not log unvalidated user-input to mysql-log (if enabled)

Signed-off-by: Michael Kaufmann <[email protected]>

* clean log-text to only allow a subset of special characters

Signed-off-by: Michael Kaufmann <[email protected]>

* clean log-text when selecting from database to avoid possible previously added malicious entries

Signed-off-by: Michael Kaufmann <[email protected]>

---------

Signed-off-by: Michael Kaufmann <[email protected]>
  • Loading branch information
d00p authored May 3, 2024
1 parent 7f8b36e commit 1b44ee2
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
6 changes: 3 additions & 3 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@
$rstlog = FroxlorLogger::getInstanceOf([
'loginname' => $_SERVER['REMOTE_ADDR']
]);
$rstlog->logAction(FroxlorLogger::LOGIN_ACTION, LOG_WARNING, "Unknown user '" . $loginname . "' tried to login.");
$rstlog->logAction(FroxlorLogger::LOGIN_ACTION, LOG_WARNING, "Unknown user tried to login.");

Response::redirectTo('index.php', [
'showmessage' => '2'
Expand Down Expand Up @@ -334,7 +334,7 @@
$rstlog = FroxlorLogger::getInstanceOf([
'loginname' => $_SERVER['REMOTE_ADDR']
]);
$rstlog->logAction(FroxlorLogger::LOGIN_ACTION, LOG_WARNING, "User '" . $loginname . "' tried to login with wrong password.");
$rstlog->logAction(FroxlorLogger::LOGIN_ACTION, LOG_WARNING, "User tried to login with wrong password.");

unset($userinfo);
Response::redirectTo('index.php', [
Expand Down Expand Up @@ -653,7 +653,7 @@
$rstlog = FroxlorLogger::getInstanceOf([
'loginname' => 'password_reset'
]);
$rstlog->logAction(FroxlorLogger::USR_ACTION, LOG_WARNING, "User '" . $loginname . "' requested to set a new password, but was not found in database!");
$rstlog->logAction(FroxlorLogger::USR_ACTION, LOG_WARNING, "Unknown user requested to set a new password, but was not found in database!");
$message = lng('login.usernotfound');
}

Expand Down
2 changes: 2 additions & 0 deletions lib/Froxlor/Api/Commands/SysLog.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ public function listing()
}
Database::pexecute($result_stmt, $query_fields, true, true);
while ($row = $result_stmt->fetch(PDO::FETCH_ASSOC)) {
// clean log-text
$row['text'] = preg_replace("/[^\w @#\"':.()\[\]+\-_\/\\\!]/i", "_", $row['text']);
$result[] = $row;
}
$this->logger()->logAction($this->isAdmin() ? FroxlorLogger::ADM_ACTION : FroxlorLogger::USR_ACTION, LOG_INFO, "[API] list log-entries");
Expand Down
3 changes: 3 additions & 0 deletions lib/Froxlor/FroxlorLogger.php
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,9 @@ public function logAction($action = FroxlorLogger::USR_ACTION, int $type = LOG_N
$this->initMonolog();
}

// clean log-text
$text = preg_replace("/[^\w @#\"':.()\[\]+\-_\/\\\!]/i", "_", $text);

if (self::$crondebug_flag || ($action == FroxlorLogger::CRON_ACTION && $type <= LOG_WARNING)) {
echo "[" . $this->getLogLevelDesc($type) . "] " . $text . PHP_EOL;
}
Expand Down

0 comments on commit 1b44ee2

Please sign in to comment.