CVE-2026-129301: mail-parser: One hostile attachment aborts `write_attachments()` and silently drops the rest of the batch
mail-parser is a tool that parses emails by enhancing the Python standard library and extracting message details into a comprehensive object. From 4.6.0 until 4.6.3, writeattachments() calls safeattachmentfilename() and writesample() without isolating failures for individual attacker-controlled MIME parts. An RFC 2231 filename containing a NUL, a basename exceeding NAMEMAX, or an undecodable base64 payload can raise ValueError, OSError, or binascii.Error and abort the entire save loop. Later attachments remain unwritten; when a caller catches only MailParserError, the failure is not surfaced through the expected library-exception path. If a downstream scanner or sandbox reads only the extraction directory, a payload after the crafted part can be missed even though it remains in the delivered message, and the aborted batch also causes availability loss. This issue is fixed in version 4.6.3.
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade
mail-parserto a version that resolves this vulnerability.Fixed in 4.6.3
Event History
Frequently Asked Questions
Who is exposed to this issue?
Deployments using mail-parser from 4.6.0 through 4.6.3 are affected when they call write_attachments(). Exposure is most significant where downstream scanners or sandboxes inspect only the attachment extraction directory.
What does an attacker need to provide to trigger the failure?
An attacker needs to send an email with a crafted MIME attachment part before attachments they want to prevent from being extracted. Triggering inputs include an RFC 2231 filename containing a NUL byte, a filename basename exceeding NAME_MAX, or an undecodable base64 payload.
How can this affect security processing?
A failure processing one crafted attachment aborts the save loop, leaving later attachments unwritten. A malicious payload placed after the crafted part can remain in the delivered message while being absent from the extraction directory inspected by a scanner or sandbox.
What should be done if upgrading is not immediately possible?
Ensure attachment-processing callers handle ValueError, OSError, and binascii.Error in addition to MailParserError, and avoid treating an incomplete extraction directory as evidence that all attachments were scanned. Retain and inspect the original delivered message when extraction fails.
How can operators identify affected behavior?
Look for write_attachments() failures involving ValueError, OSError, or binascii.Error, particularly where only MailParserError is caught. Verify whether later attachments from the same message are missing from the extraction directory after such a failure.