{"id":"CVE-2026-129299","kind":"vulnerability","aliases":["CVE-2026-129299","GHSA-24mq-4vc6-2prf"],"related":[],"title":"mail-parser: Uncaught exceptions and silent header loss in mail-parser on attacker-controlled input","description":"### 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 <real@good.example>\\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()` returned before initialising state, and the unset\nattributes were then absorbed by `__getattr__` and answered as absent headers. Every\nproperty returned `''` — including `mail` and `attachments`, which are documented to return\na `dict` and a `list` — with no error and no defect flag.\n\n```python\nimport mailparser\nmail = mailparser.parse_from_string(\"Click http://evil.example/pay.exe now\\r\\n\")\nprint(repr(mail.body))         # 4.6.1 -> ''    4.6.2 -> the text\nprint(repr(mail.attachments))  # 4.6.1 -> ''    4.6.2 -> []\nprint(mail.has_defects)        # 4.6.1 -> ''    4.6.2 -> True\n```\n\n### Patches\n\nFixed in **4.6.2**. Upgrade with `pip install --upgrade mail-parser`.\n\nHeader names taken from a message are now looked up literally — no attribute access, no\ncase or separator folding, no suffix interpretation — so no header name can collide with a\nmethod or property, and no value can be substituted or dropped. 8-bit values are coerced to\n`str` before serialisation. Parser state is initialised before the message check, which now\ntests `is None`, and attribute names beginning with `_` raise `AttributeError` instead of\nbeing answered as headers.\n\n**Behaviour changes.** Header names now appear in `mail` and `headers` exactly as sent, so a\nheader named `X_Spam_Flag` keeps that name and its own value. `X_raw` always returns a JSON\narray — an absent header yields `[]` where 4.6.1 returned `null`.\n\n### Workarounds\n\nNone for the data loss. For the uncaught exceptions, callers who cannot upgrade should wrap\n`mail_json`, `mail_partial_json`, `headers_json` and any `X_raw` access in a bare\n`except Exception` rather than catching only `MailParserError` subclasses.","summary":"mail-parser is a Python library for parsing email messages. Crafted headers can raise exceptions, silently drop content, or make body and attachment fields come back empty, which can abort processing or hide indicators from downstream scanners.","severity":"medium","cvss":6.5,"epss":null,"exploited":false,"exploited_at":null,"products":[{"name":"mail-parser","fixed":["4.6.2"],"affected":"<= 4.6.1","ecosystem":"pypi"}],"ecosystems":["pypi"],"tags":["cwe-248","cwe-436","email-processing","mail-parser","package","python"],"not_affected_if":["no-untrusted-email-input","version-4.6.2-or-later"],"how_to_check":"- `pip show mail-parser` or check the installed version in requirements.txt or the lockfile\n- Confirm whether the affected version is below `4.6.2`","fix":"- Upgrade mail-parser to `4.6.2` or later","status":"open","published_at":"2026-11-16T18:17:30+00:00","first_seen_at":"2026-11-16T18:38:03+00:00","triaged_at":"2026-11-16T18:39:07+00:00","updated_at":"2026-11-16T22:17:23+00:00","category":"package","confidence":0.7,"triage":{"at":"2026-11-16T18:39:07Z","model":"claude-haiku-5-5","output":{"fix":"- Upgrade mail-parser to `4.6.2` or later","reach":"network","title":"mail-parser: header handling bugs crash parsing and hide content from scanners","impact":"low","summary":"mail-parser is a Python library for parsing email messages. Crafted headers can raise exceptions, silently drop content, or make body and attachment fields come back empty, which can abort processing or hide indicators from downstream scanners.","audience":"developers","category":"package","nicknames":[],"who_cares":["python","mail-parser","email-processing"],"confidence":0.7,"fix_status":"available","needs_auth":"no","worst_case":"Message processing aborts and malicious indicators go unseen by scanners","analyst_note":"","how_to_check":"- `pip show mail-parser` or check the installed version in requirements.txt or the lockfile\n- Confirm whether the affected version is below `4.6.2`","plain_action":"","product_name":"mail-parser","needs_analyst":false,"not_affected_if":["version-4.6.2-or-later","no-untrusted-email-input"],"who_is_affected":"Applications that use mail-parser in Python to process untrusted inbound email, such as mail gateways, scanners or ticketing pipelines, are the exposed case. Code that only parses messages you produce yourself is unlikely to be reached by crafted headers. The sources do not describe the exact exposure beyond the affected versions.","user_interaction":"no","product_ecosystem":"pypi","needs_special_setup":"unknown","severity_if_unknown":"unknown"},"cost_usd":0.000753,"input_tokens":4859,"output_tokens":535,"severity_before":"medium"},"analyst_status":null,"analyst_note":null,"search":"'-129299':21A,29A '-2026':20A,28A '-248':34B,146C,253C '-436':36B,339C '/pay.exe':586C '/payload.exe':464C '1':92C '12':177C '24mq':24A '2prf':26A '4.6.1':231C,321C,486C,497C,507C,593C,600C,605C '4.6.2':241C,331C,488C,498C,509C,594C,601C,606C,611C '4vc6':25A '8':249C,259C,661C 'abort':75B 'absent':550C 'absorb':544C 'access':633C 'accessor':276C 'actual':380C 'advisori':91C 'also':206C 'answer':548C 'ascii':288C 'attach':68B,190C,558C 'attack':16A 'attacker-control':15A 'attribut':103C,156C,541C,632C 'b':309C 'back':71B 'benign':285C 'bit':250C,260C,662C 'bodi':66B 'bound':168C 'byte':178C,202C,251C,261C,293C,308C,379C 'c2':461C,503C 'caf':311C,332C 'caller':125C 'carri':248C 'case':518C,635C 'catch':126C,134C 'caus':89C 'chosen':95C 'class':155C 'cli':210C 'click':583C 'coerc':665C 'collid':183C,647C 'come':70B 'compat32':264C 'confirm':186C 'contain':257C,437C 'content':63B,337C 'control':17A 'count':524C 'craft':56B,112C 'cve':19A,27A 'cwe':33B,35B,145C,252C,338C 'dash':407C 'defect':245C,364C,513C,574C,604C 'dict':175C,565C 'die':139C 'differ':358C 'discard':431C 'diverg':376C 'document':561C 'downstream':81B 'drop':62B,660C 'effect':85C 'email':38B,54B,179C 'email-process':37B 'email.header.header':268C 'email.message.message':519C 'empti':72B 'entir':284C 'entri':296C 'error':571C 'evas':370C 'everi':350C,552C 'evil.eml':215C 'evil.example':463C,585C 'evil.example/pay.exe':584C 'evil.example/payload.exe':462C 'except':5A,60B,110C,116C,131C 'f':214C 'failur':396C 'fals':246C,366C,508C,515C 'falsi':532C 'field':69B 'file':192C,194C,197C 'fire':282C 'fix':609C 'flag':469C,496C,575C 'fold':405C,638C 'genuin':416C 'get':203C 'getattr':158C,546C 'ghsa':23A 'ghsa-24mq-4vc6-2prf':22A 'header':8A,57B,93C,140C,161C,247C,256C,326C,345C,359C,398C,415C,434C,523C,530C,551C,620C,644C 'hide':78B 'hierarchi':122C 'iam':150C 'iam-niranjan':149C 'impact':83C 'import':218C,304C,444C,577C 'includ':555C 'indic':79B,391C 'initiali':673C 'initialis':536C 'innocu':454C,487C 'input':18A 'instal':615C 'interpret':412C,641C 'ipaddress':205C 'j':216C 'json':230C,239C,329C,409C,419C,458C,485C,506C 'json.dumps':280C 'len':520C 'librari':51B 'list':568C 'liter':630C 'look':628C 'lookup':104C,108C,403C 'loss':9A,334C 'mail':2A,12A,31A,41B,46B,129C,174C,212C,229C,289C,299C,477C,556C,579C,618C 'mail-pars':1A,11A,40B,45B,128C,211C,617C 'mail-parser':30A 'mail.attachments':599C 'mail.body':592C 'mail.has':512C,603C 'mail.headers':493C 'mail.mail':483C,505C 'mailpars':121C,219C,305C,445C,578C 'mailparser.parse':220C,306C,478C,580C 'make':65B,343C 'malwar':460C,502C 'malware-c2':459C,501C 'messag':55B,113C,188C,336C,383C,527C,625C 'method':144C,165C,169C,236C,650C 'msg':198C 'n':226C,228C,314C,318C,452C,456C,466C,472C,476C,589C 'name':94C,141C,162C,184C,399C,417C,436C,621C,645C 'nbodi':316C,474C 'nine':182C 'niranjan':151C 'non':287C 'non-ascii':286C 'normal':295C 'normalis':401C 'noth':393C,442C 'obj':195C 'object':170C,233C,323C 'output':351C,375C,389C 'outsid':119C 'packag':43B 'pars':53B,173C,187C,223C,242C,291C,388C,533C 'parser':3A,13A,32A,42B,47B,130C,213C,619C,670C 'pass':277C 'patch':608C 'pip':614C 'pipelin':386C 'point':297C 'polici':265C 'primit':371C 'print':482C,492C,500C,511C,590C,597C,602C 'process':39B,76B 'properti':553C,652C 'put':166C 'python':44B,50B,102C,152C,217C,262C,303C,443C,576C 'r':225C,227C,313C,315C,317C,451C,455C,465C,471C,473C,475C,588C 'rais':59B,114C 'rather':269C 'raw':258C,275C,320C,410C,446C,481C 'real':154C,448C,490C 'real@good.example':450C 'relat':517C 'remain':365C 'replac':355C 'report':147C,421C 'repr':591C,598C 'reproduc':207C 'resolv':100C,153C,440C 'return':266C,521C,534C,554C,563C 'rewritten':106C 'root':88C 'scan':387C 'scanner':82B 'see':392C 'sender':98C,341C,449C 'separ':637C 'serialis':669C 'serializ':240C,330C 'server':204C 'share':86C 'signal':397C 'silent':7A,61B,333C 'spam':468C,495C 'state':537C,671C 'str':272C,667C 'straight':278C 'string':200C,222C,480C,582C 'subject':310C,319C,418C,426C,453C,457C,484C 'substitut':658C 'suffici':181C 'suffix':411C,640C 'surfac':352C 'taken':622C 'text':596C 'tool':373C 'true':510C,607C 'two':84C 'type':235C,325C 'typeerror':232C,322C 'uncaught':4A,109C 'underscor':404C,439C 'unset':540C 'upgrad':612C,616C 'valu':347C,361C,424C,430C,491C,655C,663C 'vanish':348C 'via':290C 'whose':435C 'wire':302C 'worker':138C 'write':189C 'x':224C,243C,467C,494C 'xe9':312C 'yes':470C,499C","nicknames":[],"mitigations":[],"who_affected":"Applications that use mail-parser in Python to process untrusted inbound email, such as mail gateways, scanners or ticketing pipelines, are the exposed case. Code that only parses messages you produce yourself is unlikely to be reached by crafted headers. The sources do not describe the exact exposure beyond the affected versions.","tier":"C","verified":{},"analyst_revisit_at":null,"fix_status":"available","audience":"developers","plain_action":null,"pkeys":["mailparser"],"ptokens":["mail","parser"],"labels":["cwe248","cwe436","emailprocessing","mailparser","medium","package","pypi","python"],"campaign_type":null,"search_a":"'-129299':21A,29A '-2026':20A,28A '24mq':24A '2prf':26A '4vc6':25A 'attack':16A 'attacker-control':15A 'control':17A 'cve':19A,27A 'except':5A 'ghsa':23A 'ghsa-24mq-4vc6-2prf':22A 'header':8A 'input':18A 'loss':9A 'mail':2A,12A,31A 'mail-pars':1A,11A 'mail-parser':30A 'parser':3A,13A,32A 'silent':7A 'uncaught':4A","search_b":"'-248':34B '-436':36B 'abort':75B 'attach':68B 'back':71B 'bodi':66B 'come':70B 'content':63B 'craft':56B 'cwe':33B,35B 'downstream':81B 'drop':62B 'email':38B,54B 'email-process':37B 'empti':72B 'except':60B 'field':69B 'header':57B 'hide':78B 'indic':79B 'librari':51B 'mail':41B,46B 'mail-pars':40B,45B 'make':65B 'messag':55B 'packag':43B 'pars':53B 'parser':42B,47B 'process':39B,76B 'python':44B,50B 'rais':59B 'scanner':82B 'silent':61B","search_c":"'-248':146C,253C '-436':339C '/pay.exe':586C '/payload.exe':464C '1':92C '12':177C '4.6.1':231C,321C,486C,497C,507C,593C,600C,605C '4.6.2':241C,331C,488C,498C,509C,594C,601C,606C,611C '8':249C,259C,661C 'absent':550C 'absorb':544C 'access':633C 'accessor':276C 'actual':380C 'advisori':91C 'also':206C 'answer':548C 'ascii':288C 'attach':190C,558C 'attribut':103C,156C,541C,632C 'b':309C 'benign':285C 'bit':250C,260C,662C 'bound':168C 'byte':178C,202C,251C,261C,293C,308C,379C 'c2':461C,503C 'caf':311C,332C 'caller':125C 'carri':248C 'case':518C,635C 'catch':126C,134C 'caus':89C 'chosen':95C 'class':155C 'cli':210C 'click':583C 'coerc':665C 'collid':183C,647C 'compat32':264C 'confirm':186C 'contain':257C,437C 'content':337C 'count':524C 'craft':112C 'cwe':145C,252C,338C 'dash':407C 'defect':245C,364C,513C,574C,604C 'dict':175C,565C 'die':139C 'differ':358C 'discard':431C 'diverg':376C 'document':561C 'drop':660C 'effect':85C 'email':179C 'email.header.header':268C 'email.message.message':519C 'entir':284C 'entri':296C 'error':571C 'evas':370C 'everi':350C,552C 'evil.eml':215C 'evil.example':463C,585C 'evil.example/pay.exe':584C 'evil.example/payload.exe':462C 'except':110C,116C,131C 'f':214C 'failur':396C 'fals':246C,366C,508C,515C 'falsi':532C 'file':192C,194C,197C 'fire':282C 'fix':609C 'flag':469C,496C,575C 'fold':405C,638C 'genuin':416C 'get':203C 'getattr':158C,546C 'header':93C,140C,161C,247C,256C,326C,345C,359C,398C,415C,434C,523C,530C,551C,620C,644C 'hierarchi':122C 'iam':150C 'iam-niranjan':149C 'impact':83C 'import':218C,304C,444C,577C 'includ':555C 'indic':391C 'initiali':673C 'initialis':536C 'innocu':454C,487C 'instal':615C 'interpret':412C,641C 'ipaddress':205C 'j':216C 'json':230C,239C,329C,409C,419C,458C,485C,506C 'json.dumps':280C 'len':520C 'list':568C 'liter':630C 'look':628C 'lookup':104C,108C,403C 'loss':334C 'mail':129C,174C,212C,229C,289C,299C,477C,556C,579C,618C 'mail-pars':128C,211C,617C 'mail.attachments':599C 'mail.body':592C 'mail.has':512C,603C 'mail.headers':493C 'mail.mail':483C,505C 'mailpars':121C,219C,305C,445C,578C 'mailparser.parse':220C,306C,478C,580C 'make':343C 'malwar':460C,502C 'malware-c2':459C,501C 'messag':113C,188C,336C,383C,527C,625C 'method':144C,165C,169C,236C,650C 'msg':198C 'n':226C,228C,314C,318C,452C,456C,466C,472C,476C,589C 'name':94C,141C,162C,184C,399C,417C,436C,621C,645C 'nbodi':316C,474C 'nine':182C 'niranjan':151C 'non':287C 'non-ascii':286C 'normal':295C 'normalis':401C 'noth':393C,442C 'obj':195C 'object':170C,233C,323C 'output':351C,375C,389C 'outsid':119C 'pars':173C,187C,223C,242C,291C,388C,533C 'parser':130C,213C,619C,670C 'pass':277C 'patch':608C 'pip':614C 'pipelin':386C 'point':297C 'polici':265C 'primit':371C 'print':482C,492C,500C,511C,590C,597C,602C 'properti':553C,652C 'put':166C 'python':102C,152C,217C,262C,303C,443C,576C 'r':225C,227C,313C,315C,317C,451C,455C,465C,471C,473C,475C,588C 'rais':114C 'rather':269C 'raw':258C,275C,320C,410C,446C,481C 'real':154C,448C,490C 'real@good.example':450C 'relat':517C 'remain':365C 'replac':355C 'report':147C,421C 'repr':591C,598C 'reproduc':207C 'resolv':100C,153C,440C 'return':266C,521C,534C,554C,563C 'rewritten':106C 'root':88C 'scan':387C 'see':392C 'sender':98C,341C,449C 'separ':637C 'serialis':669C 'serializ':240C,330C 'server':204C 'share':86C 'signal':397C 'silent':333C 'spam':468C,495C 'state':537C,671C 'str':272C,667C 'straight':278C 'string':200C,222C,480C,582C 'subject':310C,319C,418C,426C,453C,457C,484C 'substitut':658C 'suffici':181C 'suffix':411C,640C 'surfac':352C 'taken':622C 'text':596C 'tool':373C 'true':510C,607C 'two':84C 'type':235C,325C 'typeerror':232C,322C 'uncaught':109C 'underscor':404C,439C 'unset':540C 'upgrad':612C,616C 'valu':347C,361C,424C,430C,491C,655C,663C 'vanish':348C 'via':290C 'whose':435C 'wire':302C 'worker':138C 'write':189C 'x':224C,243C,467C,494C 'xe9':312C 'yes':470C,499C","cause_entry":null,"cause_path":null,"disclosures_checked_at":null,"first_public_at":"2026-08-12T21:02:00+00:00","kev":null,"cvss_vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:L/A:L","cvss_by":"GitHub","poc_count":0,"sources":[{"source":"nvd","external_id":"CVE-2026-129299","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-129299","severity":null,"published_at":"2026-11-16T18:17:30+00:00","modified_at":"2026-11-16T18:17:30+00:00","first_seen_at":"2026-11-16T18:38:03+00:00","fetched_at":"2026-11-16T18:38:03+00:00","note":null},{"source":"ghsa","external_id":"GHSA-24mq-4vc6-2prf","url":"https://github.com/advisories/GHSA-24mq-4vc6-2prf","severity":"medium","published_at":"2026-11-16T22:12:51+00:00","modified_at":"2026-11-16T22:12:52+00:00","first_seen_at":"2026-11-16T22:17:23+00:00","fetched_at":"2026-11-16T22:22:36+00:00","note":null}],"documents":[{"id":171755,"url":"https://github.com/SpamScope/mail-parser/commit/ce3cf3559db1ff806bda598b378de9f8c2a5be96","title":"Patch: github.com","kind":"other","source":"nvd","publisher":"vendor","text":null,"published_at":null,"relation":"fix","confidence":null,"note":"Patch: github.com"},{"id":171756,"url":"https://github.com/SpamScope/mail-parser/releases/tag/4.6.2","title":"Release notes: github.com","kind":"release","source":"nvd","publisher":"vendor","text":null,"published_at":null,"relation":"fix","confidence":null,"note":"Release notes: github.com"},{"id":171760,"url":"https://github.com/SpamScope/mail-parser/security/advisories/GHSA-24mq-4vc6-2prf","title":"Vendor advisory: github.com","kind":"vendor","source":"nvd","publisher":"vendor","text":null,"published_at":"2026-08-12T21:02:00+00:00","relation":"advisory","confidence":null,"note":"Vendor advisory: github.com"},{"id":172712,"url":"https://api.github.com/repos/SpamScope/mail-parser/security-advisories/GHSA-24mq-4vc6-2prf","title":"Maintainer's advisory: api.github.com","kind":"vendor","source":"ghsa","publisher":"vendor","text":null,"published_at":null,"relation":"advisory","confidence":null,"note":"Maintainer's advisory: api.github.com"},{"id":172678,"url":"https://github.com/SpamScope/mail-parser/pull/167","title":"Patch: github.com","kind":"other","source":"ghsa","publisher":"vendor","text":null,"published_at":null,"relation":"fix","confidence":null,"note":"Patch: github.com"}],"disclosures":[],"exploit_sources":[],"notice":"Free to read, with fair use of about 60 pages a minute. For higher limits or API access: sales@infrastack.ai"}