Skip to content
Medium 5.3

eml_parser: Algorithmic-complexity DoS (O(n^4) regex backtracking) in Received-header parsing

CVE-2026-129307 First seen on SecPulse

Affected packages

PackageAffected → Fixed
GOVCERT-LUeml_parser —
PyPIeml-parser
< 3.0.4→ 3.0.4
pipeml-parser
< 3.0.4→ 3.0.4
Original description The description as published by the source.

Summary

eml_parser.routing.parserouting() dynamically builds a regex from up to four greedy .* groups (from (?P.*)by (?P.*)with (?P.*)for (?P.*)) 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):

reg = ''
for item in tout:
    reg += item[1] + '(?P<' + item[1].strip() + '>.*)'   # e.g. 'from (?P.*)'
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 `lin…

Source: CVE.org (CVE Program・cvelistV5) NVD GitHub Advisory

References

We use cookies for analytics and ad measurement. This setting applies to all Game co., Ltd. sites. Details