eml_parser vulnerability causes denial of service via regex backtracking

  • Niranjan Ganesan
  • eml_parser
  • ReDoS
  • backtracking
  • denial of service

Flaw in Received header parsing reached O(n^4) complexity

Maintainers updated logic to achieve linear O(n) processing

Users should update to version 3.0.4 to mitigate the risk

Niranjan Ganesan discovered an algorithmic-complexity denial of service vulnerability in the eml_parser library. The flaw existed within the eml_parser.routing.parserouting() function, which is responsible for parsing Received headers in email messages.

The vulnerability occurred because the function dynamically constructed a regular expression using four nested greedy capture groups. When a crafted email header made the trailing date literal unmatchable, the regex engine performed exhaustive backtracking. This process resulted in O(n^4) complexity, which could pin a CPU core and cause worker processes to hang. The issue affected eml_parser versions up to and including 3.0.3.

To address the vulnerability, the maintainers replaced the static date suffix with non-greedy capture groups and implemented a more efficient routing keyword detection logic. These changes reduced the processing complexity from O(n^4) to linear O(n). Users should update to version 3.0.4 to mitigate this risk.