Skip to content

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

High
fedelemantuano published GHSA-72px-j8gh-p79x Aug 12, 2026

Package

pip mail-parser (pip)

Affected versions

<= 4.6.1

Patched versions

4.6.2

Description

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

Severity

High

CVSS overall score

This score calculates overall vulnerability severity from 0 to 10 and is based on the Common Vulnerability Scoring System (CVSS).
/ 10

CVSS v3 base metrics

Attack vector
Network
Attack complexity
Low
Privileges required
None
User interaction
None
Scope
Unchanged
Confidentiality
None
Integrity
High
Availability
None

CVSS v3 base metrics

Attack vector: More severe the more the remote (logically and physically) an attacker can be in order to exploit the vulnerability.
Attack complexity: More severe for the least complex attacks.
Privileges required: More severe if no privileges are required.
User interaction: More severe when no user interaction is required.
Scope: More severe when a scope change occurs, e.g. one vulnerable component impacts resources in components beyond its security scope.
Confidentiality: More severe when loss of data confidentiality is highest, measuring the level of data access available to an unauthorized user.
Integrity: More severe when loss of data integrity is the highest, measuring the consequence of data modification possible by an unauthorized user.
Availability: More severe when the loss of impacted component availability is highest.
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:N

CVE ID

No known CVE

Weaknesses

Improper Input Validation

The product receives input or data, but it does not validate or incorrectly validates that the input has the properties that are required to process the data safely and correctly. Learn more on MITRE.

Insufficient Verification of Data Authenticity

The product does not sufficiently verify the origin or authenticity of data, in a way that causes it to accept invalid data. Learn more on MITRE.

Credits