{"vuln_id":"GHSA-fr3h-cpq2-9496","aliases":["CVE-2026-129296"],"description":"mail-parser: Path Traversal vulnerability in attachment extraction","published_at":"2026-11-16T22:10:55Z","modified_at":"2026-11-16T22:10:56Z","first_seen_at":"2026-11-21T19:15:20.238585Z","severity":"medium","severity_source":"ghsa","cvss_score":6.5,"cvss_vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:H/A:N","cwe":["CWE-22","CWE-73"],"vendor":null,"product":null,"kev":{"is_kev":false,"date_added":null,"due_date":null,"ransomware":false},"epss":null,"epss_percentile":null,"nvd_status":null,"enriched_at":null,"links":{"nvd":"https://github.com/advisories/GHSA-fr3h-cpq2-9496"},"matched_alias":null,"items":[{"id":2476,"source":{"id":"ghsa","name":"GitHub Security Advisories"},"title":"GHSA-8cgq-x343-p74c / CVE-2026-129301: mail-parser: One hostile attachment aborts `write_attachments()` and silently drops the rest of the batch","summary":"mail-parser: One hostile attachment aborts `write_attachments()` and silently drops the rest of the batch\n\n### Impact\n\n`write_attachments()` called `_safe_attachment_filename()` and `write_sample()` inside its loop\nwith no guard, so a single crafted attachment raised out of the whole save. Every attachment\n**after** the malicious one was silently never written, with no error surfaced to a caller that\ncatches only `MailParserError`.\n\nThat is an evasion primitive as much as an availability bug: a sender puts one poisoned part\nfirst and the real payload second, and the payload never reaches the extraction directory that\na downstream scanner or sandbox reads — while it still reaches the recipient's mail client\nintact. The tool's output diverges from the bytes actually in the message, which is the same\nfailure mode as the filename-sanitizing bypass in\n[GHSA-fr3h-cpq2-9496](https://github.com/SpamScope/mail-parser/security/advisories/GHSA-fr3h-cpq2-9496).\n\nThree shapes were reachable, all from attacker-controlled MIME metadata:\n\n- **NUL smuggled through RFC 2231** — `filename*=us-ascii''evil%00.bin` decodes to a NUL in the\n  filename during parsing and raised `ValueError` out of the name check;\n- **overlong basename** — a filename longer than `NAME_MAX` (e.g. 300 characters) raised\n  `OSError: File name too long` from `open()`, *after* creating a zero-byte stub on disk;\n- **undecodable payload** — a body that is not valid base64 raised `binascii.Error` (a\n  `ValueError` subclass) from the decode performed inside the `open()` block.\n\n```python\nimport tempfile, mailparser\n\nraw = (\"Content-Type: multipart/mixed; boundary=b\\r\\n\\r\\n\"\n       \"--b\\r\\nContent-Type: application/octet-stream\\r\\n\"\n       \"Content-Disposition: attachment; filename*=us-ascii''evil%00.bin\\r\\n\\r\\nxx\\r\\n\"\n       \"--b\\r\\nContent-Type: application/octet-stream\\r\\n\"\n       \"Content-Disposition: attachment; filename=good.bin\\r\\n\\r\\nyy\\r\\n\"\n       \"--b--\\r\\n\")\n\nmp = mailparser.parse_from_string(raw)     # parse itself is fine; safe_filename is None\nmp.write_attachments(tempfile.mkdtemp())\n# 4.6.0 - 4.6.2 -> ValueError, and good.bin is never written\n# 4.6.3         -> logs \"Skipped attachment with invalid filename: 'evil\\x00.bin'\";\n#                  good.bin is written\n```\n\n`parse()` itself was never affected — it catches the `ValueError` — so only the write path was\nunguarded. The reject-paths that made this reachable were introduced with the filename\nsanitizing in 4.6.0 (PR #165).\n\n### Patches\n\nFixed in **4.6.3**. `write_attachments()` now logs and skips a single unusable attachment\ninstead of aborting the batch:\n\n- an invalid filename is caught and skipped;\n- overlong basenames are truncated to 240 UTF-8 bytes, preserving the extension, rather than\n  reaching `open()`;\n- the base64 decode moved *before* `open()`, so a failure leaves no zero-byte stub, and it now\n  repairs padding and alphabet errors the way mail clients do (matching `MIME::Base64` on 2008\n  cases) — rejecting them let a sender append one character to make an attachment vanish from\n  the extraction directory while it still re\n\nAffected packages: pip:mail-parser\nPatched: mail-parser 4.6.3","url":"https://github.com/advisories/GHSA-8cgq-x343-p74c","published_at":"2026-11-16T22:22:13Z","updated_at":"2026-11-16T22:23:34Z","fetched_at":"2026-11-21T19:15:18.416867Z","severity":"medium","cvss_score":6.5,"epss":0.00335,"is_kev":false,"has_exploit":false,"kev_due_date":null,"vendor":null,"product":"mail-parser","vuln_id":"CVE-2026-129301","vuln_ids":["CVE-2026-129296","CVE-2026-129301","GHSA-8CGQ-X343-P74C","GHSA-FR3H-CPQ2-9496"],"tags":["ghsa","pip","CWE-248","CWE-436"],"cluster_id":2396,"links":{"self":"https://vulnwatch.ve1ve2.com/api/v1/items/2476","html":"https://vulnwatch.ve1ve2.com/item/2476"}},{"id":2483,"source":{"id":"ghsa","name":"GitHub Security Advisories"},"title":"GHSA-fr3h-cpq2-9496 / CVE-2026-129296: mail-parser: Path Traversal vulnerability in attachment extraction","summary":"mail-parser: Path Traversal vulnerability in attachment extraction\n\nA path traversal vulnerability was identified in mail-parser when extracting email attachments using the write_attachments() and write_sample() APIs.\n\nA specially crafted email containing malicious attachment filenames (for example, using directory traversal sequences such as \"../\" or absolute filesystem paths) could cause files to be written outside the intended output directory. Depending on how the library was used and the permissions of the executing process, this could result in arbitrary file overwrite.\n\nThe vulnerability affects mail-parser versions 3.8.0 through 4.5.0.\n\nThe issue has been addressed by introducing comprehensive filename sanitization and path validation before any file is written to disk. The fix includes:\n\n- Sanitization of attachment filenames before writing.\n- Validation that all output paths remain within the intended destination directory.\n- Rejection of symbolic link targets.\n- Normalization of Windows and POSIX path separators.\n- Validation and rejection of invalid or unsafe filenames.\n- Protection applied consistently in both write_attachments() and write_sample() APIs.\n\nUsers are strongly encouraged to upgrade to the patched release.\n\n## Credits\n\nThe vulnerability was responsibly reported by **Niranjan Ganesan** (Security Insights, https://securityinsights.io/, GitHub: @iam-niranjan).\n\nThe vulnerability was analyzed, remediated, and the security fix was implemented by **Fedele Mantuano**, maintainer of mail-parser (LinkedIn: https://www.linkedin.com/in/fmantuano/).\n\nmail-parser would like to thank Niranjan Ganesan for following a coordinated vulnerability disclosure process and for collaborating throughout the remediation and verification of the fix.\n\nAffected packages: pip:mail-parser\nPatched: mail-parser 4.6.0","url":"https://github.com/advisories/GHSA-fr3h-cpq2-9496","published_at":"2026-11-16T22:10:55Z","updated_at":"2026-11-16T22:10:56Z","fetched_at":"2026-11-21T19:15:18.416873Z","severity":"medium","cvss_score":6.5,"epss":0.006,"is_kev":false,"has_exploit":false,"kev_due_date":null,"vendor":null,"product":"mail-parser","vuln_id":"CVE-2026-129296","vuln_ids":["CVE-2026-129296","GHSA-FR3H-CPQ2-9496"],"tags":["ghsa","pip","CWE-22","CWE-73"],"cluster_id":2397,"links":{"self":"https://vulnwatch.ve1ve2.com/api/v1/items/2483","html":"https://vulnwatch.ve1ve2.com/item/2483"}},{"id":6218,"source":{"id":"nvd","name":"NVD CVE API 2.0"},"title":"CVE-2026-129296: mail-parser is a tool that parses emails by enhancing the Python standard library and extracting message details into a comprehensive object. From 3.8.0 until…","summary":"mail-parser is a tool that parses emails by enhancing the Python standard library and extracting message details into a comprehensive object. From 3.8.0 until 4.6.0, the write_attachments() and write_sample() APIs use attacker-controlled attachment filenames without sufficient sanitization and path containment validation. Directory traversal sequences and absolute filesystem paths can cause an attachment to be written outside the intended output directory. An attacker can overwrite files accessible to the parsing process when an application extracts attachments from a crafted message. This issue is fixed in version 4.6.0.\n\nReferences:\nhttps://github.com/SpamScope/mail-parser/commit/3d6cb7a51f2ad7ea57e529121dbd5d56f29fefe8\nhttps://github.com/SpamScope/mail-parser/commit/b0a2e968815f3ed9e129efb0f5f7e935a9dacd1d\nhttps://github.com/SpamScope/mail-parser/pull/165\nhttps://github.com/SpamScope/mail-parser/releases/tag/4.6.0\nhttps://github.com/SpamScope/mail-parser/security/advisories/GHSA-fr3h-cpq2-9496","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-129296","published_at":"2026-11-16T18:17:30.390000Z","updated_at":"2026-11-18T16:18:10.647000Z","fetched_at":"2026-11-21T19:15:31.481993Z","severity":"medium","cvss_score":6.5,"epss":0.006,"is_kev":false,"has_exploit":false,"kev_due_date":null,"vendor":null,"product":null,"vuln_id":"CVE-2026-129296","vuln_ids":["CVE-2026-129296","GHSA-FR3H-CPQ2-9496"],"tags":["CWE-22"],"cluster_id":1408,"links":{"self":"https://vulnwatch.ve1ve2.com/api/v1/items/6218","html":"https://vulnwatch.ve1ve2.com/item/6218"}}]}