CVE-2026-129299
Mail‑parser 4.6.1 can raise TypeError or drop headers during parsing/JSON conversion.
- CVSS 6.5
- CWE-248
- Input Validation and Sanitization
- Local
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 Write_Attachments can place bound method objects into parsed output and raise TypeError when a caller requests JSON serialization such as mail_json. When byte input is parsed through parse_from_bytes(), an 8-bit header value returned as email.header.Header can likewise raise TypeError when an X_raw accessor passes the value to json.dumps; both exceptions are outside the MailParserError hierarchy. Separately, rewritten names such as Subject_json and X_Spam_Flag can be substituted or disappear from mail, headers, and JSON output while has_defects 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.
- CWE
- CWE-248
- CVSS base score
- 6.5
- Published
- 2026-11-16
- OWASP
- A08 Software and Data Integrity Failures
- Orthogonal defect classification
- Interface
- Code defect classification
- Incorrect Interface
- Category
- Input Validation and Sanitization
- Subcategory
- Insecure Parsing or Deserialization
- Accessibility scope
- Local
- Impact
- Denial of Service (DoS)
- Affected component
- mail-parser
- Fixed by upgrading
- Yes
Solution
Upgrade mail‑parser to version 4.6.2 or later.
Vulnerable code sample
from mailparser import MailParser
import json
def parse_email(raw_bytes):
# VULNERABLE: bound method objects from colliding headers leak into dict and break json.dumps
parser = MailParser()
message = parser.parse_from_bytes(raw_bytes)
# Directly expose all parsed attributes, including any that may have been overwritten
# by headers like "Parse" or "Message", which become bound methods.
payload = {
"subject": message.subject,
"headers": message.headers, # dict of header name → value
"metadata": message.__dict__ # includes methods if header names collide
}
# This will raise TypeError if a method object is present in metadata
return json.dumps(payload)Patched code sample
from mailparser import MailParser
import json
def parse_email(raw_bytes):
# FIX: filter out callables to prevent method objects from entering JSON output
parser = MailParser()
message = parser.parse_from_bytes(raw_bytes)
safe_metadata = {
k: v for k, v in message.__dict__.items()
if not callable(v)
}
payload = {
"subject": message.subject,
"headers": message.headers,
"metadata": safe_metadata
}
return json.dumps(payload)Published fix
Public sources link this CVE to the changes below. The code samples above were generated to illustrate the defect; these links lead to the code the project actually changed.
- Fixed many bugs (#167) (SpamScope/mail-parser)
src/mailparser/const.py,src/mailparser/core.py,src/mailparser/core.py · MailParser.get_server_ipaddress,src/mailparser/core.py · MailParser.headers,src/mailparser/core.py · MailParser.parse,src/mailparser/core.py · MailParser._extract_ip,src/mailparser/core.py · MailParser._make_mail,src/mailparser/core.py · MailParser._reset,src/mailparser/core.py · MailParser.__getattr__,src/mailparser/core.py · MailParser.__init__,src/mailparser/utils.py,src/mailparser/utils.py · get_header
Cite this entry
@misc{vaitp:cve2026129299,
title = {{Mail‑parser 4.6.1 can raise TypeError or drop headers during parsing/JSON conversion.}},
author = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
year = {2026},
note = {VAITP Python Vulnerability Dataset, entry CVE-2026-129299},
howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2026-129299/}}
}
Introducing the "VAITP dataset": a specialized repository of Python vulnerabilities and patches, meticulously compiled for the use of the security research community. As Python's prominence grows, understanding and addressing potential security vulnerabilities become crucial. Crafted by and for the cybersecurity community, this dataset offers a valuable resource for researchers, analysts, and developers to analyze and mitigate the security risks associated with Python. Through the comprehensive exploration of vulnerabilities and corresponding patches, the VAITP dataset fosters a safer and more resilient Python ecosystem, encouraging collaborative advancements in programming security.
The supreme art of war is to subdue the enemy without fighting.
Sun Tzu – “The Art of War”
:: Shaping the future through research and ingenuity ::
