Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.
Sources: National Vulnerability Database, CISA KEV, Exploit-DB
CVE-2026-61816 Overview
CVE-2026-61816 is an uncontrolled resource consumption vulnerability [CWE-400] in the zbateson/mail-mime-parser PHP library. The library provides an alternative to PHP's imap_* functions for parsing RFC 822 Internet Message Format messages. Versions 2.0.0 through 3.0.5 and 4.0.0 through 4.0.1 contain three independent parsing paths that execute in super-linear time or memory relative to input size. A crafted email under 2 MB can consume seconds of CPU and hundreds of megabytes to multiple gigabytes of memory, triggering out-of-memory kills and denial of service. The parse is lazy, so the cost is paid on the first getAllParts() call or content read.
Critical Impact
A single malicious email under 2 MB can exhaust host memory and crash PHP worker processes, enabling denial of service against any application that parses untrusted mail.
Affected Products
- zbateson/mail-mime-parser versions 2.0.0 through 2.x (end-of-life, unpatched)
- zbateson/mail-mime-parser versions 3.0.0 through 3.0.5
- zbateson/mail-mime-parser versions 4.0.0 through 4.0.1
Discovery Timeline
- 2026-09-24 - CVE-2026-61816 published to NVD
- 2026-09-30 - Last updated in NVD database
Technical Details for CVE-2026-61816
Vulnerability Analysis
The vulnerability affects three independent parsing paths inside zbateson/mail-mime-parser that scale super-linearly with input structure rather than input size. Because the cost is tied to the complexity of nested MIME structures, header counts, and sibling-append operations, a byte-size cap on the caller side does not bound the work performed by the parser.
Parsing is lazy by design. The expensive work is deferred until the application invokes getAllParts() or reads part content. Applications that queue mail for later analysis will therefore absorb the cost at processing time, not at ingest time, which complicates upstream rate limiting.
A single crafted message under 2 MB can consume multi-second CPU bursts and allocate hundreds of megabytes to multiple gigabytes of memory. The resulting out-of-memory kill terminates the PHP worker handling the request. See the GitHub Security Advisory GHSA-f6v3-2qmr-vfjx for the full advisory.
Root Cause
Three distinct code paths exhibit algorithmic complexity issues: deeply nested multipart structures without a depth cap, unbounded header count and total header size, and a sibling-append operation that executes in O(n²). The fixes in 3.0.6 and 4.0.2 add configurable limits on multipart nesting depth and on header count or total header size, record a parse error past the threshold instead of throwing, and change sibling append to O(n).
Attack Vector
An attacker crafts an RFC 822 message with deeply nested multipart boundaries, a large number of headers, or a structure that triggers the quadratic sibling-append path. The message is delivered to any application that passes untrusted mail through zbateson/mail-mime-parser. On the first call to getAllParts() or a content read, the parser consumes CPU and memory until the request fails or the PHP process is killed by the OS out-of-memory handler.
The vulnerability requires no authentication and no user interaction. Any network-exposed mail processing pipeline, webhook, or ticketing system that accepts email is a candidate target.
Detection Methods for CVE-2026-61816
Indicators of Compromise
- PHP worker processes terminating with out-of-memory errors shortly after inbound mail processing
- Sustained high CPU on PHP-FPM or worker queues correlated with specific inbound messages
- Repeated HTTP 500 responses or dropped connections on endpoints that invoke MailMimeParser::parse() or getAllParts()
- Inbound RFC 822 messages with unusually deep multipart nesting or thousands of header lines
Detection Strategies
- Inventory dependencies with composer show zbateson/mail-mime-parser to identify vulnerable versions across repositories and deployed artifacts
- Parse application logs for PHP fatal errors referencing Allowed memory size within request traces that invoked the parser
- Sample inbound messages and measure parse time and peak memory per message to flag outliers
Monitoring Recommendations
- Alert on PHP worker OOM kills via systemd journal entries or container runtime exit codes
- Monitor per-request memory and wall-clock duration for endpoints handling inbound email
- Track mail queue backlog growth as a secondary signal of parser-induced request failures
How to Mitigate CVE-2026-61816
Immediate Actions Required
- Upgrade zbateson/mail-mime-parser to 4.0.2 or 3.0.6 immediately using composer require zbateson/mail-mime-parser:^4.0.2
- Migrate any deployments on 2.x to a supported fixed line, as 2.x is end-of-life and will not receive patches
- Apply strict PHP memory_limit and max_execution_time values to any process that parses untrusted mail
- Isolate mail parsing into dedicated worker pools so an OOM kill does not disrupt unrelated request handling
Patch Information
The maintainer released fixed versions 4.0.2 and 3.0.6. These versions add configurable limits for multipart nesting depth and header count or total header size, record a parse error past the threshold instead of throwing, and change the sibling-append operation to O(n). Full details are available in the GitHub Security Advisory GHSA-f6v3-2qmr-vfjx.
Workarounds
- Restrict exposure of the parser to untrusted input where possible, routing only authenticated or trusted mail sources through the library
- Run parsing under a constrained memory_limit and execution time limit so a malicious message fails its own request rather than exhausting the host
- Reject messages whose structural metrics (nesting depth, header count) exceed conservative thresholds before invoking the parser
# Configuration example: constrain PHP resources for mail parsing workers
# php.ini for the mail-processing pool
memory_limit = 256M
max_execution_time = 15
# Upgrade to a fixed release
composer require zbateson/mail-mime-parser:^4.0.2
Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.
Sources: National Vulnerability Database, CISA KEV, Exploit-DB

