Home/Research/Post

GHSA-r7w7-vpq8-c5vv: mail-parser is vulnerable to polynomial ReDoS in email header parsing

  • Severity: HIGH
  • CVE: CVE-2026-129295
  • Ecosystems: pip
  • Packages: mail-parser

### Summary

Two regular expressions used while parsing email headers backtrack
polynomially on attacker-controlled input. Parsing a single small, well-formed
email can consume minutes to hours of CPU, denying service to any process that
parses untrusted mail.

Both are reachable from an ordinary `parse_from_string()`, `parse_from_bytes()`
or `parse_from_file()` call — no special API, option, or malformed structure is
required by the victim.

### Details

**1. Address-header fallback regex (`src/mailparser/utils.py`)**

`get_addresses()` falls back to `_ADDR_FALLBACK_RE` whenever
`email.utils.getaddresses(strict=True)` yields no usable address. The
alternative `([^` overlaps a lazy quantifier with an adjacent
`\s*` — a space matches both. Driven by `finditer`, which retries at every
offset and rescans the remainder, matching degrades to **quadratic** on `

Source: GitHub Security Advisories · 2026-11-16