Advisories for Pypi/Mail-Parser package

2026

mail-parser: Uncaught exceptions and silent header loss in mail-parser on attacker-controlled input

Two effects, sharing the root cause of Advisory 1 — header names chosen by the sender were resolved through Python attribute lookup and rewritten before lookup. Uncaught exceptions. A crafted message raises an exception that is outside the MailParser* hierarchy, so a caller catching only mail-parser exceptions does not catch it and the worker dies. Header named after a method (CWE-248, reported by @iam-niranjan). Python resolves real class attributes before …

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

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; …

mail-parser: Sender IP address spoofing in get_server_ipaddress()

Patches Fixed in 4.6.2. Upgrade with pip install –upgrade mail-parser. Candidate addresses are now selected by position, not by appearance — a bracketed address the sender wrote is byte-identical to one the MTA wrote, so no amount of pattern matching can tell them apart: the first token of the from clause is the HELO name, whatever its shape, and is never a candidate; an explicit HELO marker inside a comment …

mail-parser: Path Traversal vulnerability in attachment extraction

A path traversal vulnerability was identified in mail-parser when extracting email attachments using the write_attachments() and write_sample() APIs. A specially crafted email containing malicious attachment filenames (for example, using directory traversal sequences such as "../" or absolute filesystem paths) could cause files to be written outside the intended output directory. Depending on how the library was used and the permissions of the executing process, this could result in arbitrary file …

mail-parser: One hostile attachment aborts `write_attachments()` and silently drops the rest of the batch

write_attachments() called _safe_attachment_filename() and write_sample() inside its loop with no guard, so a single crafted attachment raised out of the whole save. Every attachment after the malicious one was silently never written, with no error surfaced to a caller that catches only MailParserError. That is an evasion primitive as much as an availability bug: a sender puts one poisoned part first and the real payload second, and the payload never …

mail-parser is vulnerable to polynomial ReDoS in email header parsing

Two regular expressions used while parsing email headers backtrack polynomially on attacker-controlled input. Parsing a single small, well-formed email can consume minutes to hours of CPU, denying service to any process that parses untrusted mail. Both are reachable from an ordinary parse_from_string(), parse_from_bytes() or parse_from_file() call — no special API, option, or malformed structure is required by the victim.