CVE-2026-129299: mail-parser: Uncaught exceptions and silent header loss in mail-parser on attacker-controlled input
mail-parser is a tool that parses emails by enhancing the Python standard library and extracting message details into a comprehensive object. Prior to 4.6.2, multiple message-processing behaviors can raise exceptions or silently lose content. Headers colliding with methods such as Parse, Message, and WriteAttachments can place bound method objects into parsed output and raise TypeError when a caller requests JSON serialization such as mailjson. When byte input is parsed through parsefrombytes(), an 8-bit header value returned as email.header.Header can likewise raise TypeError when an Xraw accessor passes the value to json.dumps; both exceptions are outside the MailParserError hierarchy. Separately, rewritten names such as Subjectjson and XSpamFlag can be substituted or disappear from mail, headers, and JSON output while hasdefects remains false, and a headerless message can be treated as falsy before parser state is initialized, causing body and attachment properties to return empty values without an error signal. These behaviors can abort message processing or hide malicious indicators from downstream scanners. This issue is fixed in version 4.6.2.
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.2
Event History
Frequently Asked Questions
Who is exposed to this issue?
Applications that use mail-parser to process attacker-controlled email content are exposed. Impact is most relevant where parsed headers, body content, attachments, or JSON output are consumed by downstream scanners or processing workflows.
What can an attacker do to trigger the problem?
An attacker can supply messages with headers that collide with parser method names, 8-bit header values parsed from byte input, rewritten header names such as Subject_json or X_Spam_Flag, or no headers. These inputs can cause uncaught TypeError exceptions, silently omit or substitute header content, or make body and attachment properties appear empty.
Can normal defect detection identify all affected messages?
No. Rewritten header-name cases can alter or remove content from mail, headers, and JSON output while has_defects remains false. Headerless messages can also produce empty body and attachment results without an error signal.
What should be done if upgrading is not immediately possible?
Treat exceptions from JSON serialization and related message processing as potential malformed or adversarial input rather than relying only on MailParserError handling. Independently validate required headers and message content before downstream scanning or decision-making, particularly for headerless messages and rewritten header names.
What version contains the fix?
The issue is fixed in mail-parser version 4.6.2. Versions prior to 4.6.2 are affected.