# CVE-2017-5223: PHPMailer local file disclosure in msgHTML method

Source: https://junglewise.ai/threats/cve-2017-5223-phpmailer-local-file-disclosure-in-msghtml-method  
Publisher: Junglewise Threat Intelligence, https://junglewise.ai/threats  
Published: 2017-01-16. Updated: 2026-05-13  
License: CC BY 4.0 with a link back

CVE-2017-5223 · Severity: medium · CVSS 5.5 · Published 2017-01-16

PHPMailer, a widely used library for sending emails from web applications, contains a security flaw that could allow an attacker to steal sensitive files from the server. By submitting a specially crafted email message containing specific image tags, an attacker can trick the system into attaching private server files (such as configuration files or password lists) to the email. This could lead to the exposure of confidential business data or system credentials.

Technologies: [phpmailer/phpmailer (Packagist)](https://junglewise.ai/threats/technologies/phpmailer-phpmailer). Vendors: [Packagist](https://junglewise.ai/threats/vendors/packagist).

## Quick answers

**Is CVE-2017-5223 exploited in the wild?** No. Junglewise Threat Intelligence has no report of CVE-2017-5223 being exploited in the wild.

**How severe is CVE-2017-5223?** Medium severity, with a CVSS score of 5.5, published 16 January 2017.

**Which products and versions are affected?** phpmailer/phpmailer (Packagist) ECOSYSTEM:introduced=5.0.0,fixed=5.2.22.

**Is there a fix for CVE-2017-5223?** Yes. phpmailer/phpmailer (Packagist): upgrade to 5.2.22 or later. Junglewise finds every place you run it, drafts the upgrade and applies it once you approve.

**How is CVE-2017-5223 attacked?** It is attacked over the network, in a software library.

**Am I affected by CVE-2017-5223?** Check whether you run phpmailer/phpmailer (Packagist) at an affected version. Junglewise does that check for you around the clock: connect your code, cloud and domains, and it matches new vulnerabilities like this one against what you actually run and tells you when one reaches you.

## How to fix

- phpmailer/phpmailer (Packagist): upgrade to 5.2.22 or later

  ```sh
  composer require phpmailer/phpmailer:^5.2.22
  ```


## Technical details

A local file disclosure vulnerability exists in PHPMailer's msgHTML method. The method automatically converts relative image URLs into email attachments. If a developer passes unfiltered user input to msgHTML without specifying a base directory, the library defaults to the root directory (/). An attacker can exploit this by submitting an HTML message containing an <img> tag with a 'src' attribute pointing to a sensitive local file (e.g., <img src='/etc/passwd'>). PHPMailer will then resolve this as an absolute path and attach the requested file to the outgoing email. This vulnerability is mitigated in version 5.2.22.

## Affected products

- PHPMailer project PHPMailer < 5.2.22

## Identifiers

- CVE-2017-5223
- GHSA-4x5h-cr29-fhp6

## Timeline

- 2017-01-09: patched: Version 5.2.22 released
- 2017-01-16: disclosed: NVD publication date
- 2017-10-25: other: Public exploit code released on Exploit-DB

## References

- [http://kalilinux.co/2017/01/12/phpmailer-cve-2017-5223-local-information-disclosure-vulnerability-analysis/](http://kalilinux.co/2017/01/12/phpmailer-cve-2017-5223-local-information-disclosure-vulnerability-analysis/)
- [http://www.securityfocus.com/bid/95328](http://www.securityfocus.com/bid/95328)
- [https://github.com/PHPMailer/PHPMailer/blob/master/SECURITY.md](https://github.com/PHPMailer/PHPMailer/blob/master/SECURITY.md)
- [https://www.exploit-db.com/exploits/43056/](https://www.exploit-db.com/exploits/43056/)

## Related threats

- [PHPMailer Local file inclusion](https://junglewise.ai/threats/cve-2006-5734-phpmailer-local-file-inclusion)
- [PHPMailer Shell command injection](https://junglewise.ai/threats/cve-2007-3215-phpmailer-shell-command-injection)
- [PHPMailer vulnerable to email header injection](https://junglewise.ai/threats/cve-2012-0796-phpmailer-vulnerable-to-email-header-injection)
- [PHPMailer susceptible to arbitrary code execution](https://junglewise.ai/threats/cve-2008-5619-phpmailer-susceptible-to-arbitrary-code-execution)
- [PHPMailer untrusted code may be run from an overridden address validator](https://junglewise.ai/threats/cve-2021-3603-phpmailer-untrusted-code-may-be-run-from-an-overridden-address)
