{"id":2958,"cve":"CVE-2026-129297","cve_url":"https:\/\/www.cvedetails.com\/cve\/CVE-2026-129297\/","cwe":"CWE-345","cwe_number":345,"cwe_url":"https:\/\/cwe.mitre.org\/data\/definitions\/345","cvss_score":7.5,"published":"2026-11-16","owasp":"A04 Insecure Design","odc":"Algorithm","cdc":"Incorrect Algorithm","category":"Input Validation and Sanitization","subcategory":"Insecure Parsing or Deserialization","scope":"Remote","impact":"Information Disclosure","summary":"Spoofable sender IP due to untrusted Received header parsing (pre\u20114.6.2).","permalink":"https:\/\/netpack.pt\/vaitp\/vulnerability\/CVE-2026-129297\/","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.","solution":"Upgrade mail-parser to version\u202f4.6.2 or later.","affected_component":"mail-parser","fixed_by_upgrading":true,"vulnerable_code":"import re\nimport mailparser\n\ndef get_server_ipaddress(raw_email):\n    \"\"\"\n    Extract the sending server IP from the first Received header.\n    \"\"\"\n    parsed = mailparser.parse_from_string(raw_email)\n    # VULNERABLE: trusts the first IP found in Received headers without validation\n    for header in parsed.headers.get('Received', []):\n        # naive split, picks anything that looks like an IP\n        parts = header.split()\n        for part in parts:\n            if re.match(r'\\d+\\.\\d+\\.\\d+\\.\\d+', part):\n                return part\n    return None\n","patched_code":"import re\nimport mailparser\n\ndef get_server_ipaddress(raw_email):\n    \"\"\"\n    Extract the sending server IP, ignoring attacker\u2011controlled text.\n    \"\"\"\n    ip_regex = re.compile(\n        r'\\[(?P<ipv4>(?:\\d{1,3}\\.){3}\\d{1,3})\\]|'      # [1.2.3.4]\n        r'\\[(?P<ipv6>[:0-9a-fA-F]+)\\]|'                # [2001:db8::1]\n        r'(?P<helo>HELO\\s+\\S+)'                       # HELO example.com\n    )\n    parsed = mailparser.parse_from_string(raw_email)\n    # FIX: only accept bracketed IPs or HELO markers, skip untrusted hops\n    for header in parsed.headers.get('Received', []):\n        match = ip_regex.search(header)\n        if match:\n            if match.group('ipv4') or match.group('ipv6'):\n                # strip brackets\n                return match.group('ipv4') or match.group('ipv6')\n            elif match.group('helo'):\n                # treat HELO marker as trusted hop, continue searching\n                continue\n    return None\n","payload_needed":true,"payload":null,"payload_status":"model_refused","published_fix":[{"repository":"SpamScope\/mail-parser","commit_url":"https:\/\/github.com\/SpamScope\/mail-parser\/commit\/ce3cf3559db1ff806bda598b378de9f8c2a5be96","commit_subject":"Fixed many bugs (#167)","units":[{"file":"src\/mailparser\/const.py","function":null},{"file":"src\/mailparser\/core.py","function":null},{"file":"src\/mailparser\/core.py","function":"MailParser.get_server_ipaddress"},{"file":"src\/mailparser\/core.py","function":"MailParser.headers"},{"file":"src\/mailparser\/core.py","function":"MailParser.parse"},{"file":"src\/mailparser\/core.py","function":"MailParser._extract_ip"},{"file":"src\/mailparser\/core.py","function":"MailParser._make_mail"},{"file":"src\/mailparser\/core.py","function":"MailParser._reset"},{"file":"src\/mailparser\/core.py","function":"MailParser.__getattr__"},{"file":"src\/mailparser\/core.py","function":"MailParser.__init__"},{"file":"src\/mailparser\/utils.py","function":null},{"file":"src\/mailparser\/utils.py","function":"get_header"}]}],"references":null}