Object injection in PHPMailer/PHPMailer
Published 4 May 2021 · Updated 21 Jul 2026
Affected package
- Affected
- >=6.1.8 <6.4.1
- Fixed in
- 6.4.1
composer require phpmailer/phpmailer:^6.4.1Details
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 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()` 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, reported and managed via Tidelift.
Is GHSA-m298-fh5c-jc66 in any of your client repos?
Checking one package by hand is fine. Checking it across forty client projects is not. NPMscan reads the lockfiles in every GitHub repo you pick, finds each project with an affected phpmailer/phpmailer, and gives you the command that fixes it.
References
- Linkgithub.com/PHPMailer/PHPMailer/security/advisories/GHSA-m298-fh5c-jc66
- Advisorynvd.nist.gov/vuln/detail/CVE-2020-36326
- Linkgithub.com/PHPMailer/PHPMailer/commit/e2e07a355ee8ff36aba21d0242c5950c56e4c6f9
- Linkgithub.com/FriendsOfPHP/security-advisories/blob/master/phpmailer/phpmailer/CVE-2020-36326.yaml
- Packagegithub.com/PHPMailer/PHPMailer
- Linkgithub.com/PHPMailer/PHPMailer/releases/tag/v6.4.1
- Linklists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/3B5WDPGUFNPG4NAZ6G4BZX43BKLAVA5B
- Linklists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/KPU66INRFY5BQ3ESVPRUXJR4DXQAFJVT
Advisory data from OSV.dev (opens OSV.dev in a new tab), refreshed daily.