HIGH · CVSS 3.1 7.5 EPSS 0.7% · 48th percentile CWE-1333

CVE-2026-129295: mail-parser is vulnerable to polynomial ReDoS in email header parsing

Published 2026-11-16 · Updated 2026-11-16 · Also known as GHSA-r7w7-vpq8-c5vv

Summary

mail-parser contains polynomial-time regex backtracking in its email header parsing (CVE-2026-129295), letting a small crafted email consume excessive CPU and deny service. Anyone using PyPI mail-parser 4.2.0 through 4.6.0 to parse untrusted email should upgrade to 4.6.1.

Who is affected

Any process that parses untrusted email with mail-parser, such as mail gateways, ticketing systems, quarantine UIs, and archiving pipelines, is affected on versions 4.2.0 to 4.6.0. A single small, well-formed, RFC 5322-compliant email (including fully compliant folded headers) is sufficient to trigger the backtracking, with no special API, option, or malformed structure required, and all six address headers plus Received parsing add up. A handful of such emails can keep every parsing worker busy, denying service. Impact is limited to availability, with no confidentiality or integrity effect.

Exploitability

The CVSS 3.1 vector CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H yields a base score of 7.5, reflecting a network-reachable attack that is low complexity, requires no privileges and no user interaction, and affects availability only. EPSS is 0.005 (0.5% probability, percentile 0.432), indicating relatively low short-term exploitation likelihood. It is not listed in the CISA Known Exploited Vulnerabilities catalog, so active exploitation is not documented.

Remediation

How to check your project

Automated analysis of the published advisory data, generated 2026-11-18. Not human-reviewed; verify against the official advisory. How this works.

Affected packages

EcosystemPackageAffected versionsFixed inUpgrade
PyPI mail-parser >= 4.2.0, < 4.6.1 4.6.1 python -m pip install 'mail-parser>=4.6.1'

CVSS 3.1 vector

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

Attack vectorNetwork
Attack complexityLow
Privileges requiredNone
User interactionNone
ScopeUnchanged
ConfidentialityNone
IntegrityNone
AvailabilityHigh

FAQ

Is CVE-2026-129295 being actively exploited?

No. It is not listed in the CISA Known Exploited Vulnerabilities catalog, and no active exploitation is documented in this record.

What is the impact beyond denial of service?

None is documented. The flaw affects availability only (C:N/I:N in the CVSS vector); there is no confidentiality or integrity impact.

Which mail-parser versions are affected and where is it fixed?

The vulnerability was introduced in 4.2.0 and fixed in 4.6.1, so versions from 4.2.0 up to (but not including) 4.6.1 are affected. Upgrade to 4.6.1.

Is there a workaround if I cannot upgrade to 4.6.1?

The record states there is no workaround within the library. Users who cannot upgrade should cap total header size before parsing and enforce a wall-clock timeout around each parse.

Original advisory description
### Summary Two regular expressions used while parsing email headers backtrack polynomially on attacker-controlled input. Parsing a single small, well-formed email can consume minutes to hours of CPU, denying service to any process that parses untrusted mail. Both are reachable from an ordinary `parse_from_string()`, `parse_from_bytes()` or `parse_from_file()` call - no special API, option, or malformed structure is required by the victim. ### Details **1. Address-header fallback regex (`src/mailparser/utils.py`)** `get_addresses()` falls back to `_ADDR_FALLBACK_RE` whenever `email.utils.getaddresses(strict=True)` yields no usable address. The alternative `([^<,]*?)\s*<([^>]+)>` overlaps a lazy quantifier with an adjacent `\s*` - a space matches both. Driven by `finditer`, which retries at every offset and rescans the remainder, matching degrades to **quadratic** on `<` padding and **cubic** on whitespace padding. The fallback engages on the feature's own happy path, e.g. `From: [email protected] <[email protected]>`. Measured (4.6.0, CPython 3.14, macOS arm64; reproduced identically on Linux and on CPython 3.9, 3.11, 3.12, 3.13): | Padding | Parse time | | ---------------------- | ------------------ | | valid address + 750 sp | 0.38 s | | + 1500 sp | 2.97 s | | + 3000 sp | 23.4 s (×7.9/2×) | | + 6 KB sp | 185 s | | ~100 KB sp | hours | Fully RFC 5322-compliant folded headers (all lines ≤ 71 octets) trigger the same blowup, so the input passes normal MTA and library checks. ~100 KB of headers is within Postfix's default `header_size_limit = 102400`. All six address headers parsed by the library (`From`, `To`, `Cc`, `Bcc`, `Reply-To`, `Delivered-To`) are affected and their cost adds up linearly. **2. Received-header clause splitter (`src/mailparser/const.py`)** `parse_received()` splits on `_CLAUSE_SPLITTER`, `(?:^|\s+)(from|by|via|with|id|for|envelope-from)\s+`. Under `re.split` this backtracks **quadratically** over any whitespace run that is not followed by a clause keyword. The pre-existing normalization collapsed only `[\t\n]`, so literal spaces - including folded-header padding - reached the splitter intact. Measured: 24 000 spaces in one `Received:` header → 22 s; ~100 KB → minutes. ### Impact Availability. A handful of small emails keeps every parsing worker of a mail gateway, ticketing system, quarantine UI, or archiving pipeline permanently busy. No confidentiality or integrity impact. Anyone who parses email they did not author is affected - which is the library's purpose. ### Patches Fixed in **4.6.1**. - The address fallback is now a linear scan: the header is split into comma-separated items (quote-aware, in Python), then each item is matched against a bounded angle-address `<([^<>\s]+)>` with the display name derived in Python, falling back to a bare-email match. Each pattern has a single non-nested quantifier over a negated character class → O(n). 2000 padding spaces: `3.5 s → <0.01 s`. 256 KB padding: `hours → 0.087 s`. Output is preserved on every previously supported shape. - `parse_received()` collapses whitespace runs to a single space before splitting, so the splitter's `\s+` only ever matches one character → O(n). The date is extracted from the raw header beforehand, so date formatting is unaffected. 24 000 spaces: `22 s → 0.003 s`; 200 000 spaces: `0.004 s`. Regression tests assert linear-time behaviour for both paths. ### Workarounds None within the library. Upgrade to `4.6.1`. Users who cannot upgrade immediately should cap total header size before parsing and enforce a wall-clock timeout around each parse.

References

Source records: GHSA-r7w7-vpq8-c5vv (OSV.dev) · EPSS by FIRST, 2026-11-26.