CVE-2026-129297
JSON

7.5high

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

Severity
7.5high CVSS:3.1 by GitHub_M
Exploit likelihood
0.20% (higher than 10% of CVEs; EPSS, by FIRST)
Published
Last changed
Assigned by
GitHub_M
Also known as
GHSA-72px-j8gh-p79x

Description

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, get_server_ipaddress() can select an attacker-controlled address from attacker-controlled Received headers. The minimum mechanism needed to distinguish this spoofing issue, derived from the advisory's remediation analysis and verified fix evidence, is appearance-based candidate selection that can treat bracketed IPv4 or IPv6 addresses or HELO markers in sender-written text as MTA-recorded addresses and can continue past a trusted hop that names no address. Applications that rely on the returned value can attribute a message to an attacker-selected sender IP address. This issue is fixed in version 4.6.2.

Affected

Product or packageVersionsReported by
SpamScope mail-parser< 4.6.2CVE List
mail-parser (PyPI)before 4.6.2GitHub Advisory Database

All scores

GitHub_M7.5high CVSS:3.1CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:N
GitHub7.5high CVSS:3.1CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:N

Classification

CWE-20CWE-345

SSVC (CISA-ADP): exploitation none, automatable yes, technical impact partial.

What each source says

CVE List

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, get_server_ipaddress() can select an attacker-controlled address from attacker-controlled Received headers. The minimum mechanism needed to distinguish this spoofing issue, derived from the advisory's remediation analysis and verified fix evidence, is appearance-based candidate selection that can treat bracketed IPv4 or IPv6 addresses or HELO markers in sender-written text as MTA-recorded addresses and can continue past a trusted hop that names no address. Applications that rely on the returned value can attribute a message to an attacker-selected sender IP address. This issue is fixed in version 4.6.2.

GitHub Advisory Database
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 group is sender text and is excluded;
  • a candidate must sit inside a ( / [ group;
  • IPv4 and IPv6 matches are merged positionally, never family-first;
  • the walk stops at the first trusted hop naming no address, rather than continuing into sender-written headers.

The IPv6 pattern was corrected to skip the IPv6: tag and to prefer the longest valid form.

Behaviour change. get_server_ipaddress() now returns None rather than an unreliable value in two cases that previously returned an address: a from clause consisting of a bare address with no HELO marker (indistinguishable from EHLO <that address>), and a trusted hop naming no address at all. Callers must handle None.

Workarounds

None within mail-parser. Callers who cannot upgrade should not treat the return value of get_server_ipaddress() as trustworthy, and should derive sender attribution from an authenticated signal instead — the MTA's own logs, or SPF/DKIM/DMARC results computed outside this library.

References

Sources

SourceRecordLicence
CVE ListCVE-2026-129297 changed 2026-11-16CVE Terms of Use
GitHub Advisory DatabaseGHSA-72px-j8gh-p79x changed 2026-11-16CC-BY-4.0
NVDCVE-2026-129297 changed 2026-11-16Public domain