This commit is contained in:
Marcus Bointon 2021-06-10 22:31:30 +02:00
parent 4839207650
commit 8107a91852
No known key found for this signature in database
GPG Key ID: DE31CD6EB646AA24
8 changed files with 65 additions and 20 deletions

View File

@ -2,6 +2,11 @@
Please disclose any security issues or vulnerabilities found through [Tidelift's coordinated disclosure system](https://tidelift.com/security) or to the maintainers privately. Please disclose any security issues or vulnerabilities found through [Tidelift's coordinated disclosure system](https://tidelift.com/security) or to the maintainers privately.
PHPMailer 6.4.1 contains a possible remote code execution vulnerability through the `$lang_path` parameter of the `setLanguage()` method. If the `$lang_path` parameter is passed unfiltered from user input, it can be set to [a UNC path](https://docs.microsoft.com/en-us/dotnet/standard/io/file-path-formats#unc-paths), and if an attacker is also able to create a remote mount on the server that the UNC path points to, a script file under their control may be executed. This vulnerability only applies to systems that resolve UNC paths, typically only Microsoft Windows. Recorded as [CVE-2021-34551](https://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2021-34551). Reported by [listensec.com](https://listensec.com) via Tidelift.
PHPMailer 6.5.0 mitigates this by no longer treating translation files as PHP code, but by parsing their text content directly.
This approach avoids the possibility of executing unknown code while retaining backward compatibility. This isn't ideal, so the current translation format is deprecated and will be replaced in the next major release.
PHPMailer versions between 6.1.8 and 6.4.0 contain a regression of the earlier CVE-2018-19296 object injection vulnerability as a result of [a fix for Windows UNC paths in 6.1.8](https://github.com/PHPMailer/PHPMailer/commit/e2e07a355ee8ff36aba21d0242c5950c56e4c6f9). Recorded as [CVE-2020-36326](https://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2020-36326). Reported by Fariskhi Vidyan via Tidelift. 6.4.1 fixes this issue, and also enforces stricter checks for URL schemes in local path contexts. PHPMailer versions between 6.1.8 and 6.4.0 contain a regression of the earlier CVE-2018-19296 object injection vulnerability as a result of [a fix for Windows UNC paths in 6.1.8](https://github.com/PHPMailer/PHPMailer/commit/e2e07a355ee8ff36aba21d0242c5950c56e4c6f9). Recorded as [CVE-2020-36326](https://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2020-36326). Reported by Fariskhi Vidyan via Tidelift. 6.4.1 fixes this issue, and also enforces stricter checks for URL schemes in local path contexts.
PHPMailer versions 6.1.5 and earlier contain an output escaping bug that occurs in `Content-Type` and `Content-Disposition` when filenames passed into `addAttachment` and other methods that accept attachment names contain double quote characters, in contravention of RFC822 3.4.1. No specific vulnerability has been found relating to this, but it could allow file attachments to bypass attachment filters that are based on matching filename extensions. Recorded as [CVE-2020-13625](https://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2020-13625). Reported by Elar Lang of Clarified Security. PHPMailer versions 6.1.5 and earlier contain an output escaping bug that occurs in `Content-Type` and `Content-Disposition` when filenames passed into `addAttachment` and other methods that accept attachment names contain double quote characters, in contravention of RFC822 3.4.1. No specific vulnerability has been found relating to this, but it could allow file attachments to bypass attachment filters that are based on matching filename extensions. Recorded as [CVE-2020-13625](https://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2020-13625). Reported by Elar Lang of Clarified Security.

View File

@ -1 +1 @@
6.4.1 6.5.0

View File

@ -1,5 +1,9 @@
# PHPMailer Change Log # PHPMailer Change Log
## Version 6.5.0 (June 11th, 2021)
* **SECURITY** Fixes CVE-2021-34551, a complex RCE affecting Windows hosts.
* *Deprecation* The translation file format currently used (PHP arrays) is now deprecated; the next major version will introduce a new format.
## Version 6.4.1 (April 29th, 2021) ## Version 6.4.1 (April 29th, 2021)
* **SECURITY** Fixes CVE-2020-36326, a regression of CVE-2018-19296 object injection introduced in 6.1.8, see SECURITY.md for details * **SECURITY** Fixes CVE-2020-36326, a regression of CVE-2018-19296 object injection introduced in 6.1.8, see SECURITY.md for details
* Reject more file paths that look like URLs, matching RFC3986 spec, blocking URLS using schemes such as `ssh2` * Reject more file paths that look like URLs, matching RFC3986 spec, blocking URLS using schemes such as `ssh2`

View File

@ -19,8 +19,7 @@ $PHPMAILER_LANG['instantiate'] = 'لا يمكن توفير خدمة ا
$PHPMAILER_LANG['invalid_address'] = 'الإرسال غير ممكن لأن عنوان البريد الإلكتروني غير صالح: '; $PHPMAILER_LANG['invalid_address'] = 'الإرسال غير ممكن لأن عنوان البريد الإلكتروني غير صالح: ';
$PHPMAILER_LANG['mailer_not_supported'] = ' برنامج الإرسال غير مدعوم.'; $PHPMAILER_LANG['mailer_not_supported'] = ' برنامج الإرسال غير مدعوم.';
$PHPMAILER_LANG['provide_address'] = 'يجب توفير عنوان البريد الإلكتروني لمستلم واحد على الأقل.'; $PHPMAILER_LANG['provide_address'] = 'يجب توفير عنوان البريد الإلكتروني لمستلم واحد على الأقل.';
$PHPMAILER_LANG['recipients_failed'] = 'خطأ SMTP: الأخطاء التالية ' . $PHPMAILER_LANG['recipients_failed'] = 'خطأ SMTP: الأخطاء التالية فشل في الارسال لكل من : ';
'فشل في الارسال لكل من : ';
$PHPMAILER_LANG['signing'] = 'خطأ في التوقيع: '; $PHPMAILER_LANG['signing'] = 'خطأ في التوقيع: ';
$PHPMAILER_LANG['smtp_connect_failed'] = 'SMTP Connect() غير ممكن.'; $PHPMAILER_LANG['smtp_connect_failed'] = 'SMTP Connect() غير ممكن.';
$PHPMAILER_LANG['smtp_error'] = 'خطأ على مستوى الخادم SMTP: '; $PHPMAILER_LANG['smtp_error'] = 'خطأ على مستوى الخادم SMTP: ';

View File

@ -750,7 +750,7 @@ class PHPMailer
* *
* @var string * @var string
*/ */
const VERSION = '6.4.1'; const VERSION = '6.5.0';
/** /**
* Error severity: message only, continue processing. * Error severity: message only, continue processing.
@ -2246,14 +2246,32 @@ class PHPMailer
if (!static::fileIsAccessible($lang_file)) { if (!static::fileIsAccessible($lang_file)) {
$foundlang = false; $foundlang = false;
} else { } else {
//Overwrite language-specific strings. //$foundlang = include $lang_file;
//This way we'll never have missing translation keys. $lines = file($lang_file);
$foundlang = include $lang_file; foreach ($lines as $line) {
//Translation file lines look like this:
//$PHPMAILER_LANG['authenticate'] = 'SMTP-Fehler: Authentifizierung fehlgeschlagen.';
//These files are parsed as text and not PHP so as to avoid the possibility of code injection
//See https://blog.stevenlevithan.com/archives/match-quoted-string
$matches = [];
if (
preg_match(
'/^\$PHPMAILER_LANG\[\'([a-z\d_]+)\'\]\s*=\s*(["\'])(.+)*?\2;/',
$line,
$matches
) &&
//Ignore unknown translation keys
array_key_exists($matches[1], $PHPMAILER_LANG)
) {
//Overwrite language-specific strings so we'll never have missing translation keys.
$PHPMAILER_LANG[$matches[1]] = (string)$matches[3];
}
}
} }
} }
$this->language = $PHPMAILER_LANG; $this->language = $PHPMAILER_LANG;
return (bool) $foundlang; //Returns false if language not found return $foundlang; //Returns false if language not found
} }
/** /**

View File

@ -46,7 +46,7 @@ class POP3
* *
* @var string * @var string
*/ */
const VERSION = '6.4.1'; const VERSION = '6.5.0';
/** /**
* Default POP3 port number. * Default POP3 port number.

View File

@ -35,7 +35,7 @@ class SMTP
* *
* @var string * @var string
*/ */
const VERSION = '6.4.1'; const VERSION = '6.5.0';
/** /**
* SMTP line break constant. * SMTP line break constant.

View File

@ -39,7 +39,7 @@ final class PHPMailerLangTest extends TestCase
/** /**
* Test language files for missing and excess translations. * Test language files for missing and excess translations.
* All languages are compared with English. * All languages are compared with English, which is built-in.
* *
* @group languages * @group languages
*/ */
@ -57,17 +57,36 @@ final class PHPMailerLangTest extends TestCase
if (preg_match('/^phpmailer\.lang-([a-z_]{2,})\.php$/', $fileInfo->getFilename(), $matches)) { if (preg_match('/^phpmailer\.lang-([a-z_]{2,})\.php$/', $fileInfo->getFilename(), $matches)) {
$lang = $matches[1]; //Extract language code $lang = $matches[1]; //Extract language code
$PHPMAILER_LANG = []; //Language strings get put in here $PHPMAILER_LANG = []; //Language strings get put in here
include $fileInfo->getPathname(); //Get language strings $lines = file($fileInfo->getPathname());
$missing = array_diff(array_keys($definedStrings), array_keys($PHPMAILER_LANG)); foreach ($lines as $line) {
$extra = array_diff(array_keys($PHPMAILER_LANG), array_keys($definedStrings)); //Translation file lines look like this:
if (!empty($missing)) { //$PHPMAILER_LANG['authenticate'] = 'SMTP-Fehler: Authentifizierung fehlgeschlagen.';
$err .= "\nMissing translations in $lang: " . implode(', ', $missing); //These files are parsed as text and not PHP so as to avoid the possibility of code injection
} $matches = [];
if (!empty($extra)) { if (
$err .= "\nExtra translations in $lang: " . implode(', ', $extra); preg_match(
'/^\$PHPMAILER_LANG\[\'([a-z\d_]+)\'\]\s*=\s*(["\'])(.+)*?\2;/',
$line,
$matches
)
) {
//Overwrite language-specific strings so we'll never have missing translation keys.
$PHPMAILER_LANG[$matches[1]] = (string)$matches[3];
}
} }
} }
include $fileInfo->getPathname(); //Get language strings
$missing = array_diff(array_keys($definedStrings), array_keys($PHPMAILER_LANG));
$extra = array_diff(array_keys($PHPMAILER_LANG), array_keys($definedStrings));
if (!empty($missing)) {
$err .= "\nMissing translations in $lang: " . implode(', ', $missing);
}
if (!empty($extra)) {
$err .= "\nExtra translations in $lang: " . implode(', ', $extra);
}
} }
$this->assertEmpty($err, $err); //If we have no extra and no missing translations, $err will be empty
self::assertEmpty($err, $err);
} }
} }