From 042c5e5791217f7da6879cebb5df7d37efe0ff6e Mon Sep 17 00:00:00 2001 From: David <44263817+mozkomor05@users.noreply.github.com> Date: Wed, 2 Nov 2022 07:56:00 +0100 Subject: [PATCH] Regex with optional capture groups might cause catastrophic backtracking (#2490) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix catastrophic backtracking * prevented catasthropic backtracing Co-authored-by: David Moškoř --- application/Espo/Core/Api/ErrorOutput.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/application/Espo/Core/Api/ErrorOutput.php b/application/Espo/Core/Api/ErrorOutput.php index 802dcde456..d7fcaef0d6 100644 --- a/application/Espo/Core/Api/ErrorOutput.php +++ b/application/Espo/Core/Api/ErrorOutput.php @@ -215,8 +215,7 @@ class ErrorOutput private function clearPasswords(string $string): string { - /** @var string */ - return preg_replace('/"(.*?password.*?)":".*?"/i', '"$1":"*****"', $string); + return preg_replace('/"(.*password.*)":".*"/i', '"$1":"*****"', $string) ?? $string; } private static function generateErrorBody(string $header, string $text): string