Pleasediscloseanysecurityissuesorvulnerabilitiesfoundthrough[Tidelift'scoordinateddisclosuresystem](https://tidelift.com/security) or to the maintainers privately.
PHPMailer6.4.1andearliercontainavulnerabilitythatcanresultinuntrustedcodebeingcalled(ifsuchcodeisinjectedintothehostproject'sscopebyothermeans).Ifthe`$patternselect`parameterto`validateAddress()`issetto`'php'`(thedefault,definedby`PHPMailer::$validator`),andtheglobalnamespacecontainsafunctioncalled`php`,itwillbecalledinpreferencetothebuilt-invalidatorofthesamename.MitigatedinPHPMailer6.5.0bydenyingtheuseofsimplestringsasvalidatorfunctionnames.Recordedas[CVE-2021-3603](https://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2021-3603). Reported by [Vikrant Singh Chauhan](mailto:vi@hackberry.xyz) via [huntr.dev](https://www.huntr.dev/).
PHPMailerversions6.4.1andearliercontainapossibleremotecodeexecutionvulnerabilitythroughthe`$lang_path`parameterofthe`setLanguage()`method.Ifthe`$lang_path`parameterispassedunfilteredfromuserinput,itcanbesetto[aUNCpath](https://docs.microsoft.com/en-us/dotnet/standard/io/file-path-formats#unc-paths), and if an attacker is also able to persuade the server to load a file from that UNC path, a script file under their control may be executed. This vulnerability only applies to systems that resolve UNC paths, typically only Microsoft Windows.
PHPMailer6.5.0mitigatesthisbynolongertreatingtranslationfilesasPHPcode,butbyparsingtheirtextcontentdirectly.Thisapproachavoidsthepossibilityofexecutingunknowncodewhileretainingbackwardcompatibility.Thisisn'tideal,sothecurrenttranslationformatisdeprecatedandwillbereplacedinthenextmajorrelease.Recordedas[CVE-2021-34551](https://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2021-34551). Reported by [Jilin Diting Information Technology Co., Ltd](https://listensec.com) via Tidelift.
PHPMailerversionsbetween6.1.8and6.4.0containaregressionoftheearlierCVE-2018-19296objectinjectionvulnerabilityasaresultof[afixforWindowsUNCpathsin6.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.
PHPMailerversions6.1.5andearliercontainanoutputescapingbugthatoccursin`Content-Type`and`Content-Disposition`whenfilenamespassedinto`addAttachment`andothermethodsthatacceptattachmentnamescontaindoublequotecharacters,incontraventionofRFC8223.4.1.Nospecificvulnerabilityhasbeenfoundrelatingtothis,butitcouldallowfileattachmentstobypassattachmentfiltersthatarebasedonmatchingfilenameextensions.Recordedas[CVE-2020-13625](https://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2020-13625). Reported by Elar Lang of Clarified Security.
PHPMailerversionspriorto6.0.6and5.2.27arevulnerabletoanobjectinjectionattackbypassing`phar://` paths into `addAttachment()` and other functions that may receive unfiltered local paths, possibly leading to RCE. Recorded as [CVE-2018-19296](https://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2018-19296). See [this article](https://knasmueller.net/5-answers-about-php-phar-exploitation) for more info on this type of vulnerability. Mitigated by blocking the use of paths containing URL-protocol style prefixes such as `phar://`. Reported by Sehun Oh of cyberone.kr.
PHPMailerversionspriorto5.2.24(releasedJuly26th2017)haveanXSSvulnerabilityinoneofthecodeexamples,[CVE-2017-11503](https://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2017-11503). The `code_generator.phps` example did not filter user input prior to output. This file is distributed with a `.phps` extension, so it it not normally executable unless it is explicitly renamed, and the file is not included when PHPMailer is loaded through composer, so it is safe by default. There was also an undisclosed potential XSS vulnerability in the default exception handler (unused by default). Patches for both issues kindly provided by Patrick Monnerat of the Fedora Project.
PHPMailerversionspriorto5.2.22(releasedJanuary9th2017)havealocalfiledisclosurevulnerability,[CVE-2017-5223](https://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2017-5223). If content passed into `msgHTML()` is sourced from unfiltered user input, relative paths can map to absolute local file paths and added as attachments. Also note that `addAttachment` (just like `file_get_contents`, `passthru`, `unlink`, etc) should not be passed user-sourced params either! Reported by Yongxiang Li of Asiasecurity.
PHPMailerversionspriorto5.2.20(releasedDecember28th2016)arevulnerableto[CVE-2016-10045](https://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2016-10045) a remote code execution vulnerability, responsibly reported by [Dawid Golunski](https://legalhackers.com/advisories/PHPMailer-Exploit-Remote-Code-Exec-CVE-2016-10045-Vuln-Patch-Bypass.html), and patched by Paul Buonopane (@Zenexer).
PHPMailerversionspriorto5.2.18(releasedDecember2016)arevulnerableto[CVE-2016-10033](https://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2016-10033) a remote code execution vulnerability, responsibly reported by [Dawid Golunski](http://legalhackers.com/advisories/PHPMailer-Exploit-Remote-Code-Exec-CVE-2016-10033-Vuln.html).
PHPMailerversionspriorto5.2.14(releasedNovember2015)arevulnerableto[CVE-2015-8476](https://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2015-8476) an SMTP CRLF injection bug permitting arbitrary message sending.
PHPMailerversionspriorto5.2.10(releasedMay2015)arevulnerableto[CVE-2008-5619](https://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2008-5619), a remote code execution vulnerability in the bundled html2text library. This file was removed in 5.2.10, so if you are using a version prior to that and make use of the html2text function, it's vitally important that you upgrade and remove this file.
PHPMailerversionspriorto2.0.7and2.2.1arevulnerableto[CVE-2012-0796](https://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2012-0796), an email header injection attack.
PHPMailerdidn'tsanitisethe`$lang_path`parameterin`SetLanguage`.Thiswasn'taprobleminitself,butsomeapps(PHPClassifieds,ATutor)alsofailedtosanitiseuser-providedparameterspassedtoit,permittingsemi-arbitrarylocalfileinclusion,reportedin[CVE-2010-4914](https://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2010-4914), [CVE-2007-2021](https://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2007-2021) and [CVE-2006-5734](https://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2006-5734).