CVE-2026-129299: mail-parser Uncaught Exceptions And Silent Header Vulnerability

MODERATE
Advisory Identifier: GHSA-24mq-4vc6-2prf
CVSS 6.5
CWE-436 CWE-248
Published
Advisory Summary

CVE-2026-129299 is a MODERATE (CVSS 6.5) uncaught exceptions and silent header vulnerability (CWE-436: Interpretation Conflict) affecting mail-parser libraries in the PyPI ecosystem. The issue involves uncaught exceptions and silent header loss in mail-parser on attacker-controlled input. Remediation is available by upgrading affected packages to version 4.6.2.

CVE-2026-129299 at a Glance

CVE Identifier CVE-2026-129299
GHSA Identifier GHSA-24mq-4vc6-2prf
Severity MODERATE
CVSS v3.1 Base Score 6.5
CWE Classification CWE-436: Interpretation Conflict
Affected Product mail-parser
Package Ecosystem PyPI
Published Date
Last Updated

Security Impact

CVSS: 6.5

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:L/A:L).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required None (PR:N)
User Interaction None (UI:N)
Scope Unchanged (S:U)
Confidentiality None (C:N)
Integrity Low (I:L)
Availability Low (A:L)

How to Fix CVE-2026-129299

To remediate this vulnerability, upgrade all affected mail-parser dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

mail-parser fixed: 4.6.2
pip install mail-parser>=4.6.2
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

pip show mail-parser

How to Check if You Are Affected

To determine whether your Python environment is affected by CVE-2026-129299, inspect your installed packages using pip:

pip show mail-parser

Analyze the terminal output to locate any version of mail-parser in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 4.6.2), your application is affected.

Note: The pip show mail-parser command checks currently installed packages in your active Python environment.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-436: Interpretation Conflict, where product a handles inputs or steps differently than product b, which causes a to perform incorrect actions based on its perception of b's state. In mail-parser, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

### Impact 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 `__getattr__`, so a header named after a method put a bound method object into the parsed mail dict. A 12-byte email is sufficient. Nine colliding names were confirmed: `Parse`, `Message`, `Write_Attachments`, `From_File`, `From_File_Obj`, `From_File_Msg`, `From_String`, `From_Bytes`, `Get_Server_Ipaddress`. Also reproducible from the CLI (`mail-parser -f evil.eml -j`). ```python import mailparser mailparser.parse_from_string("Parse: x\r\n\r\n").mail_json # 4.6.1 -> TypeError: Object of type method is not JSON serializable # 4.6.2 -> {"parse": "x", "has_defects": false} ``` *Header carrying 8-bit bytes* (CWE-248). For a header containing raw 8-bit bytes, Python's `compat32` policy returns an `email.header.Header` rather than a `str`, which the `_raw` accessor passed straight to `json.dumps`. This fires on entirely benign non-ASCII mail via `parse_from_bytes()`, the normal entry point for mail off the wire. ```python import mailparser mailparser.parse_from_bytes(b"Subject: caf\xe9\r\n\r\nbody\r\n").subject_raw # 4.6.1 -> TypeError: Object of type Header is not JSON serializable # 4.6.2 -> '["caf�"]' ``` **Silent loss of message content** (CWE-436). A sender can make a header's value vanish from every output surface, or be replaced by a different header's value, with `has_defects` remaining `false`. This is an evasion primitive: the tool's output diverges from the bytes actually in the message, and a pipeline scanning parsed output for indicators sees nothing and no failure signal. Header names were normalised before lookup — underscores folded to dashes, and `_json` / `_raw` suffixes interpreted — so a header genuinely named `Subject_json` was reported with the value of `Subject` and its own value discarded, and any header whose name contains an underscore resolved to nothing. ```python import mailparser raw = ("From: Real Sender <real@good.example>\r\n" "Subject: innocuous\r\n" "Subject_json: MALWARE-C2 http://evil.example/payload.exe\r\n" "X_Spam_Flag: YES\r\n\r\nbody\r\n") mail = mailparser.parse_from_string(raw) print(mail.mail["subject_json"]) # 4.6.1 -> '"innocuous"' 4.6.2 -> the real value print(mail.headers["X_Spam_Flag"]) # 4.6.1 -> '' 4.6.2 -> 'YES' print("MALWARE-C2" in mail.mail_json) # 4.6.1 -> False 4.6.2 -> True print(mail.has_defects) # both -> False ``` A related case: `email.message.Message.__len__` returns the header count, so a message with **no headers** is falsy. `parse()` returned before initialising state, and the unset attributes were then absorbed by `__getattr__` and answered as absent headers. Every property returned `''` — including `mail` and `attachments`, which are documented to return a `dict` and a `list` — with no error and no defect flag. ```python import mailparser mail = mailparser.parse_from_string("Click http://evil.example/pay.exe now\r\n") print(repr(mail.body)) # 4.6.1 -> '' 4.6.2 -> the text print(repr(mail.attachments)) # 4.6.1 -> '' 4.6.2 -> [] print(mail.has_defects) # 4.6.1 -> '' 4.6.2 -> True ``` ### Patches Fixed in **4.6.2**. Upgrade with `pip install --upgrade mail-parser`. Header names taken from a message are now looked up literally — no attribute access, no case or separator folding, no suffix interpretation — so no header name can collide with a method or property, and no value can be substituted or dropped. 8-bit values are coerced to `str` before serialisation. Parser state is initialised before the message check, which now tests `is None`, and attribute names beginning with `_` raise `AttributeError` instead of being answered as headers. **Behaviour changes.** Header names now appear in `mail` and `headers` exactly as sent, so a header named `X_Spam_Flag` keeps that name and its own value. `X_raw` always returns a JSON array — an absent header yields `[]` where 4.6.1 returned `null`. ### Workarounds None for the data loss. For the uncaught exceptions, callers who cannot upgrade should wrap `mail_json`, `mail_partial_json`, `headers_json` and any `X_raw` access in a bare `except Exception` rather than catching only `MailParserError` subclasses.

CVE-2026-129299 Affected mail-parser Versions

1 component(s)
Fixed Versions:
4.6.2
Product / Package Ecosystem Affected Versions Fixed Version
mail-parser
PyPI
< 4.6.2
4.6.2

References

Frequently Asked Questions

What is CVE-2026-129299?
CVE-2026-129299 is a security vulnerability in mail-parser involving Uncaught exceptions and silent header loss in mail-parser on attacker-controlled input under CWE-436: Interpretation Conflict.
Which mail-parser versions are affected?
Affected versions include releases prior to 4.6.2 across affected packages: mail-parser.
What version fixes CVE-2026-129299?
Upgrading to 4.6.2 (or the latest patched release for your respective branch) resolves the vulnerability.
Is mail-parser affected?
Yes, mail-parser is affected in releases prior to 4.6.2. Upgrade your dependency to 4.6.2 or later.
What is the CVSS score of CVE-2026-129299?
CVE-2026-129299 has a CVSS v3.1 base score of 6.5 (MODERATE) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:L/A:L.
What CWE is associated with CVE-2026-129299?
CVE-2026-129299 is classified under CWE-436: Interpretation Conflict (Product A handles inputs or steps differently than Product B, which causes A to perform incorrect actions based on its perception of B's state.).
How can I check PyPI dependencies for CVE-2026-129299?
Run the dependency tree command: 'pip show mail-parser'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-24mq-4vc6-2prf",
  "modified" : "2026-11-16T22:12:52Z",
  "published" : "2026-11-16T22:12:51Z",
  "aliases" : [ "CVE-2026-129299" ],
  "summary" : "mail-parser: Uncaught exceptions and silent header loss in mail-parser on attacker-controlled input",
  "details" : "### 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.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:L/A:L"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "PyPI",
      "name" : "mail-parser"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "4.6.2"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 4.6.1"
    }
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/SpamScope/mail-parser/security/advisories/GHSA-24mq-4vc6-2prf"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2026-129299"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/SpamScope/mail-parser/pull/167"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/SpamScope/mail-parser/commit/ce3cf3559db1ff806bda598b378de9f8c2a5be96"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/SpamScope/mail-parser"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/SpamScope/mail-parser/releases/tag/4.6.2"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-248", "CWE-436" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-11-16T22:12:51Z",
    "nvd_published_at" : "2026-11-16T18:17:30Z"
  }
}