From ce55237b3fd5ebc3ce5c39f7e65aba69eabbb2ae Mon Sep 17 00:00:00 2001 From: David Goodwin Date: Fri, 20 Nov 2026 09:10:22 +0000 Subject: [PATCH] if an exception occurs when calling Login::login(...), avoid logging the password in an error log, thanks @vibpe From Peter's email : "On the postfixadmin_4.0 branch, Login::login() logs the complete exception, including its stack trace, when pacrypt() throws. A PHP stack trace contains the call arguments (strings cut to 15 characters) unless zend.exception_ignore_args is on, so the frame Login->login($username, $password) puts the typed password into the web server error log. With a salted dovecot: scheme this happens in normal operation, on every failed login: doveadm pw -t exits non-zero for a wrong password and for the dummy pacrypt('abc', 'def') call, and _pacrypt_dovecot() turns that into an exception." --- model/Login.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/model/Login.php b/model/Login.php index 76dd3beb..0ed98bd7 100644 --- a/model/Login.php +++ b/model/Login.php @@ -20,7 +20,10 @@ class Login * Attempt to log a user in. * @return boolean true on successful login (i.e. password matches etc) */ - public function login(string $username, string $password): bool + public function login( + string $username, + #[\SensitiveParameter] + string $password): bool { $active = db_get_boolean(true); $query = "SELECT password FROM {$this->key_table} WHERE username = :username AND active = :active"; @@ -36,7 +39,7 @@ class Login $crypt_password = pacrypt($password, $row['password'], $username); } catch (\Exception $e) { error_log("Error while trying to call pacrypt()"); - error_log("" . $e); + error_log("" . $e->getMessage()); hash_equals("not", "comparable"); return false; // just refuse to login? }