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."
This commit is contained in:
David Goodwin committed 2026-11-20 09:19:54 +00:00
1 parent 0ba30e3d69
commit ce55237b3f
1 file changed
+5 -2
+5 -2
View File
@@ -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?
}