llamaCVEVulnerability Intelligence
/
Advisory · GitHub · PyPI · mail-parser

GHSA-8CGQ-X343-P74C

mail-parser: One hostile attachment aborts `write_attachments()` and silently drops the rest of the batch

Parche disponible
Descargar PNG JSON
CVSS
—
medium
Fuente: —
ExplotaciónSin evidenciaNo figura en CISA KEV
Exploits públicos0Ninguno conocido
Parche1 versión4.6.3
Exposición3 dDesde la divulgación, 16 nov 2026, 5:22 p. m.
Detección1 hDesde la divulgación hasta su ingreso al índice
Timeline

Ciclo de vida de la vulnerabilidad

Hoy
Divulgación
Publicada +1
Explotación
Remediación
Monitoreo
Detectada +1
16 nov 26
20 nov 26
16 nov 26
17 nov 26
18 nov 26
19 nov 26
20 nov 26
FechaFaseEventoDetalle
Divulgación Publicada GHSA-8CGQ-X343-P74C divulgada
Divulgación Modificada Última actualización del registro
Monitoreo Detectada Ingresó al índice
Monitoreo Verificada Última verificación contra las fuentes
Resumen
Descripción del advisory
Texto original · GitHub · en inglés
Impact

`write_attachments()` called `_safe_attachment_filename()` and `write_sample()` inside its loop
with no guard, so a single crafted attachment raised out of the whole save. Every attachment
after the malicious one was silently never written, with no error surfaced to a caller that
catches only `MailParserError`.

That is an evasion primitive as much as an availability bug: a sender puts one poisoned part
first and the real payload second, and the payload never reaches the extraction directory that
a downstream scanner or sandbox reads — while it still reaches the recipient's mail client
intact. The tool's output diverges from the bytes actually in the message, which is the same
failure mode as the filename-sanitizing bypass in
GHSA-fr3h-cpq2-9496 https://github.com/SpamScope/mail-parser/security/advisories/GHSA-fr3h-cpq2-9496.

Three shapes were reachable, all from attacker-controlled MIME metadata:

  • NUL smuggled through RFC 2231 — `filename*=us-ascii''evil%00.bin` decodes to a NUL in the
  • overlong basename — a filename longer than `NAME_MAX` (e.g. 300 characters) raised
  • undecodable payload — a body that is not valid base64 raised `binascii.Error` (a
import tempfile, mailparser

raw = ("Content-Type: multipart/mixed; boundary=b\r\n\r\n"
       "--b\r\nContent-Type: application/octet-stream\r\n"
       "Content-Disposition: attachment; filename*=us-ascii''evil%00.bin\r\n\r\nxx\r\n"
       "--b\r\nContent-Type: application/octet-stream\r\n"
       "Content-Disposition: attachment; filename=good.bin\r\n\r\nyy\r\n"
       "--b--\r\n")

mp = mailparser.parse_from_string(raw)     # parse itself is fine; safe_filename is None
mp.write_attachments(tempfile.mkdtemp())
# 4.6.0 - 4.6.2 -> ValueError, and good.bin is never written
# 4.6.3         -> logs "Skipped attachment with invalid filename: 'evil\x00.bin'";
#                  good.bin is written

`parse()` itself was never affected — it catches the `ValueError` — so only the write path was
unguarded. The reject-paths that made this reachable were introduced with the filename
sanitizing in 4.6.0 (PR #165).

Patches

Fixed in 4.6.3. `write_attachments()` now logs and skips a single unusable attachment
instead of aborting the batch:

  • an invalid filename is caught and skipped;
  • overlong basenames are truncated to 240 UTF-8 bytes, preserving the extension, rather than
  • the base64 decode moved *before* `open()`, so a failure leaves no zero-byte stub, and it now
  • `MailParserPathError` is deliberately not caught by the per-attachment handler: a

Deduplication was hardened in the same change: it reserves room for its own suffix marker
(`write_sample()` sanitizes again, and the clamp there used to cut the marker back off,
collapsing distinct attachments onto one file), resumes from the last used suffix per stem
instead of rescanning from 1 (quadratic before — 16000 same-named attachments took 14 s, now
milliseconds), and folds case, because APFS, exFAT and SMB collapse `Invoice.pdf` and
`invoice.pdf`.

Workarounds

Upgrade to 4.6.3. If you cannot upgrade, do not call `write_attachments()` on untrusted mail;
iterate `parser.attachments` yourself and write each attachment inside its own
`try`/`except Exception`, skipping the ones whose `safe_filename` is `None`.

Versiones

Rangos afectados

Afectada Corregida
mail-parser≥ 4.6.0 < 4.6.3
4.6.0
4.6.3
Remediación

Estado del parche por paquete

Paquete / productoEstadoCorregida enDesde divulgaciónÚltima versión
PyPImail-parser
Corregida 4.6.3 — —
Versiones corregidas4.6.3
Explotación

Arsenal público

Sin exploits, módulos ni PoC públicos conocidos a la fecha de verificación.

Referencias
Advisoryhttps://nvd.nist.gov/vuln/detail/CVE-2026-129301
Otrahttps://github.com/SpamScope/mail-parser/security/advisories/GHSA-8cgq-x343-p74c
Otrahttps://github.com/SpamScope/mail-parser/pull/171
Otrahttps://github.com/SpamScope/mail-parser/commit/11b894a0b8b3f11055a99caff118206138d1daba
Otrahttps://github.com/SpamScope/mail-parser/commit/e1d9fe6778045d6e2c44406bc8822e3464c1097f
Otrahttps://github.com/SpamScope/mail-parser
Otrahttps://github.com/SpamScope/mail-parser/releases/tag/4.6.3

Las referencias externas se muestran para copiar: cve.llama.ec no lo redirige a otros sitios.