CVE-2020-36326: Phpmailer/phpmailer Object Injection Vulnerability

CRITICAL
Advisory Identifier: GHSA-m298-fh5c-jc66
CVSS 9.8
CWE-641 CWE-502
Published
Advisory Summary

CVE-2020-36326 is a CRITICAL (CVSS 9.8) object injection vulnerability (CWE-641: Improper Restriction of Names for Files and Other Resources) affecting Phpmailer/phpmailer libraries in the Packagist ecosystem. The issue involves object injection in phpmailer/phpmailer. Remediation is available by upgrading affected packages to version 6.4.1.

CVE-2020-36326 at a Glance

CVE Identifier CVE-2020-36326
GHSA Identifier GHSA-m298-fh5c-jc66
Severity CRITICAL
CVSS v3.1 Base Score 9.8
CWE Classification CWE-641: Improper Restriction of Names for Files and Other Resources
Affected Product Phpmailer/phpmailer
Package Ecosystem Packagist
Published Date
Last Updated

Security Impact

CVSS: 9.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:N/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 None (UI:N)
Scope Unchanged (S:U)
Confidentiality High (C:H)
Integrity High (I:H)
Availability High (A:H)

How to Fix CVE-2020-36326

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: 6.4.1
Upgrade phpmailer/phpmailer to 6.4.1
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-2020-36326, 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 6.4.1), 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-641: Improper Restriction of Names for Files and Other Resources, where the product constructs the name of a file or other resource using input from an upstream component, but it does not restrict or incorrectly restricts the resulting name. 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

### 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](https://knasmueller.net/5-answers-about-php-phar-exploitation) 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()`](https://github.com/PHPMailer/PHPMailer/blob/master/src/PHPMailer.php#L1815) 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](https://github.com/farisv), reported and managed via Tidelift.

CVE-2020-36326 Affected Phpmailer/phpmailer Versions

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

References

Frequently Asked Questions

What is CVE-2020-36326?
CVE-2020-36326 is a security vulnerability in Phpmailer/phpmailer involving Object injection in PHPMailer/PHPMailer under CWE-641: Improper Restriction of Names for Files and Other Resources.
Which Phpmailer/phpmailer versions are affected?
Affected versions include releases prior to 6.4.1 across affected packages: phpmailer/phpmailer.
What version fixes CVE-2020-36326?
Upgrading to 6.4.1 (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 6.4.1. Upgrade your dependency to 6.4.1 or later.
What is the CVSS score of CVE-2020-36326?
CVE-2020-36326 has a CVSS v3.1 base score of 9.8 (CRITICAL) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H.
What CWE is associated with CVE-2020-36326?
CVE-2020-36326 is classified under CWE-641: Improper Restriction of Names for Files and Other Resources (The product constructs the name of a file or other resource using input from an upstream component, but it does not restrict or incorrectly restricts the resulting name.).
How can I check Packagist dependencies for CVE-2020-36326?
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-m298-fh5c-jc66",
  "modified" : "2026-07-21T13:42:46Z",
  "published" : "2021-05-04T17:42:13Z",
  "aliases" : [ "CVE-2020-36326" ],
  "summary" : "Object injection in PHPMailer/PHPMailer",
  "details" : "### Impact\nThis 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](https://knasmueller.net/5-answers-about-php-phar-exploitation) for more info.\n\n### Patches\nThis 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.\n\n### Workarounds\nValidate paths to loaded files using the same pattern as used in [`isPermittedPath()`](https://github.com/PHPMailer/PHPMailer/blob/master/src/PHPMailer.php#L1815) 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.\n\n### Credit\nThis issue was found by [Fariskhi Vidyan](https://github.com/farisv), reported and managed via Tidelift.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "Packagist",
      "name" : "phpmailer/phpmailer"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "6.1.8"
      }, {
        "fixed" : "6.4.1"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/PHPMailer/PHPMailer/security/advisories/GHSA-m298-fh5c-jc66"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2020-36326"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/PHPMailer/PHPMailer/commit/e2e07a355ee8ff36aba21d0242c5950c56e4c6f9"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/FriendsOfPHP/security-advisories/blob/master/phpmailer/phpmailer/CVE-2020-36326.yaml"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/PHPMailer/PHPMailer"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/PHPMailer/PHPMailer/releases/tag/v6.4.1"
  }, {
    "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"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-502", "CWE-641" ],
    "severity" : "CRITICAL",
    "github_reviewed" : true,
    "github_reviewed_at" : "2021-04-30T19:41:24Z",
    "nvd_published_at" : "2021-04-28T03:15:00Z"
  }
}