Nov 17, 2026·11 min read·1 visit
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.
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.
mail-parser (distributed on PyPI and maintained by SpamScope) is a Python wrapper around the standard library email module designed to parse raw electronic mail messages into structured Python objects. It is widely used in automated email ingestion pipelines, threat intelligence platforms, and spam analysis frameworks to extract message headers, attachments, and routing metadata.
A critical security function provided by mail-parser is MailParser.get_server_ipaddress(trust). This method iterates through a message's Received header chain to identify the public IP address of the external mail relay that delivered the message to a trusted Mail Transfer Agent (MTA), identified by the caller-supplied trust string.
In versions prior to 4.6.2, get_server_ipaddress() suffers from Insufficient Verification of Data Authenticity (CWE-345). The parser relies on unanchored substring searches to locate header clause boundaries, uses appearance-based regular expressions rather than positional token parsing to extract IP candidates, and fails open when a matching hop yields no public IP address.
Because an unauthenticated remote sender controls the HELO/EHLO identifier recorded in the legitimate MTA's Received header—as well as any historical Received headers appended prior to message delivery—an attacker can manipulate the parsing logic. Downstream applications relying on get_server_ipaddress() for IP reputation checks, blocklisting, allowlisting, or forensic attribution can be forced to attribute incoming emails to an arbitrary IPv4 or IPv6 address.
The vulnerability in get_server_ipaddress() stems from three distinct flaws in how Received headers (defined in RFC 5321 Section 4.4) are parsed and evaluated.
An RFC 5321 Received header consists of structured clauses separated by whitespace-delimited keywords, primarily from <sending-host> and by <receiving-host>. To isolate the sending host information, mail-parser prior to 4.6.2 executed a naive substring search for the characters "by":
by_idx = received_header.find("by")
from_part = received_header[:by_idx] if by_idx != -1 else received_headerBecause str.find("by") does not enforce token boundaries, any HELO/EHLO hostname supplied by the connecting client that contains the substring "by" (for example, derby.attacker.com or nearby.example.org) triggers a match inside the hostname token itself. The parser slices received_header at the first occurrence of "by", discarding the remainder of the from clause—including the parenthesized client IP address recorded by the trusted MTA.
When inspecting the Received header list from top (most recent) to bottom (oldest), get_server_ipaddress() checks whether the trust string appears in the header. In a standard deployment, if a trusted edge MTA hands the message to an internal relay, the topmost hop records a private IP address, requiring the parser to step down to the next trusted hop to find the external public IP.
However, in vulnerable versions, if _extract_ip() returned None on a trusted hop (either because no IP existed or because delimiter truncation stripped the IP from from_part), the loop did not terminate. Instead, it continued iterating into older Received headers. Because a remote sender can prepend arbitrary forged Received headers containing the victim's trust string before transmitting the email, forcing extraction to fail on the legitimate edge hop causes the parser to fall through into sender-crafted headers.
Even without triggering delimiter truncation and header fall-through, _extract_ip() selected IP addresses based on regex appearance rather than syntactic token position. Under RFC 5321 Section 4.1.3, a client may send an address literal as its EHLO argument (e.g., EHLO [8.8.8.8]), which MTAs record as the first token after from (e.g., Received: from [8.8.8.8] (real.client.net [1.2.3.4]) by mx.victim.com).
Because REGXIP.findall(from_part) scanned left-to-right across the entire from_part string, it matched the sender-supplied EHLO address literal before the MTA-verified IP address inside the parenthetical tcp-info group. Additionally, the parser evaluated REGXIP (IPv4) across the entire clause before evaluating REGXIP6 (IPv6). An attacker connecting over IPv6 could supply a spoofed IPv4 address in the EHLO string (or a private IPv4 literal like [127.0.0.1] to trigger fall-through) and completely preempt IPv6 extraction.
Commit ce3cf3559db1ff806bda598b378de9f8c2a5be96 (released in version 4.6.2 via Pull Request #167) resolves the vulnerability by replacing substring slicing and raw regex scanning with boundary-aware clause parsing, positional candidate filtering, and fail-closed loop termination.
In the unpatched code inside src/mailparser/core.py, get_server_ipaddress() iterated over all Received headers, checking for trust containment and delegating directly to _extract_ip(). If _extract_ip() returned None, the loop silently proceeded to the next header:
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
# VULNERABLE: If ip_str is None (e.g., due to truncation or private IP),
# execution continues to older, sender-controlled Received headers.The patch restructures get_server_ipaddress() and replaces _extract_ip() with _sender_ip_candidates() and _public_ip():
for i in received:
i = ported_string(i)
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:
# FIX (Fail-Closed): If an authoritative hop contains no valid sender IP,
# halt immediately instead of falling through to sender-written headers.
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: indicates an internal relay; continue following the chain.To prevent HELO spoofing and delimiter confusion, _sender_ip_candidates() uses get_from_clause() (which splits on anchored RFC 5321 keyword tokens rather than substring .find("by")) and enforces strict positional rules:
def _sender_ip_candidates(self, received_header):
"""
Return the IP addresses named in the from clause of a header.
"""
# Normalize IPv6 prefix tags while preserving character offsets
from_part = _IPV6_TAG_RE.sub("_____", get_from_clause(received_header))
if not from_part:
return []
# Identify parenthetical/bracketed MTA groups and explicit helo= comments
groups = group_spans(from_part)
helo_spans = [
m.span()
for m in _HELO_RE.finditer(from_part)
if in_spans(m.start(), groups)
]
# Calculate the boundary of the first token (the unverified HELO name)
first_token_end = len(from_part.split(" ", 1)[0])
# FIX: Merge IPv4 and IPv6 regex matches by character offset position
matches = sorted(
list(REGXIP.finditer(from_part)) + list(REGXIP6.finditer(from_part)),
key=lambda m: m.start(),
)
# Exclude matches located inside explicit helo= spans
matches = [m for m in matches if not in_spans(m.start(), helo_spans)]
# FIX: Require candidates to appear AFTER the first token and INSIDE groups
candidates = [
m.group()
for m in matches
if m.start() >= first_token_end and in_spans(m.start(), groups)
]
if candidates:
return candidates
# Fallback for non-standard headers where the real IP is bare in token 0
# and the HELO name was placed inside a parenthetical (helo=...) comment
if helo_spans:
return [m.group() for m in matches if m.start() < first_token_end]
return []The patch comprehensively addresses the identified attack vectors within get_from_clause() and _sender_ip_candidates(). By anchoring clause splits, merging IPv4 and IPv6 matches positionally, disqualifying the first token (first_token_end), and failing closed when candidates is empty, an attacker can no longer force fall-through via malformed HELO strings or override the MTA-recorded address.
> [!NOTE]
> One architectural limitation remains inherent to the API design of get_server_ipaddress(trust): the method still checks if trust not in i: using substring containment across the entire Received header. If an internal relay prepends a Received header that does not match trust, or if an attacker injects the trust string into the from (HELO) clause of an untrusted relay hop that sits above the target trust hop, substring matching on trust itself could still evaluate to True. However, when trust properly identifies the outermost edge MTA, the topmost Received header is guaranteed to be generated by that edge MTA, rendering trust injection on lower hops unreachable under the new fail-closed logic.
Exploiting CVE-2026-129297 requires no authentication or special privileges (PR:N), nor does it require user interaction (UI:N). Any remote actor capable of delivering an SMTP message to a mail server whose downstream processing pipeline invokes MailParser.get_server_ipaddress() can trigger the vulnerability.
To spoof an arbitrary IP address (e.g., 6.6.6.6) while connecting from the actual attacker IP (1.2.3.4) to a receiving mail server (mx.victim.com):
Received Header: Prior to transmitting the email data (DATA command), the attacker includes a fabricated Received header in the raw message headers that contains the victim's trust identifier (mx.victim.com) and the desired spoofed IP ([6.6.6.6]).HELO/EHLO Hostname: During the SMTP handshake with mx.victim.com, the attacker issues EHLO derby.attacker.com. The substring "by" within derby serves as the truncation trigger.mx.victim.com) accepts the message and prepends its legitimate Received header above the attacker's forged header:Received: from derby.attacker.com (derby.attacker.com [1.2.3.4])
by mx.victim.com (Postfix) with ESMTP id ABC
for <recipient@victim.com>; Mon, 1 Jan 2026 00:00:00 +0000
Received: from fake.example (fake.example [6.6.6.6])
by mx.victim.com (Postfix) with ESMTP id XYZ; Mon, 1 Jan 2026 00:00:00 +0000
From: attacker@evil.com
To: recipient@victim.com
Subject: Spoofed Attribution Test
Email payload body here.When the downstream Python application parses this message using mail-parser < 4.6.2:
import mailparser
raw_mail = (
"Received: from derby.attacker.com (derby.attacker.com [1.2.3.4])\r\n"
"\tby mx.victim.com (Postfix) with ESMTP id ABC\r\n"
"\tfor <v@victim.com>; Mon, 1 Jan 2026 00:00:00 +0000\r\n"
"Received: from fake.example (fake.example [6.6.6.6])\r\n"
"\tby mx.victim.com (Postfix) with ESMTP id XYZ; Mon, 1 Jan 2026 00:00:00 +0000\r\n"
"From: spoof@attacker.com\r\n\r\n"
"Body"
)
parser = mailparser.parse_from_string(raw_mail)
sender_ip = parser.get_server_ipaddress("mx.victim.com")
print(f"Extracted sender IP: {sender_ip}")In vulnerable versions, inspecting the first header slices the string at "derby" ("Received: from der"), yielding no IP match. The loop then falls through to the second header and returns "6.6.6.6". In version 4.6.2, get_from_clause() properly isolates derby.attacker.com (derby.attacker.com [1.2.3.4]), ignores the first token, and extracts "1.2.3.4".
EHLO Literal SpoofingEven without injecting a second Received header, an attacker can issue EHLO [6.6.6.6] during the SMTP session. The edge MTA records:
Received: from [6.6.6.6] (attacker.host [1.2.3.4]) by mx.victim.com ...In versions prior to 4.6.2, REGXIP.findall() returns ["6.6.6.6", "1.2.3.4"] and selects the first public IP ("6.6.6.6"), directly returning the unverified EHLO literal without requiring header fall-through.
CVE-2026-129297 carries a CVSS v3.1 base score of 7.5 (High) (CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:N). The entire impact is concentrated in the Integrity metric (I:H), as the vulnerability corrupts the trustworthiness of network origin metadata extracted by the library.
Systems that integrate mail-parser into custom spam filters, Secure Email Gateways (SEGs), or automated phishing triage pipelines use get_server_ipaddress() to query DNS-based Blackhole Lists (DNSBLs), IP reputation feeds, or internal allowlists. By spoofing a high-reputation IP address or an IP belonging to a trusted partner organization, an attacker can bypass IP-based filtering and deliver phishing or malware payloads.
In automated incident response or abuse-reporting workflows (the core use case of the SpamScope project), extracted sender IPs are frequently fed into automated blocklists, firewall drop rules, or external abuse reporting systems. By forging the IP address of a legitimate third-party mail server or critical infrastructure host, an attacker can poison threat intelligence feeds or trigger automated blocking of innocent third-party networks.
Upgrade mail-parser to version 4.6.2 or later. The patched release is available on PyPI and GitHub and enforces positional candidate extraction alongside fail-closed header evaluation.
pip install --upgrade "mail-parser>=4.6.2"After upgrading, verify the installed package version in the target Python environment:
python3 -c "import mailparser; print(mailparser.__version__)"For environments where mail-parser cannot be immediately upgraded:
Received headers via get_server_ipaddress(), configure the edge MTA (e.g., Postfix, Exim, Sendmail) to record the client IP in an Authentication-Results or X-Originating-IP header after stripping any inbound instances of that header from external senders.Received header against local MTA connection logs rather than trusting regex extraction over in-band message headers.HELO/EHLO Validation at the Edge MTA: Configure the edge mail server to reject non-FQDN HELO/EHLO hostnames or unexpected address literals from unauthenticated external peers (e.g., reject_non_fqdn_helo_hostname in Postfix), reducing the attacker's flexibility in crafting malformed from clauses.CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:N| Product | Affected Versions | Fixed Version |
|---|---|---|
mail-parser SpamScope | < 4.6.2 | 4.6.2 |
| Attribute | Detail |
|---|---|
| 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 |
The software does not sufficiently verify the origin or authenticity of data, in a way that causes it to accept invalid data.
CVE-2026-129299 (GHSA-24mq-4vc6-2prf) is a parsing and serialization flaw in SpamScope mail-parser prior to version 4.6.2. The library uses reflective Python attribute resolution (getattr) over untrusted email header names and applies caller convenience transformations (such as underscore-to-hyphen folding and _json/_raw suffix stripping) directly to wire headers. An unauthenticated remote attacker can send crafted emails that trigger uncaught TypeError exceptions during JSON serialization or cause security-relevant headers and body content to be silently dropped without setting defect indicators.
CVE-2026-129236 is a command-line argument injection vulnerability (CWE-88) in Kubeshark, an eBPF-based network observability tool for Kubernetes. Located within the Model Context Protocol (MCP) server implementation in cmd/mcpRunner.go, the flaw occurs when handling the start_kubeshark tool request. When the MCP server runs with the --allow-destructive flag, the callStartKubeshark function appends the caller-supplied pod_regex parameter directly to the kubeshark tap argument slice without an end-of-options (--) delimiter. Because Kubeshark uses the Cobra and pflag libraries for command-line parsing, any pod_regex value prefixed with a hyphen is interpreted as a CLI flag rather than a positional regular expression. An attacker capable of influencing MCP tool arguments, such as through indirect prompt injection against a connected Large Language Model (LLM) agent, can inject the --set flag to override Helm chart values like tap.docker.registry. Because Kubeshark deploys its worker DaemonSet with privileged security contexts and host networking enabled, redirecting the container image registry allows arbitrary code execution as root across all Kubernetes cluster nodes.
Kubeshark versions 53.1.0 prior to 53.4.0 contain an arbitrary file write and path traversal vulnerability (CWE-22) alongside an argument injection vulnerability (CWE-88) in the Model Context Protocol (MCP) server implementation (cmd/mcpRunner.go). The download_file tool fails to validate caller-supplied path and dest arguments, allowing an attacker who influences an AI agent driving kubeshark mcp to write Kubeshark Hub API responses to arbitrary locations writable by the local user. Additionally, the start_kubeshark tool appends the pod_regex argument without flag delimiters, allowing argument injection into the kubeshark tap subcommand.
CVE-2026-129300 (GHSA-xhrq-2mqv-q8wx) is an unhandled exception vulnerability in SpamScope mail-parser, a Python library used to parse raw emails. When processing an email with a malformed Received header containing an out-of-range year or timezone offset, standard library datetime conversion routines raise OverflowError or OSError. Because the internal error handler only caught TypeError and ValueError, these exceptions escape the parser hierarchy, terminating email ingestion pipelines and causing a denial of service.
CVE-2026-129301 (GHSA-8cgq-x343-p74c) is an uncaught exception and MIME interpretation conflict vulnerability in the Python email parsing library mail-parser (versions >= 4.6.0 and < 4.6.3). The write_attachments() function iterates over parsed email attachments without per-attachment exception containment. When processing a specially crafted MIME part containing an RFC 2231-encoded null byte in the filename, a basename exceeding filesystem NAME_MAX limits, or a malformed base64 payload, the function raises an unhandled standard library exception (ValueError, OSError, or binascii.Error). This prematurely aborts the attachment extraction loop, preventing subsequent attachments from being written to disk for downstream security inspection while also triggering unhandled worker crashes in applications that only catch MailParserError.
Directus versions prior to 12.3.1 contain an authorization bypass and privilege management flaw in the SharesService component. Authenticated non-administrative users with update permissions on the directus_shares collection can modify the user_created, role, item, and collection fields of an existing owned share. Because the update operation validates permissions solely against the pre-update record state without revalidating the modified fields, an attacker can reassign share ownership and role context to an administrator. Subsequent guest access using the share token derives administrative accountability, exposing restricted relational data.