GHSA-cxf7-m5g2-v594: Zendframework/zend mail Remote Code Execution Vulnerability

HIGH
CVSS 8.8
CWE-74
Published
Advisory Summary

GHSA-cxf7-m5g2-v594 is a HIGH (CVSS 8.8) remote code execution vulnerability (CWE-74: Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')) affecting Zendframework/zend mail libraries in the Packagist ecosystem. The issue involves zend-mail remote code execution in zend-mail via sendmail adapter. Remediation is available by upgrading affected packages to version 2.4.11, 2.7.2.

GHSA-cxf7-m5g2-v594 at a Glance

CVE Identifier N/A
GHSA Identifier GHSA-cxf7-m5g2-v594
Severity HIGH
CVSS v3.1 Base Score 8.8
CWE Classification CWE-74: Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')
Affected Product Zendframework/zend mail
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:L/UI:N/S:U/C:H/I:H/A:H).

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

How to Fix GHSA-cxf7-m5g2-v594

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

zendframework/zend-mail fixed: 2.4.11
Upgrade zendframework/zend-mail to 2.4.11
zendframework/zend-mail fixed: 2.7.2
Upgrade zendframework/zend-mail to 2.7.2
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 zendframework/zend-mail

How to Check if You Are Affected

To determine whether your application is affected by GHSA-cxf7-m5g2-v594, inspect your project dependencies for Zendframework/zend mail:

inspect dependencies for zendframework/zend-mail

Analyze the terminal output to locate any version of Zendframework/zend mail in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 2.4.11), 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-74: Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection'), where the product constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component. In Zendframework/zend mail, 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

When using the zend-mail component to send email via the `Zend\Mail\Transport\Sendmail` transport, a malicious user may be able to inject arbitrary parameters to the system sendmail program. The attack is performed by providing additional quote characters within an address; when unsanitized, they can be interpreted as additional command line arguments, leading to the vulnerability. The following example demonstrates injecting additional parameters to the sendmail binary via the From address: ``` use Zend\Mail; $mail = new Mail\Message(); $mail->setBody('This is the text of the email.'); // inject additional parameters to sendmail command line $mail->setFrom('"AAA\" params injection"@domain', 'Sender\'s name'); $mail->addTo('hacker@localhost', 'Name of recipient'); $mail->setSubject('TestSubject'); $transport = new Mail\Transport\Sendmail(); $transport->send($mail); ``` The attack works because zend-mail filters the email addresses using the RFC 3696 specification, where the string "AAA\" params injection"@domain is considered a valid address. This validation is provided using the zend-validator component with the following parameters: ``` Zend\Validator\EmailAddress( Zend\Validator\Hostname::ALLOW_DNS | Zend\Validator\Hostname::ALLOW_LOCAL ) ``` The above accepts local domain with any string specified by double quotes as the local part. While this is valid per RFC 3696, due to the fact that sender email addresses are provided to the sendmail binary via the command line, they create the vulnerability described above.

GHSA-cxf7-m5g2-v594 Affected Zendframework/zend mail Versions

2 component(s)
Fixed Versions:
2.4.112.7.2
Product / Package Ecosystem Affected Versions Fixed Version
zendframework/zend-mail
Packagist
≥ 2.0.0
< 2.4.11
2.4.11
zendframework/zend-mail
Packagist
≥ 2.5.0
< 2.7.2
2.7.2

References

Frequently Asked Questions

What is GHSA-cxf7-m5g2-v594?
GHSA-cxf7-m5g2-v594 is a security vulnerability in Zendframework/zend mail involving Zend-Mail remote code execution in zend-mail via Sendmail adapter under CWE-74: Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection').
Which Zendframework/zend mail versions are affected?
Affected versions include releases prior to 2.4.11, 2.7.2 across affected packages: zendframework/zend-mail.
What version fixes GHSA-cxf7-m5g2-v594?
Upgrading to 2.4.11, 2.7.2 (or the latest patched release for your respective branch) resolves the vulnerability.
Is zendframework/zend-mail affected?
Yes, zendframework/zend-mail is affected in releases prior to 2.4.11, 2.7.2. Upgrade your dependency to 2.4.11, 2.7.2 or later.
What is the CVSS score of GHSA-cxf7-m5g2-v594?
GHSA-cxf7-m5g2-v594 has a CVSS v3.1 base score of 8.8 (HIGH) with vector string CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H.
What CWE is associated with GHSA-cxf7-m5g2-v594?
GHSA-cxf7-m5g2-v594 is classified under CWE-74: Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection') (The product constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component.).
How can I check Packagist dependencies for GHSA-cxf7-m5g2-v594?
Run the dependency tree command: 'inspect dependencies for zendframework/zend-mail'. 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-cxf7-m5g2-v594",
  "modified" : "2024-06-07T21:20:03Z",
  "published" : "2024-06-07T21:19:22Z",
  "aliases" : [ ],
  "summary" : "Zend-Mail remote code execution in zend-mail via Sendmail adapter",
  "details" : "When using the zend-mail component to send email via the `Zend\\Mail\\Transport\\Sendmail` transport, a malicious user may be able to inject arbitrary parameters to the system sendmail program. The attack is performed by providing additional quote characters within an address; when unsanitized, they can be interpreted as additional command line arguments, leading to the vulnerability.\n\nThe following example demonstrates injecting additional parameters to the sendmail binary via the From address:\n```\nuse Zend\\Mail;\n\n$mail = new Mail\\Message();\n$mail->setBody('This is the text of the email.');\n\n// inject additional parameters to sendmail command line\n$mail->setFrom('\"AAA\\\" params injection\"@domain', 'Sender\\'s name');\n\n$mail->addTo('hacker@localhost', 'Name of recipient');\n$mail->setSubject('TestSubject');\n\n$transport = new Mail\\Transport\\Sendmail();\n$transport->send($mail);\n```\nThe attack works because zend-mail filters the email addresses using the RFC 3696 specification, where the string \"AAA\\\" params injection\"@domain is considered a valid address. This validation is provided using the zend-validator component with the following parameters:\n```\nZend\\Validator\\EmailAddress(\n    Zend\\Validator\\Hostname::ALLOW_DNS | Zend\\Validator\\Hostname::ALLOW_LOCAL\n)\n```\nThe above accepts local domain with any string specified by double quotes as the local part. While this is valid per RFC 3696, due to the fact that sender email addresses are provided to the sendmail binary via the command line, they create the vulnerability described above.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "Packagist",
      "name" : "zendframework/zend-mail"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "2.0.0"
      }, {
        "fixed" : "2.4.11"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "Packagist",
      "name" : "zendframework/zend-mail"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "2.5.0"
      }, {
        "fixed" : "2.7.2"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/zendframework/zend-mail/commit/0a92d0b3a8b7d7c7659aa569f1a66a23d4ad51af"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/zendframework/zend-mail/commit/7260c9768bf27c84f994c48698493fd1fa62fca3"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/zendframework/zend-mail/commit/8d18478b40fdeef7239fb7ea203e072edcadbe54"
  }, {
    "type" : "WEB",
    "url" : "https://framework.zend.com/security/advisory/ZF2016-04"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/FriendsOfPHP/security-advisories/blob/master/zendframework/zend-mail/ZF2016-04.yaml"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/zendframework/zend-mail"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-74" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2024-06-07T21:19:22Z",
    "nvd_published_at" : null
  }
}