CVE-2017-5223: Phpmailer/phpmailer Local File Disclosure Vulnerability

MODERATE
Advisory Identifier: GHSA-4x5h-cr29-fhp6
CVSS 5.5
CWE-200
Published
Advisory Summary

CVE-2017-5223 is a MODERATE (CVSS 5.5) local file disclosure vulnerability (CWE-200: Exposure of Sensitive Information to an Unauthorized Actor) affecting Phpmailer/phpmailer libraries in the Packagist ecosystem. The issue involves local file disclosure in phpmailer. Remediation is available by upgrading affected packages to version 5.2.22.

CVE-2017-5223 at a Glance

CVE Identifier CVE-2017-5223
GHSA Identifier GHSA-4x5h-cr29-fhp6
Severity MODERATE
CVSS v3.1 Base Score 5.5
CWE Classification CWE-200: Exposure of Sensitive Information to an Unauthorized Actor
Affected Product Phpmailer/phpmailer
Package Ecosystem Packagist
Published Date
Last Updated

Security Impact

CVSS: 5.5

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.0/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:N/A:N).

Attack Vector Local (AV:L)
Attack Complexity Low (AC:L)
Privileges Required Low (PR:L)
User Interaction None (UI:N)
Scope Unchanged (S:U)
Confidentiality High (C:H)
Integrity None (I:N)
Availability None (A:N)

How to Fix CVE-2017-5223

To remediate this vulnerability, upgrade all affected Phpmailer/phpmailer dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

phpmailer/phpmailer fixed: 5.2.22
Upgrade phpmailer/phpmailer to 5.2.22
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

inspect dependencies for phpmailer/phpmailer

How to Check if You Are Affected

To determine whether your application is affected by CVE-2017-5223, inspect your project dependencies for Phpmailer/phpmailer:

inspect dependencies for phpmailer/phpmailer

Analyze the terminal output to locate any version of Phpmailer/phpmailer in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 5.2.22), your application is affected.

Note: Verify declared build manifests and deployed runtime container environments.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-200: Exposure of Sensitive Information to an Unauthorized Actor, where the product exposes sensitive information to an actor that is not explicitly authorized to have access to that information. In Phpmailer/phpmailer, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

An issue was discovered in PHPMailer before 5.2.22. PHPMailer's `msgHTML` method applies transformations to an HTML document to make it usable as an email message body. One of the transformations is to convert relative image URLs into attachments using a script-provided base directory. If no base directory is provided, it resolves to `/`, meaning that relative image URLs get treated as absolute local file paths and added as attachments. To form a remote vulnerability, the msgHTML method must be called, passed an unfiltered, user-supplied HTML document, and must not set a base directory. ### Impact Arbitrary local files can be attached to email messages. ### Patches Fixed in 5.2.22 ### Workarounds Validate input before using user-supplied file paths. ### References https://nvd.nist.gov/vuln/detail/CVE-2017-5223 ### For more information If you have any questions or comments about this advisory: * Open a private issue in [the PHPMailer project](https://github.com/PHPMailer/PHPMailer)

CVE-2017-5223 Affected Phpmailer/phpmailer Versions

1 component(s)
Fixed Versions:
5.2.22
Product / Package Ecosystem Affected Versions Fixed Version
phpmailer/phpmailer
Packagist
≥ 5.0.0
< 5.2.22
5.2.22

References

Frequently Asked Questions

What is CVE-2017-5223?
CVE-2017-5223 is a security vulnerability in Phpmailer/phpmailer involving Local file disclosure in PHPMailer under CWE-200: Exposure of Sensitive Information to an Unauthorized Actor.
Which Phpmailer/phpmailer versions are affected?
Affected versions include releases prior to 5.2.22 across affected packages: phpmailer/phpmailer.
What version fixes CVE-2017-5223?
Upgrading to 5.2.22 (or the latest patched release for your respective branch) resolves the vulnerability.
Is phpmailer/phpmailer affected?
Yes, phpmailer/phpmailer is affected in releases prior to 5.2.22. Upgrade your dependency to 5.2.22 or later.
What is the CVSS score of CVE-2017-5223?
CVE-2017-5223 has a CVSS v3.1 base score of 5.5 (MODERATE) with vector string CVSS:3.0/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:N/A:N.
What CWE is associated with CVE-2017-5223?
CVE-2017-5223 is classified under CWE-200: Exposure of Sensitive Information to an Unauthorized Actor (The product exposes sensitive information to an actor that is not explicitly authorized to have access to that information.).
How can I check Packagist dependencies for CVE-2017-5223?
Run the dependency tree command: 'inspect dependencies for phpmailer/phpmailer'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-4x5h-cr29-fhp6",
  "modified" : "2021-08-19T19:50:50Z",
  "published" : "2020-03-05T22:09:10Z",
  "aliases" : [ "CVE-2017-5223" ],
  "summary" : "Local file disclosure in PHPMailer",
  "details" : "An issue was discovered in PHPMailer before 5.2.22. PHPMailer&#39;s `msgHTML` method applies transformations to an HTML document to make it usable as an email message body. One of the transformations is to convert relative image URLs into attachments using a script-provided base directory. If no base directory is provided, it resolves to `/`, meaning that relative image URLs get treated as absolute local file paths and added as attachments. To form a remote vulnerability, the msgHTML method must be called, passed an unfiltered, user-supplied HTML document, and must not set a base directory.\n\n### Impact\nArbitrary local files can be attached to email messages.\n\n### Patches\nFixed in 5.2.22\n\n### Workarounds\nValidate input before using user-supplied file paths.\n\n### References\nhttps://nvd.nist.gov/vuln/detail/CVE-2017-5223\n\n### For more information\nIf you have any questions or comments about this advisory:\n* Open a private issue in [the PHPMailer project](https://github.com/PHPMailer/PHPMailer)",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.0/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:N/A:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "Packagist",
      "name" : "phpmailer/phpmailer"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "5.0.0"
      }, {
        "fixed" : "5.2.22"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/PHPMailer/PHPMailer/security/advisories/GHSA-4x5h-cr29-fhp6"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2017-5223"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/FriendsOfPHP/security-advisories/blob/master/phpmailer/phpmailer/CVE-2017-5223.yaml"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/PHPMailer/PHPMailer/blob/master/SECURITY.md"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/PHPMailer/PHPMailer/releases/tag/v5.2.22"
  }, {
    "type" : "WEB",
    "url" : "https://www.exploit-db.com/exploits/43056"
  }, {
    "type" : "WEB",
    "url" : "http://kalilinux.co/2017/01/12/phpmailer-cve-2017-5223-local-information-disclosure-vulnerability-analysis"
  }, {
    "type" : "WEB",
    "url" : "http://www.securityfocus.com/bid/95328"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-200" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2020-03-05T22:07:31Z",
    "nvd_published_at" : null
  }
}