Vulnerabilities in pkg:pypi/eml-parser

PACKAGE
Advisory Identifier: GHSA-389r-rccm-h3h5
Advisory Summary

CVE-2026-29780 is a MODERATE (CVSS 5.5) path traversal vulnerability (CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')) affecting eml_parser libraries in the PyPI ecosystem. The issue involves path traversal in official example script leads to arbitrary file write. Remediation is available by upgrading affected packages to version 2.0.1.

1 Known Advisory Record(s)
Package Vulnerability Intelligence

pkg:pypi/eml-parser

1 Known Advisory Record(s)

Vulnerability advisories affecting package pkg:pypi/eml-parser. Select an advisory below to view technical details or fixes.

Advisory ID CVE / NVD Severity Summary
GHSA-389r-rccm-h3h5 CVE-2026-29780 MODERATE eml_parser: Path Traversal in Official Example Script Leads to Arbitrary File Write

CVE-2026-29780 at a Glance

CVE Identifier CVE-2026-29780
GHSA Identifier GHSA-389r-rccm-h3h5
Severity MODERATE
CVSS v3.1 Base Score 5.5
CWE Classification CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')
Affected Product eml_parser
Package Ecosystem PyPI
Published Date
Last Updated

Security Impact

CVSS: 5.5

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:N/I:H/A:N).

Attack Vector Local (AV:L)
Attack Complexity Low (AC:L)
Privileges Required None (PR:N)
User Interaction Required (UI:R)
Scope Unchanged (S:U)
Confidentiality None (C:N)
Integrity High (I:H)
Availability None (A:N)

How to Fix CVE-2026-29780

To remediate this vulnerability, upgrade all affected eml_parser dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

eml-parser fixed: 2.0.1
pip install eml-parser>=2.0.1
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

pip show eml-parser

How to Check if You Are Affected

To determine whether your Python environment is affected by CVE-2026-29780, inspect your installed packages using pip:

pip show eml-parser

Analyze the terminal output to locate any version of eml_parser in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 2.0.1), your application is affected.

Note: The pip show eml-parser command checks currently installed packages in your active Python environment.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal'), where the product uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the product does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the restricted directory. In eml_parser, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

### Summary The official example script `examples/recursively_extract_attachments.py` contains a path traversal vulnerability that allows arbitrary file write outside the intended output directory. Attachment filenames extracted from parsed emails are directly used to construct output file paths without any sanitization, allowing an attacker-controlled filename to escape the target directory. ### Details File: `examples/recursively_extract_attachments.py` Lines: 61–64 ```python for a in m['attachment']: out_filepath = out_path / a['filename'] # No sanitization print(f'\tWriting attachment: {out_filepath}') with out_filepath.open('wb') as a_out: a_out.write(base64.b64decode(a['raw'])) ``` The value `a['filename']` is attacker-controlled via crafted email attachment headers: ``` Content-Disposition: attachment; filename="../outside/pwned.txt" ``` No path normalization or boundary validation is performed before writing. ### PoC 1. Create a malicious `.eml` file: ``` Content-Disposition: attachment; filename="../outside/pwned.txt" ``` 2. Run the example script: ``` python recursively_extract_attachments.py -p ./emails -o ./safe ``` 3. Expected: `./safe/pwned.txt` 4. Actual: `./outside/pwned.txt` ← written outside the intended directory Verified on Kali Linux with eml_parser installed via pip in a virtual environment. ### Impact This vulnerability is limited to the **example script only** and does not affect the core eml_parser library. However, as the script is part of the official repository and is likely to be adapted for production use, an attacker supplying a crafted email could achieve arbitrary file write within the execution context. Potential attack scenarios include: - Cron job injection: `filename="../../etc/cron.d/backdoor"` - Web shell upload: `filename="../../var/www/html/shell.php"` - SSH key injection: `filename="../../home/user/.ssh/authorized_keys"` ### Recommended Fix ```python import os.path for a in m['attachment']: filename = os.path.basename(a['filename']) out_filepath = out_path / filename if not out_filepath.resolve().is_relative_to(out_path.resolve()): print(f'[!] Skipping suspicious filename: {a["filename"]}') continue print(f'\tWriting attachment: {out_filepath}') with out_filepath.open('wb') as a_out: a_out.write(base64.b64decode(a['raw'])) ```

CVE-2026-29780 Affected eml_parser Versions

1 component(s)
Fixed Versions:
2.0.1
Product / Package Ecosystem Affected Versions Fixed Version
eml-parser
PyPI
< 2.0.1
2.0.1

References

Frequently Asked Questions

What is CVE-2026-29780?
CVE-2026-29780 is a security vulnerability in eml_parser involving Path Traversal in Official Example Script Leads to Arbitrary File Write under CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal').
Which eml_parser versions are affected?
Affected versions include releases prior to 2.0.1 across affected packages: eml-parser.
What version fixes CVE-2026-29780?
Upgrading to 2.0.1 (or the latest patched release for your respective branch) resolves the vulnerability.
Is eml-parser affected?
Yes, eml-parser is affected in releases prior to 2.0.1. Upgrade your dependency to 2.0.1 or later.
What is the CVSS score of CVE-2026-29780?
CVE-2026-29780 has a CVSS v3.1 base score of 5.5 (MODERATE) with vector string CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:N/I:H/A:N.
What CWE is associated with CVE-2026-29780?
CVE-2026-29780 is classified under CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal') (The product uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the product does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the restricted directory.).
How can I check PyPI dependencies for CVE-2026-29780?
Run the dependency tree command: 'pip show eml-parser'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-389r-rccm-h3h5",
  "modified" : "2026-03-09T15:49:19Z",
  "published" : "2026-03-05T00:16:57Z",
  "aliases" : [ "CVE-2026-29780" ],
  "summary" : "eml_parser: Path Traversal in Official Example Script Leads to Arbitrary File Write",
  "details" : "### Summary\nThe official example script `examples/recursively_extract_attachments.py` contains a path traversal vulnerability that allows arbitrary file write outside the intended output directory. Attachment filenames extracted from parsed emails are directly used to construct output file paths without any sanitization, allowing an attacker-controlled filename to escape the target directory.\n\n### Details\nFile: `examples/recursively_extract_attachments.py`\nLines: 61–64\n```python\nfor a in m['attachment']:\n    out_filepath = out_path / a['filename']  # No sanitization\n    print(f'\\tWriting attachment: {out_filepath}')\n    with out_filepath.open('wb') as a_out:\n        a_out.write(base64.b64decode(a['raw']))\n```\n\nThe value `a['filename']` is attacker-controlled via crafted email attachment headers:\n```\nContent-Disposition: attachment; filename=\"../outside/pwned.txt\"\n```\n\nNo path normalization or boundary validation is performed before writing.\n\n### PoC\n1. Create a malicious `.eml` file:\n```\nContent-Disposition: attachment; filename=\"../outside/pwned.txt\"\n```\n2. Run the example script:\n```\npython recursively_extract_attachments.py -p ./emails -o ./safe\n```\n3. Expected: `./safe/pwned.txt`  \n4. Actual: `./outside/pwned.txt` ← written outside the intended directory\n\nVerified on Kali Linux with eml_parser installed via pip in a virtual environment.\n\n### Impact\nThis vulnerability is limited to the **example script only** and does not affect the core eml_parser library. However, as the script is part of the official repository and is likely to be adapted for production use, an attacker supplying a crafted email could achieve arbitrary file write within the execution context.\n\nPotential attack scenarios include:\n- Cron job injection: `filename=\"../../etc/cron.d/backdoor\"`\n- Web shell upload: `filename=\"../../var/www/html/shell.php\"`\n- SSH key injection: `filename=\"../../home/user/.ssh/authorized_keys\"`\n\n### Recommended Fix\n```python\nimport os.path\n\nfor a in m['attachment']:\n    filename = os.path.basename(a['filename'])\n    out_filepath = out_path / filename\n\n    if not out_filepath.resolve().is_relative_to(out_path.resolve()):\n        print(f'[!] Skipping suspicious filename: {a[\"filename\"]}')\n        continue\n\n    print(f'\\tWriting attachment: {out_filepath}')\n    with out_filepath.open('wb') as a_out:\n        a_out.write(base64.b64decode(a['raw']))\n```",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:N/I:H/A:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "PyPI",
      "name" : "eml-parser"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "2.0.1"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/GOVCERT-LU/eml_parser/security/advisories/GHSA-389r-rccm-h3h5"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2026-29780"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/GOVCERT-LU/eml_parser/issues/88"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/GOVCERT-LU/eml_parser/commit/99af03a09a90aaaaadd0ed2ffb5eea46d1ea2cc9"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/GOVCERT-LU/eml_parser"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-22" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-03-05T00:16:57Z",
    "nvd_published_at" : "2026-03-07T16:15:55Z"
  }
}