Intel

AIKIDO-2026-473501

mail-parser is vulnerable to Improper Handling of Exceptional Conditions

Improper Handling of Exceptional ConditionsGHSA-8cgq-x343-p74c Published 2 days ago

65

Medium Risk

This Affects:

PYTHONmail-parser
4.6.0 - 4.6.2
Fixed in 4.6.3
Are you affected? Scan for Free

TL;DR

write_attachments() called _safe_attachment_filename() and write_sample() inside its loop with no per-attachment guard, so one crafted part raised out of the whole save and every later attachment was never written. Callers that catch only MailParserError see no error. A sender can put a poisoned part first and a real payload second so a downstream scanner or sandbox never receives the payload while the recipient's mail client still does. Attacker-controlled MIME metadata can trigger this via a NUL smuggled through RFC 2231 (filename*=...evil%00.bin raises ValueError), a basename longer than NAME_MAX (OSError after a zero-byte stub), or invalid base64 (binascii.Error inside open()). The fix logs and skips a single unusable attachment, truncates overlong names, decodes base64 before opening the file, and keeps path-containment failures as MailParserPathError so they are not swallowed.

Who does this affect?

You are affected if you are using a version that falls within the vulnerable range and your application persists parsed attachments to disk using write_attachments() on untrusted email.

Background info

mail-parser is vulnerable to Improper Handling of Exceptional Conditions in versions 4.6.0 - 4.6.2.

How to fix this

Upgrade the mail-parser library to the patch version.