{"id":"CVE-2026-29780","aliases":["CVE-2026-29780","GHSA-389r-rccm-h3h5","PYSEC-2026-2148"],"related":[],"kind":"vulnerability","state":"published","title":"eml_parser: Path Traversal in Official Example Script Leading to Arbitrary File Write","summary":"eml_parser serves as a python module for parsing eml files and returning various information found in the e-mail as well as computed information. Prior to version 2.0.1, 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. This issue has been patched in version 2.0.1.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"eml_parser serves as a python module for parsing eml files and returning various information found in the e-mail as well as computed information. Prior to version 2.0.1, 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. This issue has been patched in version 2.0.1.","source":"cvelist"},{"lang":"en","text":"### 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```","format":"markdown","source":"ghsa"},{"lang":"es","text":"eml_parser sirve como un módulo de Python para analizar archivos eml y devolver diversa información encontrada en el correo electrónico, así como información calculada. Antes de la versión 2.0.1, el script de ejemplo oficial examples/recursively_extract_attachments.py contiene una vulnerabilidad de salto de ruta que permite la escritura arbitraria de archivos fuera del directorio de salida previsto. Los nombres de archivo adjuntos extraídos de correos electrónicos analizados se utilizan directamente para construir rutas de archivo de salida sin ninguna sanitización, permitiendo que un nombre de archivo controlado por el atacante escape del directorio de destino. Este problema ha sido parcheado en la versión 2.0.1.","source":"nvd"}],"published":"2026-03-05T00:16:57.000Z","modified":"2026-07-13T07:26:20.432Z","severity":{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:N/I:H/A:N","score":5.5,"rating":"MEDIUM"},"severities":[{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:N/I:H/A:N","score":5.5,"rating":"MEDIUM"},{"scorer":"GitHub","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:N/I:H/A:N","score":5.5,"rating":"MEDIUM"},{"scorer":"PyPA Advisory Database","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:N/I:H/A:N","score":5.5,"rating":"MEDIUM"}],"cwes":["CWE-22"],"affected":[{"ranges":[{"version":"< 2.0.1","status":"affected"}],"vendor":"GOVCERT-LU","product":"eml_parser","source":"cvelist"},{"ranges":[{"type":"ecosystem","introduced":"0","status":"affected","fixed":"2.0.1"}],"ecosystem":"PyPI","package":"eml-parser","purl":"pkg:pypi/eml-parser","source":"ghsa"},{"ranges":[{"status":"affected","fixed":"2.0.1"}],"vendor":"govcert.lu","product":"eml_parser","cpe":"cpe:2.3:a:govcert.lu:eml_parser:*:*:*:*:*:python:*:*","source":"nvd"},{"ranges":[{"type":"ecosystem","introduced":"0","status":"affected","fixed":"2.0.1"}],"ecosystem":"PyPI","package":"eml-parser","purl":"pkg:pypi/eml-parser","source":"pysec"}],"references":[{"url":"https://github.com/GOVCERT-LU/eml_parser/security/advisories/GHSA-389r-rccm-h3h5","tags":["evidence","exploit","mitigation","vendor-advisory","web","x-refsource-confirm"],"sources":["cvelist","ghsa","nvd","pysec"]},{"url":"https://github.com/GOVCERT-LU/eml_parser/issues/88","tags":["issue-tracking","report","web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd","pysec"]},{"url":"https://github.com/GOVCERT-LU/eml_parser/commit/99af03a09a90aaaaadd0ed2ffb5eea46d1ea2cc9","tags":["fix","patch","web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd","pysec"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2026-29780","tags":["advisory"],"sources":["ghsa"]},{"url":"https://github.com/GOVCERT-LU/eml_parser","tags":["package"],"sources":["ghsa"]}],"credits":[],"assigner":"GitHub_M","ssvc":{"scorer":"CISA-ADP","exploitation":"poc","automatable":"no","technicalImpact":"partial","date":"2026-03-09T17:52:36.051Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2026-29780","url":"https://www.cve.org/CVERecord?id=CVE-2026-29780","licence":"CVE Terms of Use","modified":"2026-03-09T18:26:58.485Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-389r-rccm-h3h5","url":"https://github.com/advisories/GHSA-389r-rccm-h3h5","licence":"CC-BY-4.0","modified":"2026-07-13T07:26:20.432Z"},{"source":"nvd","name":"NVD","id":"CVE-2026-29780","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-29780","licence":"Public domain","modified":"2026-06-17T10:29:52.353Z"},{"source":"pysec","name":"PyPA Advisory Database","id":"PYSEC-2026-2148","url":"https://osv.dev/vulnerability/PYSEC-2026-2148","licence":"CC-BY-4.0","modified":"2026-07-13T07:15:25.076Z"}],"updatedAt":"2026-11-25T22:59:15.474Z","epss":{"score":0.00272,"percentile":0.2091,"date":"2026-12-01T12:00:22.000Z"}}