CVE-2018-19296: Phpmailer/phpmailer Phar Object Injection Vulnerability

HIGH
Advisory Identifier: GHSA-7w4p-72j7-v7c2
CVSS 8.8
CWE-1321 CWE-502 CWE-915
Published
Advisory Summary

CVE-2018-19296 is a HIGH (CVSS 8.8) phar object injection vulnerability (CWE-1321: Improperly Controlled Modification of Object Prototype Attributes ('Prototype Pollution')) affecting Phpmailer/phpmailer libraries in the Packagist ecosystem. The issue involves phar object injection in phpmailer. Remediation is available by upgrading affected packages to version 5.2.27, 6.0.6.

CVE-2018-19296 at a Glance

CVE Identifier CVE-2018-19296
GHSA Identifier GHSA-7w4p-72j7-v7c2
Severity HIGH
CVSS v3.1 Base Score 8.8
CWE Classification CWE-1321: Improperly Controlled Modification of Object Prototype Attributes ('Prototype Pollution')
Affected Product Phpmailer/phpmailer
Package Ecosystem Packagist
Published Date
Last Updated

Security Impact

CVSS: 8.8

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

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

How to Fix CVE-2018-19296

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.27
Upgrade phpmailer/phpmailer to 5.2.27
phpmailer/phpmailer fixed: 6.0.6
Upgrade phpmailer/phpmailer to 6.0.6
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-2018-19296, 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.27), 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-1321: Improperly Controlled Modification of Object Prototype Attributes ('Prototype Pollution'), where the product receives input from an upstream component that specifies attributes that are to be initialized or updated in an object, but it does not properly control modifications of attributes of the object prototype. 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

PHPMailer versions prior to 6.0.6 and 5.2.27 are vulnerable to an object injection attack by passing phar:// paths into `addAttachment()` and other functions that may receive unfiltered local paths, possibly leading to RCE. 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. ### Impact Object injection, possible remote code execution ### Patches Fixed in 6.0.6 and 5.2.27 ### Workarounds Validate and sanitise user input before using. ### References https://nvd.nist.gov/vuln/detail/CVE-2018-19296 ### 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-2018-19296 Affected Phpmailer/phpmailer Versions

2 component(s)
Fixed Versions:
5.2.276.0.6
Product / Package Ecosystem Affected Versions Fixed Version
phpmailer/phpmailer
Packagist
≥ 5.0.0
< 5.2.27
5.2.27
phpmailer/phpmailer
Packagist
≥ 6.0.0
< 6.0.6
6.0.6

References

Frequently Asked Questions

What is CVE-2018-19296?
CVE-2018-19296 is a security vulnerability in Phpmailer/phpmailer involving Phar object injection in PHPMailer under CWE-1321: Improperly Controlled Modification of Object Prototype Attributes ('Prototype Pollution').
Which Phpmailer/phpmailer versions are affected?
Affected versions include releases prior to 5.2.27, 6.0.6 across affected packages: phpmailer/phpmailer.
What version fixes CVE-2018-19296?
Upgrading to 5.2.27, 6.0.6 (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.27, 6.0.6. Upgrade your dependency to 5.2.27, 6.0.6 or later.
What is the CVSS score of CVE-2018-19296?
CVE-2018-19296 has a CVSS v3.1 base score of 8.8 (HIGH) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H.
What CWE is associated with CVE-2018-19296?
CVE-2018-19296 is classified under CWE-1321: Improperly Controlled Modification of Object Prototype Attributes ('Prototype Pollution') (The product receives input from an upstream component that specifies attributes that are to be initialized or updated in an object, but it does not properly control modifications of attributes of the object prototype.).
How can I check Packagist dependencies for CVE-2018-19296?
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-7w4p-72j7-v7c2",
  "modified" : "2021-08-19T19:57:58Z",
  "published" : "2020-03-05T22:08:55Z",
  "aliases" : [ "CVE-2018-19296" ],
  "summary" : "Phar object injection in PHPMailer",
  "details" : "PHPMailer versions prior to 6.0.6 and 5.2.27 are vulnerable to an object injection attack by passing phar:// paths into `addAttachment()` and other functions that may receive unfiltered local paths, possibly leading to RCE. 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.\n\n### Impact\nObject injection, possible remote code execution\n\n### Patches\nFixed in 6.0.6 and 5.2.27\n\n### Workarounds\nValidate and sanitise user input before using.\n\n### References\nhttps://nvd.nist.gov/vuln/detail/CVE-2018-19296\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.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "Packagist",
      "name" : "phpmailer/phpmailer"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "5.0.0"
      }, {
        "fixed" : "5.2.27"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "Packagist",
      "name" : "phpmailer/phpmailer"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "6.0.0"
      }, {
        "fixed" : "6.0.6"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/PHPMailer/PHPMailer/security/advisories/GHSA-7w4p-72j7-v7c2"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2018-19296"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/FriendsOfPHP/security-advisories/blob/master/phpmailer/phpmailer/CVE-2018-19296.yaml"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/PHPMailer/PHPMailer/releases/tag/v5.2.27"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/PHPMailer/PHPMailer/releases/tag/v6.0.6"
  }, {
    "type" : "WEB",
    "url" : "https://lists.debian.org/debian-lts-announce/2018/12/msg00020.html"
  }, {
    "type" : "WEB",
    "url" : "https://lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/3B5WDPGUFNPG4NAZ6G4BZX43BKLAVA5B"
  }, {
    "type" : "WEB",
    "url" : "https://lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/KPU66INRFY5BQ3ESVPRUXJR4DXQAFJVT"
  }, {
    "type" : "WEB",
    "url" : "https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/3B5WDPGUFNPG4NAZ6G4BZX43BKLAVA5B"
  }, {
    "type" : "WEB",
    "url" : "https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/KPU66INRFY5BQ3ESVPRUXJR4DXQAFJVT"
  }, {
    "type" : "WEB",
    "url" : "https://www.debian.org/security/2018/dsa-4351"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-1321", "CWE-502", "CWE-915" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2020-03-05T22:08:10Z",
    "nvd_published_at" : "2018-11-16T09:29:00Z"
  }
}