VDB
KO
CRITICAL 9.8

GHSA-m298-fh5c-jc66

Object injection in PHPMailer/PHPMailer

Quick fix

GHSA-m298-fh5c-jc66 — phpmailer/phpmailer: upgrade to the fixed version with the command below.

composer require phpmailer/phpmailer:^6.4.1

Details

### Impact This is a reintroduction of an earlier issue (CVE-2018-19296) by an unrelated bug fix in PHPMailer 6.1.8. An external file may be unexpectedly executable if it is used as a path to an attachment file via PHP's support for `.phar` files. Exploitation requires that an attacker is able to provide an unfiltered path to a file to attach, or to trick calling code into generating one. See [this article](https://knasmueller.net/5-answers-about-php-phar-exploitation) for more info.

### Patches This issue was patched in the PHPMailer 6.4.1 release. This release also implements stricter filtering for attachment paths; paths that look like *any* kind of URL are rejected.

### Workarounds Validate paths to loaded files using the same pattern as used in [`isPermittedPath()`](https://github.com/PHPMailer/PHPMailer/blob/master/src/PHPMailer.php#L1815) before using them in *any* PHP file function, such as `file_exists`. This method can't be used directly because it is protected, but you can implement the same thing in calling code. Note that this should be applied to *all* user-supplied paths passed into such functions; it's not a problem specific to PHPMailer.

### Credit This issue was found by [Fariskhi Vidyan](https://github.com/farisv), reported and managed via Tidelift.

Are you affected?

Enter the version of the package you're using.

Affected packages

Packagist / phpmailer/phpmailer
Introduced in: 6.1.8 Fixed in: 6.4.1
Fix composer require phpmailer/phpmailer:^6.4.1

References