Summary
Bleach 6.3.0 exposes a documented email-linkification path through bleach.linkify(..., parse_email=True). The implementation scans attacker-controlled text with EMAIL_RE.finditer() over the full character token and has no length, timeout, or linear prefilter before applying the dot-atom email regex. A non-email payload around 30 KB causes multi-second CPU consumption per request/call, creating a direct availability risk for applications that enable email linkification on user-submitted text.
Affected Product
- Package:
bleach
- Ecosystem: pip
- Affected versions: verified in
6.3.0; exact first affected version not established
- Patched versions: none known at finalization time
- Tested version:
6.3.0
- Audit commit/tag:
v6.3.0 / 5546d5dbce60d08ccb99d981778d74044d646d4e
- PyPI sdist SHA256:
6f3b91b1c0a02bb9a78b5a454c92506aa0fdf197e1d5e114d2e00c6f64306d22
Vulnerability Details
- CWE: CWE-1333: Inefficient Regular Expression Complexity; related availability impact maps to CWE-400
- Component:
bleach/linkifier.py, build_email_re(), LinkifyFilter.handle_email_addresses()
- Root cause:
handle_email_addresses() calls self.email_re.finditer(text) on attacker-controlled text. EMAIL_RE includes a repeated dot-atom local-part pattern, so non-email strings such as repeated a. segments with no @ force repeated long failing scans.
- Security boundary violated: user-submitted text processed by a documented safe linkification helper should not allow an attacker to impose superlinear CPU cost through non-email text.
- Direct impact: per-request CPU exhaustion / denial-of-service risk in applications that enable
parse_email=True on attacker-controlled text.