Merge pull request from GHSA-x525-54hf-xr53
* do not log unvalidated user-input to mysql-log (if enabled) Signed-off-by: Michael Kaufmann <d00p@froxlor.org> * clean log-text to only allow a subset of special characters Signed-off-by: Michael Kaufmann <d00p@froxlor.org> * clean log-text when selecting from database to avoid possible previously added malicious entries Signed-off-by: Michael Kaufmann <d00p@froxlor.org> --------- Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
This commit is contained in:
@@ -90,6 +90,8 @@ class SysLog extends ApiCommand implements ResourceEntity
|
||||
}
|
||||
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");
|
||||
|
||||
@@ -175,6 +175,9 @@ class FroxlorLogger
|
||||
$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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user