Home/Research/Post

GHSA-24mq-4vc6-2prf: mail-parser: Uncaught exceptions and silent header loss in mail-parser on attacker-controlled input

  • Severity: MEDIUM
  • CVE: CVE-2026-129299
  • Ecosystems: pip
  • Packages: mail-parser

### 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”…

Source: GitHub Security Advisories · 2026-11-16