CVE-2026-129307: eml_parser Denial of Service Vulnerability

MODERATE
Advisory Identifier: GHSA-m4g8-47f9-h588
CVSS 5.3
CWE-1333 CWE-407
Published
Advisory Summary

CVE-2026-129307 is a MODERATE (CVSS 5.3) denial of service vulnerability (CWE-1333: Inefficient Regular Expression Complexity) affecting eml_parser libraries in the PyPI ecosystem. The issue involves algorithmic-complexity dos (o(n^4) regex backtracking) in received-header parsing. Remediation is available by upgrading affected packages to version 3.0.4.

CVE-2026-129307 at a Glance

CVE Identifier CVE-2026-129307
GHSA Identifier GHSA-m4g8-47f9-h588
Severity MODERATE
CVSS v3.1 Base Score 5.3
CWE Classification CWE-1333: Inefficient Regular Expression Complexity
Affected Product eml_parser
Package Ecosystem PyPI
Published Date
Last Updated

Security Impact

CVSS: 5.3

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required None (PR:N)
User Interaction None (UI:N)
Scope Unchanged (S:U)
Confidentiality None (C:N)
Integrity None (I:N)
Availability Low (A:L)

How to Fix CVE-2026-129307

To remediate this vulnerability, upgrade all affected eml_parser dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

eml-parser fixed: 3.0.4
pip install eml-parser>=3.0.4
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

pip show eml-parser

How to Check if You Are Affected

To determine whether your Python environment is affected by CVE-2026-129307, inspect your installed packages using pip:

pip show eml-parser

Analyze the terminal output to locate any version of eml_parser in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 3.0.4), your application is affected.

Note: The pip show eml-parser command checks currently installed packages in your active Python environment.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-1333: Inefficient Regular Expression Complexity, where the product uses a regular expression with a worst-case computational complexity that is inefficient and possibly exponential. In eml_parser, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

### Summary `eml_parser.routing.parserouting()` dynamically builds a regex from up to four greedy `.*` groups (`from (?P<from>.*)by (?P<by>.*)with (?P<with>.*)for (?P<for>.*)`) 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. ### Details Root cause: `eml_parser/routing.py:140-148` (v3.0.3): ```python reg = '' for item in tout: reg += item[1] + '(?P<' + item[1].strip() + '>.*)' # e.g. 'from (?P<from>.*)' if npdate: reg += eml_parser.regexes.escape_special_regex_chars.sub(r"""\\\1""", npdate) reparse = re.compile(reg) reparseg = reparse.search(line) # searched in the ORIGINAL line ``` `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. Data 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. Measured on Python 3.14 (identical with stdlib `re` and the optional `regex` module): | Segments | Header size | Wall time | |---|---|---| | 20 | 1.4 KB | 0.022 s | | 40 | 2.9 KB | 0.43 s | | 80 | 5.8 KB | 12 s | | 160 (extrapolated) | 13 KB | ~5 min | cProfile attributes 83% of wall time to `re.Pattern.search` called from `routing.parserouting`. The parse completes normally (no exception) - it is pure CPU exhaustion. This 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). ### PoC ```python import eml_parser seg = 'from h{0}.example.com by mx{0}.example.com with esmtp for u{0}@example.com ' received = ''.join(seg.format(i) for i in range(80)) + ';Mon, 01 Jan 2024 00:00:00 +0000(comment' # NB: unbalanced '(' in the date tail -> the normalized date literal never occurs in the # searched line, so the dynamic 4-group greedy regex can never match and backtracks O(n^4). eml = ( 'Received: ' + received + '\r\n' 'From: attacker@evil.example\r\n' 'To: victim@target.example\r\n' 'Subject: poc\r\n' 'Content-Type: text/plain\r\n' '\r\n' 'hello\r\n' ).encode() import time t0 = time.perf_counter() eml_parser.EmlParser().decode_email_bytes(eml) print(f'{time.perf_counter() - t0:.2f}s') # ~12 s for a 5.9 KB input ``` Observed on v3.0.3: `eml size: 5887 bytes`, `decode_email_bytes() wall time: 12.33s`, message parses fine. Affected APIs: `decode_email`, `decode_email_bytes`, `parse_email`. ### Impact Algorithmic-complexity denial of service. Any application that parses untrusted email with eml_parser (mail gateways, phishing-analysis and forensics pipelines, ticketing systems) can have a parser worker pinned by a single small email; an attacker sending a steady trickle of such messages keeps workers permanently busy (CPU exhaustion, queue backlog) even behind per-message timeouts. No crash, corruption, or information leak - availability impact only. Reporter credit: Niranjan Ganesan (https://securityinsights.io/, @iam-niranjan) ### Resolution An algorithmic complexity vulnerability ($O(n^4)$ ReDoS) in `eml_parser.routing.parserouting()` was resolved. Previously, `parserouting()` dynamically constructed a regex using multiple greedy `.*` capture groups appended with a normalized date string (`npdate`). Because `npdate` was extracted from a normalized copy of the `Received` header line, formatting mismatches between `npdate` and the un-normalized input line could render the trailing literal unmatchable. This forced the engine into exhaustive backtracking across nested greedy groups on unmatchable inputs, causing high CPU consumption and potential worker hangs on malicious headers. **Fix:** 1. **Dynamic Regex Construction:** Removed the static `npdate` suffix from the compiled pattern, replacing it with non-greedy field capture groups (`.*?`) terminated lazily by a semicolon or end-of-line anchor (`(?:;|$)`). 2. **Keyword Ordering Logic:** Streamlined the routing keyword position detection to a single-pass `str.find()` search, removing $O(k^2)$ matrix evaluations. These changes eliminate catastrophic backtracking and reduce processing time from $O(n^4)$ to linear $O(n)$ complexity.

CVE-2026-129307 Affected eml_parser Versions

1 component(s)
Fixed Versions:
3.0.4
Product / Package Ecosystem Affected Versions Fixed Version
eml-parser
PyPI
< 3.0.4
3.0.4

References

Frequently Asked Questions

What is CVE-2026-129307?
CVE-2026-129307 is a security vulnerability in eml_parser involving Algorithmic-complexity DoS (O(n^4) regex backtracking) in Received-header parsing under CWE-1333: Inefficient Regular Expression Complexity.
Which eml_parser versions are affected?
Affected versions include releases prior to 3.0.4 across affected packages: eml-parser.
What version fixes CVE-2026-129307?
Upgrading to 3.0.4 (or the latest patched release for your respective branch) resolves the vulnerability.
Is eml-parser affected?
Yes, eml-parser is affected in releases prior to 3.0.4. Upgrade your dependency to 3.0.4 or later.
What is the CVSS score of CVE-2026-129307?
CVE-2026-129307 has a CVSS v3.1 base score of 5.3 (MODERATE) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L.
What CWE is associated with CVE-2026-129307?
CVE-2026-129307 is classified under CWE-1333: Inefficient Regular Expression Complexity (The product uses a regular expression with a worst-case computational complexity that is inefficient and possibly exponential.).
How can I check PyPI dependencies for CVE-2026-129307?
Run the dependency tree command: 'pip show eml-parser'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-m4g8-47f9-h588",
  "modified" : "2026-11-19T22:47:08Z",
  "published" : "2026-11-19T22:47:08Z",
  "aliases" : [ "CVE-2026-129307" ],
  "summary" : "eml_parser: Algorithmic-complexity DoS (O(n^4) regex backtracking) in Received-header parsing",
  "details" : "### Summary\n\n`eml_parser.routing.parserouting()` dynamically builds a regex from up to four greedy `.*` groups (`from (?P<from>.*)by (?P<by>.*)with (?P<with>.*)for (?P<for>.*)`) 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:\n    reg += item[1] + '(?P<' + item[1].strip() + '>.*)'   # e.g. 'from (?P<from>.*)'\nif npdate:\n    reg += 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 normalized date literal never occurs in the\n# searched line, so the dynamic 4-group greedy regex can never match and backtracks O(n^4).\n\neml = (\n    'Received: ' + received + '\\r\\n'\n    'From: attacker@evil.example\\r\\n'\n    'To: victim@target.example\\r\\n'\n    'Subject: poc\\r\\n'\n    'Content-Type: text/plain\\r\\n'\n    '\\r\\n'\n    'hello\\r\\n'\n).encode()\n\nimport time\nt0 = time.perf_counter()\neml_parser.EmlParser().decode_email_bytes(eml)\nprint(f'{time.perf_counter() - t0:.2f}s')   # ~12 s for a 5.9 KB input\n```\n\nObserved on v3.0.3: `eml size: 5887 bytes`, `decode_email_bytes() wall time: 12.33s`, message parses fine. Affected APIs: `decode_email`, `decode_email_bytes`, `parse_email`.\n\n### Impact\n\nAlgorithmic-complexity denial of service. Any application that parses untrusted email with eml_parser (mail gateways, phishing-analysis and forensics pipelines, ticketing systems) can have a parser worker pinned by a single small email; an attacker sending a steady trickle of such messages keeps workers permanently busy (CPU exhaustion, queue backlog) even behind per-message timeouts. No crash, corruption, or information leak - availability impact only.\n\nReporter credit: Niranjan Ganesan (https://securityinsights.io/, @iam-niranjan)\n\n\n### Resolution\n\nAn algorithmic complexity vulnerability ($O(n^4)$ ReDoS) in `eml_parser.routing.parserouting()` was resolved.\n\nPreviously, `parserouting()` dynamically constructed a regex using multiple greedy `.*` capture groups appended with a normalized date string (`npdate`). Because `npdate` was extracted from a normalized copy of the `Received` header line, formatting mismatches between `npdate` and the un-normalized input line could render the trailing literal unmatchable. This forced the engine into exhaustive backtracking across nested greedy groups on unmatchable inputs, causing high CPU consumption and potential worker hangs on malicious headers.\n\n**Fix:**\n\n1. **Dynamic Regex Construction:** Removed the static `npdate` suffix from the compiled pattern, replacing it with non-greedy field capture groups (`.*?`) terminated lazily by a semicolon or end-of-line anchor (`(?:;|$)`).\n2. **Keyword Ordering Logic:** Streamlined the routing keyword position detection to a single-pass `str.find()` search, removing $O(k^2)$ matrix evaluations.\n\nThese changes eliminate catastrophic backtracking and reduce processing time from $O(n^4)$ to linear $O(n)$ complexity.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "PyPI",
      "name" : "eml-parser"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "3.0.4"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 3.0.3"
    }
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/GOVCERT-LU/eml_parser/security/advisories/GHSA-m4g8-47f9-h588"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2026-129307"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/GOVCERT-LU/eml_parser/commit/54ea6e9f54fecda3059283ccdb6a6fd99e7ce92f"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/GOVCERT-LU/eml_parser"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/GOVCERT-LU/eml_parser/releases/tag/v3.0.4"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-1333", "CWE-407" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-11-19T22:47:08Z",
    "nvd_published_at" : "2026-11-16T19:17:40Z"
  }
}