From ec0d92bfac52e4af4cca393a5a17e5e45310ec08 Mon Sep 17 00:00:00 2001 From: the-djmaze <> Date: Tue, 20 Feb 2024 11:22:28 +0100 Subject: [PATCH] mask passphrases in logs for PHP < 8.2 --- .../0.0.0/app/libraries/RainLoop/Actions/Pgp.php | 16 ++++++++++------ .../app/libraries/RainLoop/Actions/SMime.php | 1 + 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/snappymail/v/0.0.0/app/libraries/RainLoop/Actions/Pgp.php b/snappymail/v/0.0.0/app/libraries/RainLoop/Actions/Pgp.php index 4389dc326..9643fd02b 100644 --- a/snappymail/v/0.0.0/app/libraries/RainLoop/Actions/Pgp.php +++ b/snappymail/v/0.0.0/app/libraries/RainLoop/Actions/Pgp.php @@ -113,10 +113,10 @@ trait Pgp return $this->FalseResponse(); } - $GPG->addDecryptKey( - $this->GetActionParam('keyId', ''), - $this->GetActionParam('passphrase', '') - ); + $sPassphrase = $this->GetActionParam('passphrase', ''); + $this->logMask($sPassphrase); + + $GPG->addDecryptKey($this->GetActionParam('keyId', ''), $sPassphrase); $sData = $this->GetActionParam('data', ''); $oPart = null; @@ -160,10 +160,12 @@ trait Pgp public function DoGnupgExportKey() : array { + $sPassphrase = $this->GetActionParam('passphrase', ''); + $this->logMask($sPassphrase); $GPG = $this->GnuPG(); return $this->DefaultResponse($GPG ? $GPG->export( $this->GetActionParam('keyId', ''), - $this->GetActionParam('passphrase', '') + $sPassphrase ) : false); } @@ -174,9 +176,11 @@ trait Pgp if ($GPG) { $sName = $this->GetActionParam('name', ''); $sEmail = $this->GetActionParam('email', ''); + $sPassphrase = $this->GetActionParam('passphrase', ''); + $this->logMask($sPassphrase); $fingerprint = $GPG->generateKey( $sName ? "{$sName} <{$sEmail}>" : $sEmail, - $this->GetActionParam('passphrase', '') + $sPassphrase ); } return $this->DefaultResponse($fingerprint); diff --git a/snappymail/v/0.0.0/app/libraries/RainLoop/Actions/SMime.php b/snappymail/v/0.0.0/app/libraries/RainLoop/Actions/SMime.php index 2112c919f..bc57d77e7 100644 --- a/snappymail/v/0.0.0/app/libraries/RainLoop/Actions/SMime.php +++ b/snappymail/v/0.0.0/app/libraries/RainLoop/Actions/SMime.php @@ -62,6 +62,7 @@ trait SMime $sName = $this->GetActionParam('name', '') ?: $oAccount->Name(); $sEmail = $this->GetActionParam('email', '') ?: $oAccount->Email(); $sPassphrase = $this->GetActionParam('passphrase', ''); + $this->logMask($sPassphrase); $cert = new Certificate(); $cert->distinguishedName['commonName'] = $sName;