{"vuln_id":"GHSA-24mq-4vc6-2prf","aliases":["CVE-2026-129299"],"description":"mail-parser: Uncaught exceptions and silent header loss in mail-parser on attacker-controlled input","published_at":"2026-11-16T22:12:51Z","modified_at":"2026-11-16T22:12:52Z","first_seen_at":"2026-11-21T19:15:20.238588Z","severity":"medium","severity_source":"ghsa","cvss_score":6.5,"cvss_vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:L/A:L","cwe":["CWE-248","CWE-436"],"vendor":null,"product":null,"kev":{"is_kev":false,"date_added":null,"due_date":null,"ransomware":false},"epss":null,"epss_percentile":null,"nvd_status":null,"enriched_at":null,"links":{"nvd":"https://github.com/advisories/GHSA-24mq-4vc6-2prf"},"matched_alias":null,"items":[{"id":2477,"source":{"id":"ghsa","name":"GitHub Security Advisories"},"title":"GHSA-xhrq-2mqv-q8wx / CVE-2026-129300: mail-parser: Uncaught `OverflowError` / `OSError` on an out-of-range `Received` date","summary":"mail-parser: Uncaught `OverflowError` / `OSError` on an out-of-range `Received` date\n\n### Impact\n\nA `Received` header whose trailing date carries an out-of-range year, or a timezone offset\nlarge enough to push the timestamp past the int64 epoch range, raises an exception that is\n**outside the `MailParser*` hierarchy**. A caller that catches only mail-parser exceptions\ndoes not catch it, and the parse of the entire message is aborted — the same class of issue\nas [GHSA-24mq-4vc6-2prf](https://github.com/SpamScope/mail-parser/security/advisories/GHSA-24mq-4vc6-2prf),\nwhich this survives (it is not a duplicate; 24mq is fixed in 4.6.2 and this reproduces on 4.6.2).\n\nAll entry points are affected: `parse_from_string()`, `parse_from_bytes()`, `parse_from_file()`,\n`parse_from_file_obj()` and the `mail-parser` CLI. The header is fully attacker-controlled and\na single line is enough, so any pipeline that parses untrusted mail can be made to lose the\nmessage — and, if one worker handles a queue, to drop the batch.\n\n```python\nimport mailparser\n\nraw = (\"Received: from x ([1.2.3.4]) by mx.victim.com; \"\n\"Tue, 7 Mar 292277026596 14:29:24 +0000\\r\\n\\r\\nbody\\r\\n\")\nmailparser.parse_from_string(raw).mail_json\n# <= 4.6.2 -> OverflowError: signed integer is greater than maximum\n# 4.6.3 -> parses; the unusable hop date is reported as \"date_utc\": null\n```\n\n**Root cause.** `receiveds_format()` in `src/mailparser/utils.py` guarded the date conversion\nwith `except (TypeError, ValueError)`, but `convert_mail_date()` → `email.utils.mktime_tz()` →\n`calendar.timegm()` raises `OverflowError` for years whose epoch seconds overflow int64, and\n`datetime.fromtimestamp()` reports `EOVERFLOW` as `OSError` for a sufficiently large timezone\noffset. The `date` and `timezone` properties already wrapped the same conversion in\n`except Exception`; only the `Received` path was left open.\n\n**Affected range.** Introduced by the date-handling change in `ca2aa6a`, first released in\n3.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`\nbefore the fix (Python 3.14). 3.6.0 is not affected.\n\n### Patches\n\nFixed in **4.6.3**. `receiveds_format()` now also catches `OverflowError` and `OSError` and\nrecords `date_utc = None` for that hop, so the rest of the message still parses:\n\n```python\ntry:\nj[\"date_utc\"], _ = convert_mail_date(i[\"date\"])\nexcept (TypeError, ValueError, OverflowError, OSError):\nj[\"date_utc\"] = None\n```\n\nA sweep of year magnitudes from 10^7 to 10^12 shows only `ValueError`, `OverflowError` and\n`OSError` are reachable on this path.\n\n### Workarounds\n\nUpgrade to 4.6.3. If you cannot upgrade, wrap every `parse_from_*` call in a bare\n`except Exception` rather than `except MailParserError`, and treat the message as unparsed.\n\n### References\n\n- Fix: https://github.com/SpamScope/mail-parser/pull/171\n- Related: [GHSA-24mq-4vc6-2prf](https://github.com/SpamScope/mail-parser/security/advisories/GHSA-24mq-4vc6-2prf)\n\nAffected packages: pip:mail-parser\nPatched: mail-parser 4.6.3","url":"https://github.com/advisories/GHSA-xhrq-2mqv-q8wx","published_at":"2026-11-16T22:20:32Z","updated_at":"2026-11-16T22:20:33Z","fetched_at":"2026-11-21T19:15:18.416868Z","severity":"medium","cvss_score":6.5,"epss":0.00396,"is_kev":false,"has_exploit":false,"kev_due_date":null,"vendor":null,"product":"mail-parser","vuln_id":"CVE-2026-129300","vuln_ids":["CVE-2026-129299","CVE-2026-129300","GHSA-24MQ-4VC6-2PRF","GHSA-XHRQ-2MQV-Q8WX"],"tags":["ghsa","pip","CWE-248"],"cluster_id":2398,"links":{"self":"https://vulnwatch.ve1ve2.com/api/v1/items/2477","html":"https://vulnwatch.ve1ve2.com/item/2477"}},{"id":2480,"source":{"id":"ghsa","name":"GitHub Security Advisories"},"title":"GHSA-24mq-4vc6-2prf / CVE-2026-129299: mail-parser: Uncaught exceptions and silent header loss in mail-parser on attacker-controlled input","summary":"mail-parser: Uncaught exceptions and silent header loss in mail-parser on attacker-controlled input\n\n### Impact\n\nTwo effects, sharing the root cause of Advisory 1 — header names chosen by the sender were\nresolved through Python attribute lookup and rewritten before lookup.\n\n**Uncaught exceptions.** A crafted message raises an exception that is *outside* the\n`MailParser*` hierarchy, so a caller catching only mail-parser exceptions does not catch it\nand the worker dies.\n\n*Header named after a method* (CWE-248, reported by @iam-niranjan). Python resolves real\nclass attributes before `__getattr__`, so a header named after a method put a bound method\nobject into the parsed mail dict. A 12-byte email is sufficient. Nine colliding names were\nconfirmed: `Parse`, `Message`, `Write_Attachments`, `From_File`, `From_File_Obj`,\n`From_File_Msg`, `From_String`, `From_Bytes`, `Get_Server_Ipaddress`. Also reproducible from\nthe CLI (`mail-parser -f evil.eml -j`).\n\n```python\nimport mailparser\nmailparser.parse_from_string(\"Parse: x\\r\\n\\r\\n\").mail_json\n# 4.6.1 -> TypeError: Object of type method is not JSON serializable\n# 4.6.2 -> {\"parse\": \"x\", \"has_defects\": false}\n```\n\n*Header carrying 8-bit bytes* (CWE-248). For a header containing raw 8-bit bytes, Python's\n`compat32` policy returns an `email.header.Header` rather than a `str`, which the `_raw`\naccessor passed straight to `json.dumps`. This fires on entirely benign non-ASCII mail via\n`parse_from_bytes()`, the normal entry point for mail off the wire.\n\n```python\nimport mailparser\nmailparser.parse_from_bytes(b\"Subject: caf\\xe9\\r\\n\\r\\nbody\\r\\n\").subject_raw\n# 4.6.1 -> TypeError: Object of type Header is not JSON serializable\n# 4.6.2 -> '[\"caf�\"]'\n```\n\n**Silent loss of message content** (CWE-436). A sender can make a header's value vanish from\nevery output surface, or be replaced by a different header's value, with `has_defects`\nremaining `false`. This is an evasion primitive: the tool's output diverges from the bytes\nactually in the message, and a pipeline scanning parsed output for indicators sees nothing\nand no failure signal.\n\nHeader names were normalised before lookup — underscores folded to dashes, and `_json` /\n`_raw` suffixes interpreted — so a header genuinely named `Subject_json` was reported with\nthe value of `Subject` and its own value discarded, and any header whose name contains an\nunderscore resolved to nothing.\n\n```python\nimport mailparser\n\nraw = (\"From: Real Sender\n\\r\\n\"\n\"Subject: innocuous\\r\\n\"\n\"Subject_json: MALWARE-C2 http://evil.example/payload.exe\\r\\n\"\n\"X_Spam_Flag: YES\\r\\n\\r\\nbody\\r\\n\")\nmail = mailparser.parse_from_string(raw)\nprint(mail.mail[\"subject_json\"]) # 4.6.1 -> '\"innocuous\"' 4.6.2 -> the real value\nprint(mail.headers[\"X_Spam_Flag\"]) # 4.6.1 -> '' 4.6.2 -> 'YES'\nprint(\"MALWARE-C2\" in mail.mail_json) # 4.6.1 -> False 4.6.2 -> True\nprint(mail.has_defects) # both -> False\n```\n\nA related case: `email.message.Message.__len__` returns the header count, so a message with\n**no headers** is falsy. `parse\n\nAffected packages: pip:mail-parser\nPatched: mail-parser 4.6.2","url":"https://github.com/advisories/GHSA-24mq-4vc6-2prf","published_at":"2026-11-16T22:12:51Z","updated_at":"2026-11-16T22:12:52Z","fetched_at":"2026-11-21T19:15:18.416870Z","severity":"medium","cvss_score":6.5,"epss":0.00355,"is_kev":false,"has_exploit":false,"kev_due_date":null,"vendor":null,"product":"mail-parser","vuln_id":"CVE-2026-129299","vuln_ids":["CVE-2026-129299","GHSA-24MQ-4VC6-2PRF"],"tags":["ghsa","pip","CWE-248","CWE-436"],"cluster_id":2399,"links":{"self":"https://vulnwatch.ve1ve2.com/api/v1/items/2480","html":"https://vulnwatch.ve1ve2.com/item/2480"}},{"id":6220,"source":{"id":"nvd","name":"NVD CVE API 2.0"},"title":"CVE-2026-129299: 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, m…","summary":"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.\n\nReferences:\nhttps://github.com/SpamScope/mail-parser/commit/ce3cf3559db1ff806bda598b378de9f8c2a5be96\nhttps://github.com/SpamScope/mail-parser/pull/167\nhttps://github.com/SpamScope/mail-parser/releases/tag/4.6.2\nhttps://github.com/SpamScope/mail-parser/security/advisories/GHSA-24mq-4vc6-2prf","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-129299","published_at":"2026-11-16T18:17:30.787000Z","updated_at":"2026-11-16T19:17:40.623000Z","fetched_at":"2026-11-21T19:15:31.481995Z","severity":"medium","cvss_score":6.5,"epss":0.00355,"is_kev":false,"has_exploit":false,"kev_due_date":null,"vendor":null,"product":null,"vuln_id":"CVE-2026-129299","vuln_ids":["CVE-2026-129299","GHSA-24MQ-4VC6-2PRF"],"tags":["CWE-248","CWE-436"],"cluster_id":1407,"links":{"self":"https://vulnwatch.ve1ve2.com/api/v1/items/6220","html":"https://vulnwatch.ve1ve2.com/item/6220"}}]}