{"vuln_id":"GHSA-v7px-3835-7gjx","aliases":["CVE-2026-40111"],"description":"PraisonAIAgents has an OS Command Injection via shell=True in Memory Hooks Executor (memory/hooks.py)","published_at":"2026-04-10T19:21:54Z","modified_at":"2026-11-16T16:01:28Z","first_seen_at":"2026-11-21T19:15:20.271107Z","severity":"critical","severity_source":"ghsa","cvss_score":9.3,"cvss_vector":"CVSS:4.0/AV:L/AC:L/AT:N/PR:L/UI:N/VC:H/VI:H/VA:H/SC:H/SI:H/SA:H","cwe":["CWE-78"],"vendor":null,"product":null,"kev":{"is_kev":false,"date_added":null,"due_date":null,"ransomware":false},"epss":null,"epss_percentile":null,"nvd_status":null,"enriched_at":null,"links":{"nvd":"https://github.com/advisories/GHSA-v7px-3835-7gjx"},"matched_alias":null,"items":[{"id":2516,"source":{"id":"ghsa","name":"GitHub Security Advisories"},"title":"GHSA-v7px-3835-7gjx / CVE-2026-40111: PraisonAIAgents has an OS Command Injection via shell=True in Memory Hooks Executor (memory/hooks.py)","summary":"PraisonAIAgents has an OS Command Injection via shell=True in Memory Hooks Executor (memory/hooks.py)\n\nSummary\n\nThe memory hooks executor in praisonaiagents passes a user-controlled command string\ndirectly to subprocess.run() with shell=True at\nsrc/praisonai-agents/praisonaiagents/memory/hooks.py lines 303 to 305.\nNo sanitization, no shlex.quote(), no character filter, and no allowlist check\nexists anywhere in this file. Shell metacharacters including semicolons, pipes,\nampersands, backticks, dollar-sign substitutions, and newlines are interpreted by\n/bin/sh before the intended command executes.\n\nTwo independent attack surfaces exist. The first is via pre_run_command and\npost_run_command hook event types registered through the hooks configuration.\nThe second and more severe surface is the .praisonai/hooks.json lifecycle\nconfiguration, where hooks registered for events such as BEFORE_TOOL and\nAFTER_TOOL fire automatically during agent operation. An agent that gains\nfile-write access through prompt injection can overwrite .praisonai/hooks.json\nand have its payload execute silently at every subsequent lifecycle event without\nfurther user interaction.\n\nThis file and these surfaces are not covered by any existing published advisory.\n\n\nVulnerability Description\n\nFile    : src/praisonai-agents/praisonaiagents/memory/hooks.py\nLines   : 303 to 305\n\nVulnerable code:\n\n    result = subprocess.run(\n        command,\n        shell=True,\n        cwd=str(self.workspace_path),\n        env=env,\n        capture_output=True,\n        text=True,\n        timeout=hook.timeout\n    )\n\nThe variable command originates from hook.command, which is loaded directly\nfrom .praisonai/hooks.json at line 396 of the same file.\n\nThe hooks system registers pre_run_command and post_run_command as event types\nat lines 54 and 55 and dispatches them through _execute_script() at line 261,\nwhich calls the subprocess.run() block above.\n\nHookRunner at hooks/runner.py line 210 routes command-type hooks through\n_execute_command_hook(), which feeds into this executor.\n\nBEFORE_TOOL and AFTER_TOOL events are fired automatically at every tool call\nfrom agent/tool_execution.py line 183 and agent/chat_mixin.py line 2052.\n\nNo fix exists. shell=False does not appear anywhere in memory/hooks.py.\n\n\nGrep Commands and Confirmed Output\n\nStep 1. Confirm shell=True at exact line\n\n    grep -n \"shell=True\" \\\n      src/praisonai-agents/praisonaiagents/memory/hooks.py\n\n    Confirmed output:\n    305:                shell=True,\n\nStep 2. Confirm subprocess imported and called\n\n    grep -n \"import subprocess\\|subprocess\\.run\\|subprocess\\.Popen\" \\\n      src/praisonai-agents/praisonaiagents/memory/hooks.py\n\n    Confirmed output:\n    41:import subprocess\n    303:            result = subprocess.run(\n\nStep 3. View full vulnerable call with context\n\n    sed -n '295,320p' \\\n      src/praisonai-agents/praisonaiagents/memory/hooks.py\n\n    Confirmed output:\n            result = subprocess.run(\n                command,\n                shell=True,\n                cwd=str(self.workspace_path),\n                env=env,\n              \n\nAffected packages: pip:praisonaiagents\nPatched: praisonaiagents 1.5.128","url":"https://github.com/advisories/GHSA-v7px-3835-7gjx","published_at":"2026-04-10T19:21:54Z","updated_at":"2026-11-16T16:01:28Z","fetched_at":"2026-11-21T19:15:18.416899Z","severity":"critical","cvss_score":9.3,"epss":0.00238,"is_kev":false,"has_exploit":false,"kev_due_date":null,"vendor":null,"product":"praisonaiagents","vuln_id":"CVE-2026-40111","vuln_ids":["CVE-2026-40111","GHSA-V7PX-3835-7GJX"],"tags":["ghsa","pip","CWE-78"],"cluster_id":2476,"links":{"self":"https://vulnwatch.ve1ve2.com/api/v1/items/2516","html":"https://vulnwatch.ve1ve2.com/item/2516"}}]}