---
id: "CVE-2026-129296"
page: "https://infrastack.ai/live/CVE-2026-129296"
kind: "vulnerability"
aliases: ["CVE-2026-129296", "GHSA-fr3h-cpq2-9496"]
title: "mail-parser: Path Traversal vulnerability in attachment extraction"
severity: "medium"
cvss: 6.5
epss: null
exploited: false
status: "open"
category: "package"
products: [{"name": "mail-parser", "fixed": ["4.6.0"], "affected": ">= 3.8.0, < 4.6.0", "ecosystem": "pypi"}]
ecosystems: ["pypi"]
tags: ["cwe-22", "cwe-73", "mail-parser", "package", "python"]
not_affected_if: ["no-attachment-writing", "trusted-input-only"]
published_at: "2026-11-16T18:17:30+00:00"
first_seen_at: "2026-11-16T18:38:03+00:00"
updated_at: "2026-11-16T22:13:27+00:00"
sources: [{"source": "nvd", "url": "https://nvd.nist.gov/vuln/detail/CVE-2026-129296", "first_seen_at": "2026-11-16T18:38:03+00:00"}, {"source": "ghsa", "url": "https://github.com/advisories/GHSA-fr3h-cpq2-9496", "first_seen_at": "2026-11-16T22:12:15+00:00"}]
exploit_sources: []
---

# mail-parser: Path Traversal vulnerability in attachment extraction

Link for people: https://infrastack.ai/live/CVE-2026-129296 (this .md is for agents)

mail-parser's write_attachments() and write_sample() functions accept attachment filenames containing path traversal sequences such as "../" or absolute paths. A crafted email can make the library write files outside the intended directory, which can overwrite arbitrary files depending on process permissions.

_Summary, check and fix written by a model from the sources; labelled as such._

## Affected

- pypi:mail-parser affected >= 3.8.0, < 4.6.0 fixed 4.6.0

## How to check

- Check the installed version with `pip show mail-parser`; affected versions are `3.8.0` through `4.5.0`.
- Search your code for calls to `write_attachments()` or `write_sample()` on untrusted email input.

## Fix

- `mail-parser` upgrade to `4.6.0`

## Timeline

- 2026-11-16T18:38:03+00:00 nvd https://nvd.nist.gov/vuln/detail/CVE-2026-129296
- 2026-11-16T22:12:15+00:00 ghsa https://github.com/advisories/GHSA-fr3h-cpq2-9496

## Documents

- [advisory] Vendor advisory: github.com https://github.com/SpamScope/mail-parser/security/advisories/GHSA-fr3h-cpq2-9496
- [advisory] Maintainer's advisory: api.github.com https://api.github.com/repos/SpamScope/mail-parser/security-advisories/GHSA-fr3h-cpq2-9496
- [fix] Patch: github.com https://github.com/SpamScope/mail-parser/commit/3d6cb7a51f2ad7ea57e529121dbd5d56f29fefe8
- [fix] Patch: github.com https://github.com/SpamScope/mail-parser/commit/b0a2e968815f3ed9e129efb0f5f7e935a9dacd1d
- [fix] Release notes: github.com https://github.com/SpamScope/mail-parser/releases/tag/4.6.0
- [fix] Patch: github.com https://github.com/SpamScope/mail-parser/pull/165

## From the sources

A path traversal vulnerability was identified in mail-parser when extracting email attachments using the write_attachments() and write_sample() APIs.

A 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.

The vulnerability affects mail-parser versions 3.8.0 through 4.5.0.

The issue has been addressed by introducing comprehensive filename sanitization and path validation before any file is written to disk. The fix includes:

- Sanitization of attachment filenames before writing.
- Validation that all output paths remain within the intended destination directory.
- Rejection of symbolic link targets.
- Normalization of Windows and POSIX path separators.
- Validation and rejection of invalid or unsafe filenames.
- Protection applied consistently in both write_attachments() and write_sample() APIs.

Users are strongly encouraged to upgrade to the patched release.

## Credits

The vulnerability was responsibly reported by **Niranjan Ganesan** (Security Insights, https://securityinsights.io/, GitHub: @iam-niranjan).

The vulnerability was analyzed, remediated, and the security fix was implemented by **Fedele Mantuano**, maintainer of mail-parser (LinkedIn: https://www.linkedin.com/in/fmantuano/).

mail-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.

---

_Free to read, with fair use of about 60 pages a minute. For higher limits or API access: sales@infrastack.ai_
