GHSA-VW55-54CG-FC63
Denial of service through quadratic processing of header fields with distinct names
CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:N/VI:N/VA:L/SC:N/SI:N/SA:N
Fuente: GitHub
Ciclo de vida de la vulnerabilidad
| Fecha | Fase | Evento | Detalle |
|---|---|---|---|
| Divulgación | Publicada | GHSA-VW55-54CG-FC63 divulgada · CVSS 6.9 (GitHub) | |
| Remediación | Parche 4.3.0 | eml-parser · 0 d desde divulgación | |
| Monitoreo | Detectada | Ingresó al índice | |
| Monitoreo | Verificada | Última verificación contra las fuentes |
Summary
eml_parser takes time that grows quadratically with the number of distinct header field names in a message. A small, standards-compliant message can therefore keep the parser busy for tens of seconds. A 1 MiB message with 21,000 small header fields takes about 20–45 seconds to parse with eml_parser 4.2.1, depending on hardware, while a 1 MiB message with a single large header field parses in about 10 ms. Applications that parse untrusted e-mail with eml_parser, such as phishing triage, incident response and malware analysis pipelines, can have their workers tied up by crafted messages.
Details
To collect all header fields of a message, `EmlParser.parse_email()` called `email.message.Message.get_all()` once for each distinct header field name. Each call scans the complete list of header fields, so processing takes time proportional to the number of distinct names multiplied by the total number of fields. Many fields sharing one name do not trigger the problem; many distinct names do.
The crafted message is compliant with RFC 5322: every line stays below the 998-character limit and no obsolete syntax is needed. The issue is separate from the limit on long header values introduced in 4.1.0 (`constants.MAX_PARSED_HEADER_SIZE`), because every individual field is small.
Proof of concept
import time
import eml_parser
n = 21_000
headers = ''.join(f'X-F{i}: {"F" * 40}\r\n' for i in range(n))
raw = f'From: a@example.test\r\nTo: b@example.test\r\nSubject: test\r\n{headers}\r\nbody\r\n'.encode()
start = time.perf_counter()
eml_parser.EmlParser().decode_email_bytes(raw)
print(f'{len(raw) / 1048576:.1f} MiB, {n} header fields: {time.perf_counter() - start:.1f} s')With 4.2.1 this takes over 20 seconds. Each doubling of the number of fields roughly quadruples the time.
Impact
This is a denial of service that affects availability only. Every application that passes attacker-controlled messages to eml_parser is affected. Each crafted message occupies a worker for tens of seconds, and longer under CPU quotas, so repeated submissions can exhaust a pool of analysis workers. Confidentiality and integrity are not affected.
Patches
Fixed in version X.Y.Z:
- Linear collection: header fields are grouped by name in a single pass, so collection time grows linearly with the number of fields. The 1 MiB message above now parses in about one second, with unchanged output.
- Parsing limit: as defence in depth, at most `constants.MAX_PARSED_HEADER_FIELDS` (10,000) header fields and `constants.MAX_PARSED_HEADER_BYTES` (2 MiB) of header values per message, including all MIME parts, go through full header parsing.
- Values beyond the limit are kept as raw text in the output, so no data is lost.
- The sender, recipient, subject, date, message ID and `Content-*` fields are always parsed.
- The message reports a `HeaderParsingLimitDefect` in `header.defect`.
Workarounds
If you cannot upgrade:
- Run eml_parser with a time limit per message, for example in a separate process that is stopped after a timeout.
- Reject or quarantine messages with an unusually large number of header fields before parsing them. Legitimate messages have from a few dozen to a few hundred.
Credits
Reported by YUN GU (DrNbnonono).
Incluye detalles técnicos publicados por el investigador. Úselos solo para validar y corregir sus propios sistemas.
Desglose de métricas
Rangos afectados
Estado del parche por paquete
| Paquete / producto | Estado | Corregida en | Desde divulgación | Última versión |
|---|---|---|---|---|
pypieml-parser |
Corregida | 4.3.0 | 0 d | 4.7.0 no afectada |
4.3.0Arsenal público
Sin exploits, módulos ni PoC públicos conocidos a la fecha de verificación.
https://github.com/GOVCERT-LU/eml_parser/security/advisories/GHSA-vw55-54cg-fc63Las referencias externas se muestran para copiar: cve.llama.ec no lo redirige a otros sitios.
