{"vuln_id":"GHSA-r7w7-vpq8-c5vv","aliases":["CVE-2026-129295"],"description":"mail-parser is vulnerable to polynomial ReDoS in email header parsing","published_at":"2026-11-16T22:11:08Z","modified_at":"2026-11-16T22:11:09Z","first_seen_at":"2026-11-21T19:15:20.238596Z","severity":"high","severity_source":"ghsa","cvss_score":7.5,"cvss_vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H","cwe":["CWE-1333"],"vendor":null,"product":null,"kev":{"is_kev":false,"date_added":null,"due_date":null,"ransomware":false},"epss":null,"epss_percentile":null,"nvd_status":null,"enriched_at":null,"links":{"nvd":"https://github.com/advisories/GHSA-r7w7-vpq8-c5vv"},"matched_alias":null,"items":[{"id":2482,"source":{"id":"ghsa","name":"GitHub Security Advisories"},"title":"GHSA-r7w7-vpq8-c5vv / CVE-2026-129295: mail-parser is vulnerable to polynomial ReDoS in email header parsing","summary":"mail-parser is vulnerable to polynomial ReDoS in email header parsing\n\n### Summary\n\nTwo regular expressions used while parsing email headers backtrack\npolynomially on attacker-controlled input. Parsing a single small, well-formed\nemail can consume minutes to hours of CPU, denying service to any process that\nparses untrusted mail.\n\nBoth are reachable from an ordinary `parse_from_string()`, `parse_from_bytes()`\nor `parse_from_file()` call — no special API, option, or malformed structure is\nrequired by the victim.\n\n### Details\n\n**1. Address-header fallback regex (`src/mailparser/utils.py`)**\n\n`get_addresses()` falls back to `_ADDR_FALLBACK_RE` whenever\n`email.utils.getaddresses(strict=True)` yields no usable address. The\nalternative `([^<,]*?)\\s*<([^>]+)>` overlaps a lazy quantifier with an adjacent\n`\\s*` — a space matches both. Driven by `finditer`, which retries at every\noffset and rescans the remainder, matching degrades to **quadratic** on `<`\npadding and **cubic** on whitespace padding.\n\nThe fallback engages on the feature's own happy path, e.g.\n`From: alice@example.com\n`.\n\nMeasured (4.6.0, CPython 3.14, macOS arm64; reproduced identically on Linux and\non CPython 3.9, 3.11, 3.12, 3.13):\n\n| Padding | Parse time |\n| ---------------------- | ------------------ |\n| valid address + 750 sp | 0.38 s |\n| + 1500 sp | 2.97 s |\n| + 3000 sp | 23.4 s (×7.9/2×) |\n| + 6 KB sp | 185 s |\n| ~100 KB sp | hours |\n\nFully RFC 5322-compliant folded headers (all lines ≤ 71 octets) trigger the same\nblowup, so the input passes normal MTA and library checks. ~100 KB of headers is\nwithin Postfix's default `header_size_limit = 102400`.\n\nAll six address headers parsed by the library (`From`, `To`, `Cc`, `Bcc`,\n`Reply-To`, `Delivered-To`) are affected and their cost adds up linearly.\n\n**2. Received-header clause splitter (`src/mailparser/const.py`)**\n\n`parse_received()` splits on `_CLAUSE_SPLITTER`,\n`(?:^|\\s+)(from|by|via|with|id|for|envelope-from)\\s+`. Under `re.split` this\nbacktracks **quadratically** over any whitespace run that is not followed by a\nclause keyword. The pre-existing normalization collapsed only `[\\t\\n]`, so\nliteral spaces — including folded-header padding — reached the splitter intact.\n\nMeasured: 24 000 spaces in one `Received:` header → 22 s; ~100 KB → minutes.\n\n### Impact\n\nAvailability. A handful of small emails keeps every parsing worker of a mail\ngateway, ticketing system, quarantine UI, or archiving pipeline permanently\nbusy. No confidentiality or integrity impact.\n\nAnyone who parses email they did not author is affected — which is the library's\npurpose.\n\n### Patches\n\nFixed in **4.6.1**.\n\n- The address fallback is now a linear scan: the header is split into\ncomma-separated items (quote-aware, in Python), then each item is matched\nagainst a bounded angle-address `<([^<>\\s]+)>` with the display name derived\nin Python, falling back to a bare-email match. Each pattern has a sing\n\nAffected packages: pip:mail-parser\nPatched: mail-parser 4.6.1","url":"https://github.com/advisories/GHSA-r7w7-vpq8-c5vv","published_at":"2026-11-16T22:11:08Z","updated_at":"2026-11-16T22:11:09Z","fetched_at":"2026-11-21T19:15:18.416872Z","severity":"high","cvss_score":7.5,"epss":0.00495,"is_kev":false,"has_exploit":false,"kev_due_date":null,"vendor":null,"product":"mail-parser","vuln_id":"CVE-2026-129295","vuln_ids":["CVE-2026-129295","GHSA-R7W7-VPQ8-C5VV"],"tags":["ghsa","pip","CWE-1333"],"cluster_id":2406,"links":{"self":"https://vulnwatch.ve1ve2.com/api/v1/items/2482","html":"https://vulnwatch.ve1ve2.com/item/2482"}},{"id":6217,"source":{"id":"nvd","name":"NVD CVE API 2.0"},"title":"CVE-2026-129295: mail-parser is a tool that parses emails by enhancing the Python standard library and extracting message details into a comprehensive object. From 4.2.0 until…","summary":"mail-parser is a tool that parses emails by enhancing the Python standard library and extracting message details into a comprehensive object. From 4.2.0 until 4.6.1, attacker-controlled email headers can cause polynomial regular-expression backtracking during ordinary parse_from_string(), parse_from_bytes(), or parse_from_file() calls. In src/mailparser/utils.py, get_addresses() invokes the _ADDR_FALLBACK_RE fallback when strict address parsing yields no usable address, and overlapping quantifiers rescan padded address headers quadratically or cubically. In src/mailparser/const.py, parse_received() applies _CLAUSE_SPLITTER to uncollapsed whitespace in a Received header, causing quadratic backtracking when a whitespace run is not followed by a clause keyword. A small, well-formed message can keep mail gateway, ticketing, quarantine, or archival parsing workers busy for extended periods. This issue is fixed in version 4.6.1.\n\nReferences:\nhttps://github.com/SpamScope/mail-parser/commit/037293158cb291caa96635a54449243d32cd4d96\nhttps://github.com/SpamScope/mail-parser/commit/5aab122f0d763991604d2c2bcc807c6bf2489464\nhttps://github.com/SpamScope/mail-parser/commit/85e53f820d78ae7c955dafbbcd0e20989a735c2c\nhttps://github.com/SpamScope/mail-parser/pull/166\nhttps://github.com/SpamScope/mail-parser/releases/tag/4.6.1\nhttps://github.com/SpamScope/mail-parser/security/advisories/GHSA-r7w7-vpq8-c5vv","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-129295","published_at":"2026-11-16T18:17:30.183000Z","updated_at":"2026-11-17T23:17:51.243000Z","fetched_at":"2026-11-21T19:15:31.481991Z","severity":"high","cvss_score":7.5,"epss":0.00495,"is_kev":false,"has_exploit":false,"kev_due_date":null,"vendor":null,"product":null,"vuln_id":"CVE-2026-129295","vuln_ids":["CVE-2026-129295","GHSA-R7W7-VPQ8-C5VV"],"tags":["CWE-1333"],"cluster_id":1409,"links":{"self":"https://vulnwatch.ve1ve2.com/api/v1/items/6217","html":"https://vulnwatch.ve1ve2.com/item/6217"}}]}