GHSA-v7px-3835-7gjx PraisonAIAgents has an OS Command Injection via shell=True in Memory Hooks Executor (memory/hooks.py)
SummaryThe memory hooks executor in praisonaiagents passes a user-controlled command string
directly to subprocess.run() with shell=True at
src/praisonai-agents/praisonaiagents/memory/hooks.py lines 303 to 305.
No sanitization, no shlex.quote(), no character filter, and no allowlist check
exists anywhere in this file. Shell metacharacters including semicolons, pipes,
ampersands, backticks, dollar-sign substitutions, and newlines are interpreted by
/bin/sh before the intended command executes.Two independent attack surfaces exist. The first is via pre_run_command and
post_run_command hook event types registered through the hooks configuration.
The second and more severe surface is the .praisonai/hooks.json lifecycle
configuration, where hooks registered for events such as BEFORE_TOOL and
AFTER_TOOL fire automatically during agent operation. An agent that gains
file-write access through prompt injection can overwrite .praisonai/hooks.json
and have its payload execute silently at every subsequent lifecycle event without
further user interaction.This file and these surfaces are not covered by any existing published advisory.Vulnerability DescriptionFile    : src/praisonai-agents/praisonaiagents/memory/hooks.py
Lines   : 303 to 305Vulnerable code:The variable command originates from hook.command, which is loaded directly
from .praisonai/hooks.json at line 396 of the same file.The hooks system registers pre_run_command and post_run_command as event types
at lines 54 and 55 and dispatches them through _execute_script() at line 261,
which calls the subprocess.run() block above.HookRunner at hooks/runner.py line 210 routes command-type hooks through
_execute_command_hook(), which feeds into this executor.BEFORE_TOOL and AFTER_TOOL events are fired automatically at every tool call
from agent/tool_execution.py line 183 and agent/chat_mixin.py line 2052.No fix exists. shell=False does not appear anywhere in memory/hooks.py.Grep Commands and Confirmed OutputStep 1. Confirm shell=True at exact lineStep 2. Confirm subprocess imported and calledStep 3. View full vulnerable call with contextStep 4. Confirm zero sanitization in this fileStep 5. Confirm hooks.json load and lifecycle dispatchStep 6. Confirm shell=False never existsStep 7. Confirm this file is absent from all existing advisoriesProof of ConceptSurface 1. hooks.json lifecycle payloadWrite the following to .praisonai/hooks.json in the project workspace:Then run any agent task:When the agent calls its first tool, BEFORE_TOOL fires, _execute_command_hook()
is called, subprocess.run(command, shell=True) executes, the $() substitution
runs, and the base64-encoded .env file is sent to the attacker endpoint.
No agent definition modification is required. The payload lives entirely in
hooks.json.Surface 2. pre_run_command event typeThe semicolons are interpreted by /bin/sh and all three commands execute in
sequence under the process user.Persistence payloadThis payload survives agent restarts. Every subsequent agent invocation fires
the reverse shell automatically at the BEFORE_TOOL lifecycle event.ImpactArbitrary OS command execution with the privileges of the praisonaiagents process.The hooks.json surface is exploitable through prompt injection in multi-agent
systems. Any agent with file-write access to the workspace, which is a standard
capability, can overwrite .praisonai/hooks.json and install a payload that
executes automatically at every BEFORE_TOOL or AFTER_TOOL lifecycle event.The payload lives entirely outside the agent definition and workflow configuration
files, making it invisible to code review of agent configurations. Payloads survive
agent restarts, creating a persistent backdoor that requires no further attacker
interaction after initial placement.On shared developer machines or CI/CD runners, any local user who can run
praisonai and write to the project workspace can achieve arbitrary code execution
under the identity of the praisonaiagents process.Recommended FixReplace shell=True with a parsed argument list:For hooks that need dynamic context values, pass them as environment variables
instead of interpolating into the command string:At hooks.json load time, validate the first token of every hook command against
an allowlist of permitted executables. Reject any entry whose executable is not
in the allowlist before any subprocess call is made.ReferencesCWE-78: Improper Neutralization of Special Elements used in an OS Command
Python subprocess security documentation
CVSS v4.0 score: 9.3