CVE-2026-129296 in mail-parser
Summary
by MITRE • 11/16/2026
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.
If you want to get the best quality for vulnerability data then you always have to consider VulDB.
Analysis
by VulDB Data Team • 11/16/2026
The mail-parser library serves as a utility for processing email messages by leveraging and extending Python's standard library capabilities to extract detailed information into structured objects. While this functionality is essential for applications that need to ingest, analyze, or archive electronic communications, the security of such parsing tools relies heavily on how they handle untrusted input data. In versions ranging from 3.8.0 through 4.6.0, a critical vulnerability exists within the write_attachments and write_sample APIs, which are designed to save extracted email components to the local filesystem. These functions accept filenames derived directly from the email message headers or content without implementing adequate sanitization mechanisms or path containment validation checks. This lack of rigorous input validation creates a significant security gap that can be exploited by malicious actors crafting specific email payloads.
The core technical flaw lies in the failure to normalize and validate file paths before writing them to disk. When an attacker includes directory traversal sequences, such as ../.., or absolute filesystem paths within attachment filenames embedded in an email message, the mail-parser library processes these strings literally rather than interpreting them relative to the intended output directory. Consequently, instead of placing the extracted content into a designated safe folder, the application writes files to arbitrary locations on the host system determined by the attacker-controlled path components. This behavior violates fundamental principles of secure file handling, specifically the requirement that user-supplied input must never be used directly in filesystem operations without strict validation against directory traversal attacks. The vulnerability allows for precise control over the destination path, enabling an adversary to dictate exactly where data is written on the target machine's storage infrastructure.
The operational impact of this vulnerability is severe, primarily manifesting as a Local File Write or Path Traversal issue that can lead to arbitrary file overwrite conditions. If the process executing mail-parser has write permissions in directories outside the intended output location, an attacker can overwrite critical system files, configuration files, or application-specific data files. This capability undermines the integrity of the host environment and may facilitate further exploitation chains. For instance, overwriting a script that is subsequently executed by the same user could lead to remote code execution. Additionally, if sensitive information such as private keys, database credentials, or proprietary source code resides in accessible directories, an attacker can exfiltrate this data by writing malicious content into those locations for later retrieval or by corrupting essential files to cause denial of service conditions within the affected application ecosystem.
This vulnerability aligns with Common Weakness Enumeration CWE-22, which defines Improper Limitation of a Pathname to a Restricted Directory, commonly known as directory traversal. It also relates to CWE-73, External Control of File Name or Path, highlighting the failure to neutralize special elements within file names that could cause unintended filesystem access. From an offensive security perspective, this flaw maps to MITRE ATT&CK techniques involving Local File Discovery and potentially T1564, Hidden Files and Directories if used to conceal malicious artifacts. The root cause is a lack of robust input validation on external data sources before performing sensitive system operations, a pattern frequently observed in libraries that process untrusted media formats without implementing strict allow-listing or canonicalization strategies for file paths.
To mitigate this vulnerability, organizations must immediately upgrade the mail-parser library to version 4.6.0 or later, where these path validation issues have been addressed by developers through improved sanitization logic and stricter containment checks. For applications unable to update promptly due to dependency constraints, defensive coding practices should be implemented as a temporary countermeasure. This includes manually validating attachment filenames before passing them to the library's write functions, ensuring that resolved paths remain within an expected base directory using canonical path resolution methods provided by standard libraries such as os.path.realpath in Python. Additionally, running email processing services with minimal file system privileges can limit the blast radius of any successful exploitation attempt, restricting access only to specific directories required for normal operation and preventing writes to sensitive system areas.