CVE-2026-129300
mail-parser crash malformed Received header causing unhandled OverflowError
- CVSS 5.3
- CWE-248
- Input Validation and Sanitization
- Remote
mail-parser is a tool that parses emails by enhancing the Python standard library and extracting message details into a comprehensive object. From 3.7.0 until 4.6.3, receiveds_format() in src/mailparser/utils.py catches only TypeError and ValueError while converting the trailing date of an attacker-controlled Received header. An out-of-range year can cause calendar.timegm() to raise OverflowError, and a sufficiently large timezone offset can cause datetime.fromtimestamp() to raise OSError. These exceptions are outside the MailParserError hierarchy, so one crafted header can abort the entire message parse through every parse_from_* entry point and may drop a queued batch. This issue is fixed in version 4.6.3.
- CWE
- CWE-248
- CVSS base score
- 5.3
- Published
- 2026-11-16
- OWASP
- A04 Insecure Design
- Orthogonal defect classification
- Checking
- Code defect classification
- Missing Check
- Category
- Input Validation and Sanitization
- Subcategory
- Insecure Parsing or Deserialization
- Accessibility scope
- Remote
- Impact
- Denial of Service (DoS)
- Affected component
- mail-parser
- Fixed by upgrading
- Yes
Solution
Upgrade mail-parser to version 4.6.3 or later.
Vulnerable code sample
import calendar
import datetime
def _parse_received_date(date_str):
"""
Convert a trailing date string from a Received header into a datetime.
"""
# Expected format: "Tue, 1 Jan 2025 12:34:56 +9999"
parts = date_str.rsplit(' ', 1)
if len(parts) != 2:
raise ValueError("Invalid date format")
dt_part, tz_part = parts
# VULNERABLE: only catches TypeError and ValueError; OverflowError/OSError can escape
try:
timestamp = calendar.timegm(datetime.datetime.strptime(dt_part, "%a, %d %b %Y %H:%M:%S").timetuple())
# tz_part like "+0500" -> offset seconds
sign = 1 if tz_part[0] == '+' else -1
offset = sign * (int(tz_part[1:3]) * 3600 + int(tz_part[3:]) * 60)
return datetime.datetime.fromtimestamp(timestamp + offset)
except (TypeError, ValueError) as e:
raise RuntimeError("Failed to parse Received date") from ePatched code sample
import calendar
import datetime
def _parse_received_date(date_str):
"""
Convert a trailing date string from a Received header into a datetime.
"""
# Expected format: "Tue, 1 Jan 2025 12:34:56 +9999"
parts = date_str.rsplit(' ', 1)
if len(parts) != 2:
raise ValueError("Invalid date format")
dt_part, tz_part = parts
# FIX: broaden exception handling to include OverflowError and OSError
try:
timestamp = calendar.timegm(datetime.datetime.strptime(dt_part, "%a, %d %b %Y %H:%M:%S").timetuple())
sign = 1 if tz_part[0] == '+' else -1
offset = sign * (int(tz_part[1:3]) * 3600 + int(tz_part[3:]) * 60)
return datetime.datetime.fromtimestamp(timestamp + offset)
except (TypeError, ValueError, OverflowError, OSError) as e:
raise RuntimeError("Failed to parse Received date") from ePublished 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.
- fix: keep parsing when a Received date is out of range (SpamScope/mail-parser)
src/mailparser/utils.py · receiveds_format - fix: attachment integrity, batch availability, and date overflow on hostile mail (#171) (SpamScope/mail-parser)
src/mailparser/core.py,src/mailparser/core.py · MailParser.message_as_string,src/mailparser/core.py · MailParser.parse,src/mailparser/exceptions.py,src/mailparser/utils.py,src/mailparser/utils.py · ported_string,src/mailparser/utils.py · print_attachments,src/mailparser/utils.py · write_attachments,src/mailparser/utils.py · write_sample,src/mailparser/utils.py · _deduplicate_filename,src/mailparser/utils.py · _safe_attachment_filename
Cite this entry
@misc{vaitp:cve2026129300,
title = {{mail-parser crash malformed Received header causing unhandled OverflowError}},
author = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
year = {2026},
note = {VAITP Python Vulnerability Dataset, entry CVE-2026-129300},
howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2026-129300/}}
}
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 ::
