CVE-2026-129297: Sender IP Address Spoofing in SpamScope mail-parser
Vulnerability ID: CVE-2026-129297
CVSS Score: 7.5
Published: 2026-11-16
CVE-2026-129297 is an origin validation vulnerability (CWE-345) in the Python library mail-parser prior to version 4.6.2. The MailParser.get_server_ipaddress() method fails to properly isolate MTA-recorded client IP addresses from sender-controlled text within email Received headers. Due to naive substring delimiter matching, appearance-based regular expression scanning, and fail-open header traversal, remote attackers can spoof their originating IP address to bypass email security controls, blocklists, and anti-spam attribution.
TL;DR
SpamScope mail-parser versions prior to 4.6.2 are vulnerable to sender IP spoofing in get_server_ipaddress(). An attacker can craft HELO strings or pre-populate Received headers to force the parser to ignore the legitimate MTA hop and return an arbitrary attacker-chosen IP address. Upgrade to mail-parser 4.6.2 to resolve the issue.
⚠️ Exploit Status: POC
Technical Details
- Vulnerability ID: CVE-2026-129297 (GHSA-72px-j8gh-p79x)
- CWE Classification: CWE-345 (Insufficient Verification of Data Authenticity)
- CVSS v3.1 Score: 7.5 HIGH (CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:N)
- Affected Component: mailparser.MailParser.get_server_ipaddress() in SpamScope/mail-parser (< 4.6.2)
- Attack Vector: Network (Crafted SMTP HELO/EHLO strings and forged Received headers)
- Primary Impact: Sender IP address spoofing, subverting email attribution and IP blocklists/allowlists
- Exploit Status: Proof-of-Concept (Regression tests public in official repository)
- Patched Version: mail-parser 4.6.2
Affected Systems
- SpamScope mail-parser (PyPI package)
-
mail-parser: < 4.6.2 (Fixed in:
4.6.2)
Code Analysis
Commit: ce3cf35
Replace appearance-based IP extraction with positional candidate selection, anchored clause splitting, and fail-closed Received header traversal.
diff --git a/src/mailparser/core.py b/src/mailparser/core.py
--- a/src/mailparser/core.py
+++ b/src/mailparser/core.py
@@ -554,11 +680,19 @@ def get_server_ipaddress(self, trust):
In our case we trust only our mail server with the trust string.
+ The walk continues only while a trusted hop names a *private* IP,
+ which marks an internal relay. A trusted hop naming no IP at all
+ ends the search with None: extraction failing there used to
+ drop the loop into older Received headers, which the sender wrote,
+ so every trick that defeats extraction on the genuine hop returned
+ an attacker-chosen IP instead of nothing (CWE-345).
+
Args:
trust (string): String that identify our mail server
Returns:
- string with the ip address
+ string with the ip address, or None when no trusted hop names
+ a public sender IP
"""
log.debug(f"Trust string is {trust!r}")
@@ -572,35 +706,115 @@ def get_server_ipaddress(self, trust):
for i in received:
i = ported_string(i)
- if trust in i:
- log.debug(f"Trust string {trust!r} is in {i!r}")
- ip_str = self._extract_ip(i)
- if ip_str:
- return ip_str
+ if trust not in i:
+ continue
+
+ log.debug(f"Trust string {trust!r} is in {i!r}")
+ candidates = self._sender_ip_candidates(i)
+ if not candidates:
+ # Nothing to read on an authoritative hop: stop, never fall
+ # through to a header the sender controls.
+ log.debug("Trusted hop names no sender IP, stopping")
+ return None
+
+ ip_str = self._public_ip(candidates)
+ if ip_str:
+ return ip_str
+ # Private IP: an internal relay, keep following the chain.
Exploit Details
- GitHub: Regression test cases in tests/test_mail_parser.py demonstrating HELO delimiter truncation, header fall-through, and address literal spoofing.
Mitigation Strategies
- Upgrade mail-parser to version 4.6.2 or later to enforce positional IP extraction and fail-closed header traversal.
- Cross-reference extracted sender IP addresses with authoritative edge MTA transaction logs before executing automated blocklisting or attribution actions.
- Configure edge MTAs to strip external Authentication-Results or custom client-IP headers and inject a dedicated, trusted header containing the peer socket IP.
Remediation Steps:
- Identify all Python applications, virtual environments, and container images utilizing the mail-parser package.
- Update dependency manifests (requirements.txt, Pipfile, pyproject.toml) to pin mail-parser>=4.6.2.
- Run 'pip install --upgrade mail-parser>=4.6.2' and redeploy affected email processing services.
- Audit historical threat intelligence or blocklist entries generated by get_server_ipaddress() for discrepancies against raw MTA logs.
References
- GitHub Security Advisory GHSA-72px-j8gh-p79x
- Fix Commit ce3cf3559db1ff806bda598b378de9f8c2a5be96
- GitHub Pull Request #167
- mail-parser Release 4.6.2
- NVD Vulnerability Detail: CVE-2026-129297
- CVE.org Record: CVE-2026-129297
- CVEProject cvelistV5 Record
Read the full report for CVE-2026-129297 on our website for more details including interactive diagrams and full exploit analysis.
Top comments (0)