CVE-2026-129297
Spoofable sender IP due to untrusted Received header parsing (pre‑4.6.2).
- CVSS 7.5
- CWE-345
- Input Validation and Sanitization
- Remote
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.
- CWE
- CWE-345
- CVSS base score
- 7.5
- Published
- 2026-11-16
- OWASP
- A04 Insecure Design
- Orthogonal defect classification
- Algorithm
- Code defect classification
- Incorrect Algorithm
- Category
- Input Validation and Sanitization
- Subcategory
- Insecure Parsing or Deserialization
- Accessibility scope
- Remote
- Impact
- Information Disclosure
- Affected component
- mail-parser
- Fixed by upgrading
- Yes
Solution
Upgrade mail-parser to version 4.6.2 or later.
Vulnerable code sample
import re
import mailparser
def get_server_ipaddress(raw_email):
"""
Extract the sending server IP from the first Received header.
"""
parsed = mailparser.parse_from_string(raw_email)
# VULNERABLE: trusts the first IP found in Received headers without validation
for header in parsed.headers.get('Received', []):
# naive split, picks anything that looks like an IP
parts = header.split()
for part in parts:
if re.match(r'\d+\.\d+\.\d+\.\d+', part):
return part
return NonePatched code sample
import re
import mailparser
def get_server_ipaddress(raw_email):
"""
Extract the sending server IP, ignoring attacker‑controlled text.
"""
ip_regex = re.compile(
r'\[(?P<ipv4>(?:\d{1,3}\.){3}\d{1,3})\]|' # [1.2.3.4]
r'\[(?P<ipv6>[:0-9a-fA-F]+)\]|' # [2001:db8::1]
r'(?P<helo>HELO\s+\S+)' # HELO example.com
)
parsed = mailparser.parse_from_string(raw_email)
# FIX: only accept bracketed IPs or HELO markers, skip untrusted hops
for header in parsed.headers.get('Received', []):
match = ip_regex.search(header)
if match:
if match.group('ipv4') or match.group('ipv6'):
# strip brackets
return match.group('ipv4') or match.group('ipv6')
elif match.group('helo'):
# treat HELO marker as trusted hop, continue searching
continue
return NonePublished fix
Public sources link this CVE to the changes below. The code samples above were generated to illustrate the defect; these links lead to the code the project actually changed.
- Fixed many bugs (#167) (SpamScope/mail-parser)
src/mailparser/const.py,src/mailparser/core.py,src/mailparser/core.py · MailParser.get_server_ipaddress,src/mailparser/core.py · MailParser.headers,src/mailparser/core.py · MailParser.parse,src/mailparser/core.py · MailParser._extract_ip,src/mailparser/core.py · MailParser._make_mail,src/mailparser/core.py · MailParser._reset,src/mailparser/core.py · MailParser.__getattr__,src/mailparser/core.py · MailParser.__init__,src/mailparser/utils.py,src/mailparser/utils.py · get_header
Cite this entry
@misc{vaitp:cve2026129297,
title = {{Spoofable sender IP due to untrusted Received header parsing (pre‑4.6.2).}},
author = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
year = {2026},
note = {VAITP Python Vulnerability Dataset, entry CVE-2026-129297},
howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2026-129297/}}
}
Introducing the "VAITP dataset": a specialized repository of Python vulnerabilities and patches, meticulously compiled for the use of the security research community. As Python's prominence grows, understanding and addressing potential security vulnerabilities become crucial. Crafted by and for the cybersecurity community, this dataset offers a valuable resource for researchers, analysts, and developers to analyze and mitigate the security risks associated with Python. Through the comprehensive exploration of vulnerabilities and corresponding patches, the VAITP dataset fosters a safer and more resilient Python ecosystem, encouraging collaborative advancements in programming security.
The supreme art of war is to subdue the enemy without fighting.
Sun Tzu – “The Art of War”
:: Shaping the future through research and ingenuity ::
