mail-parser is vulnerable to Improper Handling of Exceptional Conditions
65
Medium Risk
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.
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.
mail-parser is vulnerable to Improper Handling of Exceptional Conditions in versions 4.6.0 - 4.6.2.
Upgrade the mail-parser library to the patch version.
Connect your repositories to instantly see whether vulnerable or malicious packages exist in your codebase.
Free. No credit card required.

I consent to receiving marketing communications based on Aikido’s Privacy Policy.
SOC 2Compliant
ISO 27001Compliant