Medium

mail-parser: Uncaught `OverflowError` / `OSError` on an out-of-range `Received` date

  • Disclosed: 16.11.2026
  • Updated: 17.11.2026 01:17

Impact

A Received header whose trailing date carries an out-of-range year, or a timezone offset large enough to push the timestamp past the int64 epoch range, raises an exception that is outside the MailParser* hierarchy. A caller that catches only mail-parser exceptions does not catch it, and the parse of the entire message is aborted — the same class of issue as GHSA-24mq-4vc6-2prf, which this survives (it is not a duplicate; 24mq is fixed in 4.6.2 and this reproduces on 4.6.2).

All entry points are affected: parse_from_string(), parse_from_bytes(), parse_from_file(), parse_from_file_obj() and the mail-parser CLI. The header is fully attacker-controlled and a single line is enough, so any pipeline that parses untrusted mail can be made to lose the message — and, if one worker handles a queue, to drop the batch.

python
import mailparser

raw = ("Received: from x ([1.2.3.4]) by mx.victim.com; "
       "Tue, 7 Mar 292277026596 14:29:24 +0000\r\n\r\nbody\r\n")
mailparser.parse_from_string(raw).mail_json
# <= 4.6.2 -> OverflowError: signed integer is greater than maximum
# 4.6.3    -> parses; the unusable hop date is reported as "date_utc": null

Root cause. receiveds_format() in src/mailparser/utils.py guarded the date conversion with except (TypeError, ValueError), but convert_mail_date() → email.utils.mktime_tz() → calendar.timegm() raises OverflowError for years whose epoch seconds overflow int64, and datetime.fromtimestamp() reports EOVERFLOW as OSError for a sufficiently large timezone offset. The date and timezone properties already wrapped the same conversion in except Exception; only the Received path was left open.

Affected range. Introduced by the date-handling change in ca2aa6a, first released in 3.7.0. Reproduced on PyPI 3.7.0, 3.8.0, 3.9.3, 4.0.0, 4.5.0, 4.6.0, 4.6.2 and on master before the fix (Python 3.14). 3.6.0 is not affected.

Patches

Fixed in 4.6.3. receiveds_format() now also catches OverflowError and OSError and records date_utc = None for that hop, so the rest of the message still parses:

python
try:
    j["date_utc"], _ = convert_mail_date(i["date"])
except (TypeError, ValueError, OverflowError, OSError):
    j["date_utc"] = None

A sweep of year magnitudes from 10^7 to 10^12 shows only ValueError, OverflowError and OSError are reachable on this path.

Workarounds

Upgrade to 4.6.3. If you cannot upgrade, wrap every parse_from_* call in a bare except Exception rather than except MailParserError, and treat the message as unparsed.

References

Affected software

Click a technology to see all vulnerabilities affecting it.

PlatformPackageVulnerable versionsFixed in
Python (PyPI) mail-parser >= 3.7.0, < 4.6.3 4.6.3

References

CVSS score 5.3/10
CVSS vector
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L
Weakness (CWE)
CWE-248
Platform
Python (PyPI)
Package
mail-parser
Disclosed
16.11.2026
Updated
17.11.2026 01:17

Sources and licenses

OSV / GitHub Advisory Database - GHSA-xhrq-2mqv-q8wx - CC BY 4.0

Vulnerability history: mail-parser

All published vulnerabilities of this package (Python (PyPI)), newest first. Shows whether this is a one-off slip or a package that needs watching.

Total entries
6
First → latest
11.2026 11.2026
Without a fix
0
Exploited in attacks
0

Severity breakdown

  • High 2
  • Medium 4

Disclosures per year

  1. 2026: 6
  1. mail-parser: Uncaught `OverflowError` / `OSError` on an out-of-range `Received` date this entry
    Medium · 5.3 CVE-2026-129300 >= 3.7.0, < 4.6.3 4.6.3
  2. High · 7.5 CVE-2026-129297 < 4.6.2 4.6.2
  3. High · 7.5 CVE-2026-129295 >= 4.2.0, < 4.6.1 4.6.1
  4. Medium · 6.5 CVE-2026-129296 >= 3.8.0, < 4.6.0 4.6.0

Know which vulnerabilities affect your application

With the DockRay integration and software inventory enabled, DockRay checks reported component versions against known vulnerabilities and notifies you about confirmed matches. Coverage depends on the supported technology and available advisory data.

Connect your application
DockRay newsletter

Application security in your inbox

Important vulnerabilities, actionable guidance and practical advice for your applications. Choose your technologies and follow what matters to your project.

  • A daily digest of new vulnerabilities, critical ones included.
  • Notifications about important updates.
  • Practical advice on application security and monitoring.

Leave empty to receive updates for every technology.

Free to subscribe. Unsubscribe with one click in any email.