{"vuln_id":"GHSA-g47v-rwmh-r9f8","aliases":[],"description":null,"published_at":null,"modified_at":null,"first_seen_at":"2026-11-21T19:15:19.416675Z","severity":"unknown","severity_source":null,"cvss_score":null,"cvss_vector":null,"cwe":[],"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-g47v-rwmh-r9f8"},"matched_alias":null,"items":[{"id":10714,"source":{"id":"osv","name":"OSV.dev"},"title":"GHSA-m4g8-47f9-h588: eml_parser: Algorithmic-complexity DoS (O(n^4) regex backtracking) in Received-header parsing","summary":"eml_parser: Algorithmic-complexity DoS (O(n^4) regex backtracking) in Received-header parsing\n\n### Summary\n\n`eml_parser.routing.parserouting()` dynamically builds a regex from up to four greedy `.*` groups (`from (?P\n.*)by (?P\n.*)with (?P\n.*)for (?P\n.*)`) terminated by an escaped literal of the date extracted from a **normalized** copy of the `Received` header. Because the date literal comes from the normalized text but is searched in the original line, a crafted header can make the trailing literal unmatchable; the search then fails at every start position only after exhaustively backtracking the four nested greedy groups — **O(n^4)** in header length. A single ~5.9 KB email pins one CPU core for ~12 seconds; doubling the input multiplies the cost ~25x, so a ~13 KB header takes minutes and a ~25 KB header effectively hangs the parse worker.\n\n### Details\n\nRoot cause: `eml_parser/routing.py:140-148` (v3.0.3):\n\n```python\nreg = ''\nfor item in tout:\nreg += item[1] + '(?P<' + item[1].strip() + '>.*)' # e.g. 'from (?P\n.*)'\nif npdate:\nreg += eml_parser.regexes.escape_special_regex_chars.sub(r\"\"\"\\\\\\1\"\"\", npdate)\nreparse = re.compile(reg)\nreparseg = reparse.search(line) # searched in the ORIGINAL line\n```\n\n`npdate` is extracted from `npline`, a normalized copy of the header (spacing added around `(`, `)`, `;` at routing.py:79-81; parenthesized text removed at line 82; whitespace collapsed at line 83), so it is not guaranteed to be a substring of `line`. An unbalanced `(` in the date tail (e.g. `+0000(comment`) becomes ` ( comment` in `npline` but stays `(comment` in `line`, making the mandatory trailing literal unmatchable.\n\nData flow: attacker-controlled `Received:` header (arbitrary length; the custom policy sets `max_line_length=0`) -> `parser.py:352-355` (lowercased, whitespace-flattened, no size cap - unlike body text, which is sliced) -> `parser.py:365` `routing.parserouting(...)` -> O(n^4) search. Every Received header is processed, multiplying the cost, and the behavior cannot be disabled via any `EmlParser` option.\n\nMeasured on Python 3.14 (identical with stdlib `re` and the optional `regex` module):\n\n| Segments | Header size | Wall time |\n|---|---|---|\n| 20 | 1.4 KB | 0.022 s |\n| 40 | 2.9 KB | 0.43 s |\n| 80 | 5.8 KB | 12 s |\n| 160 (extrapolated) | 13 KB | ~5 min |\n\ncProfile attributes 83% of wall time to `re.Pattern.search` called from `routing.parserouting`. The parse completes normally (no exception) - it is pure CPU exhaustion.\n\nThis is distinct from GHSA-g47v-rwmh-r9f8 (recursion DoS in `get_raw_body_text()`, fixed via `MULTIPART_RECURSION_LIMIT` - different function and mechanism) and from issue #48 (old `url_regex_simple` body-path hang; body regexes now run on ~600-char slices, capping impact - the Received-header path is unsliced).\n\n### PoC\n\n```python\nimport eml_parser\n\nseg = 'from h{0}.example.com by mx{0}.example.com with esmtp for u{0}@example.com '\nreceived = ''.join(seg.format(i) for i in range(80)) + ';Mon, 01 Jan 2024 00:00:00 +0000(comment'\n# NB: unbalanced '(' in the date tail -> the norm\n\nAffected: PyPI:eml-parser\n\nFixed in: 3.0.4\n\nReferences:\nhttps://github.com/GOVCERT-LU/eml_parser/security/advisories/GHSA-m4g8-47f9-h588\nhttps://nvd.nist.gov/vuln/detail/CVE-2026-129307\nhttps://github.com/GOVCERT-LU/eml_parser/commit/54ea6e9f54fecda3059283ccdb6a6fd99e7ce92f\nhttps://github.com/GOVCERT-LU/eml_parser\nhttps://github.com/GOVCERT-LU/eml_parser/releases/tag/v3.0.4","url":"https://osv.dev/vulnerability/GHSA-m4g8-47f9-h588","published_at":"2026-11-19T22:47:08Z","updated_at":"2026-11-19T23:00:36.652146Z","fetched_at":"2026-11-21T19:15:55.946124Z","severity":"medium","cvss_score":5.3,"epss":0.00291,"is_kev":false,"has_exploit":false,"kev_due_date":null,"vendor":null,"product":"eml-parser","vuln_id":"CVE-2026-129307","vuln_ids":["CVE-2026-129307","GHSA-G47V-RWMH-R9F8","GHSA-M4G8-47F9-H588"],"tags":["osv","pypi","fix-available"],"cluster_id":2182,"links":{"self":"https://vulnwatch.ve1ve2.com/api/v1/items/10714","html":"https://vulnwatch.ve1ve2.com/item/10714"}},{"id":2374,"source":{"id":"ghsa","name":"GitHub Security Advisories"},"title":"GHSA-m4g8-47f9-h588 / CVE-2026-129307: eml_parser: Algorithmic-complexity DoS (O(n^4) regex backtracking) in Received-header parsing","summary":"eml_parser: Algorithmic-complexity DoS (O(n^4) regex backtracking) in Received-header parsing\n\n### Summary\n\n`eml_parser.routing.parserouting()` dynamically builds a regex from up to four greedy `.*` groups (`from (?P\n.*)by (?P\n.*)with (?P\n.*)for (?P\n.*)`) terminated by an escaped literal of the date extracted from a **normalized** copy of the `Received` header. Because the date literal comes from the normalized text but is searched in the original line, a crafted header can make the trailing literal unmatchable; the search then fails at every start position only after exhaustively backtracking the four nested greedy groups — **O(n^4)** in header length. A single ~5.9 KB email pins one CPU core for ~12 seconds; doubling the input multiplies the cost ~25x, so a ~13 KB header takes minutes and a ~25 KB header effectively hangs the parse worker.\n\n### Details\n\nRoot cause: `eml_parser/routing.py:140-148` (v3.0.3):\n\n```python\nreg = ''\nfor item in tout:\nreg += item[1] + '(?P<' + item[1].strip() + '>.*)' # e.g. 'from (?P\n.*)'\nif npdate:\nreg += eml_parser.regexes.escape_special_regex_chars.sub(r\"\"\"\\\\\\1\"\"\", npdate)\nreparse = re.compile(reg)\nreparseg = reparse.search(line) # searched in the ORIGINAL line\n```\n\n`npdate` is extracted from `npline`, a normalized copy of the header (spacing added around `(`, `)`, `;` at routing.py:79-81; parenthesized text removed at line 82; whitespace collapsed at line 83), so it is not guaranteed to be a substring of `line`. An unbalanced `(` in the date tail (e.g. `+0000(comment`) becomes ` ( comment` in `npline` but stays `(comment` in `line`, making the mandatory trailing literal unmatchable.\n\nData flow: attacker-controlled `Received:` header (arbitrary length; the custom policy sets `max_line_length=0`) -> `parser.py:352-355` (lowercased, whitespace-flattened, no size cap - unlike body text, which is sliced) -> `parser.py:365` `routing.parserouting(...)` -> O(n^4) search. Every Received header is processed, multiplying the cost, and the behavior cannot be disabled via any `EmlParser` option.\n\nMeasured on Python 3.14 (identical with stdlib `re` and the optional `regex` module):\n\n| Segments | Header size | Wall time |\n|---|---|---|\n| 20 | 1.4 KB | 0.022 s |\n| 40 | 2.9 KB | 0.43 s |\n| 80 | 5.8 KB | 12 s |\n| 160 (extrapolated) | 13 KB | ~5 min |\n\ncProfile attributes 83% of wall time to `re.Pattern.search` called from `routing.parserouting`. The parse completes normally (no exception) - it is pure CPU exhaustion.\n\nThis is distinct from GHSA-g47v-rwmh-r9f8 (recursion DoS in `get_raw_body_text()`, fixed via `MULTIPART_RECURSION_LIMIT` - different function and mechanism) and from issue #48 (old `url_regex_simple` body-path hang; body regexes now run on ~600-char slices, capping impact - the Received-header path is unsliced).\n\n### PoC\n\n```python\nimport eml_parser\n\nseg = 'from h{0}.example.com by mx{0}.example.com with esmtp for u{0}@example.com '\nreceived = ''.join(seg.format(i) for i in range(80)) + ';Mon, 01 Jan 2024 00:00:00 +0000(comment'\n# NB: unbalanced '(' in the date tail -> the norm\n\nAffected packages: pip:eml-parser\nPatched: eml-parser 3.0.4","url":"https://github.com/advisories/GHSA-m4g8-47f9-h588","published_at":"2026-11-19T22:47:08Z","updated_at":"2026-11-19T22:47:09Z","fetched_at":"2026-11-21T19:15:18.416788Z","severity":"medium","cvss_score":5.3,"epss":0.00291,"is_kev":false,"has_exploit":false,"kev_due_date":null,"vendor":null,"product":"eml-parser","vuln_id":"CVE-2026-129307","vuln_ids":["CVE-2026-129307","GHSA-G47V-RWMH-R9F8","GHSA-M4G8-47F9-H588"],"tags":["ghsa","pip","CWE-407","CWE-1333"],"cluster_id":2182,"links":{"self":"https://vulnwatch.ve1ve2.com/api/v1/items/2374","html":"https://vulnwatch.ve1ve2.com/item/2374"}}]}