Summary
PraisonAI Code agent tools fail open without a workspace boundary
PraisonAI Code's agent-compatible CODE_TOOLS wrappers keep a global workspace root initialized to None. If an application uses CODE_TOOLS, code_read_file, code_search_replace, or code_apply_diff before calling set_workspace(), the wrappers pass workspace=None into lower-level helpers that only enforce path containment when a workspace is truthy. Absolute paths outside the intended project workspace are then read and modified.
The official examples correctly call set_workspace() before CODE_TOOLS, and this report does not claim configured workspaces are ineffective. The issue is the fail-open default. PraisonAI's security documentation describes workspace boundaries as the path-traversal protection mechanism, and the already-published Python API arbitrary file write advisory (GHSA-hvhp-v2gc-268q) was fixed by defaulting an unset workspace to os.getcwd(). The adjacent read and edit paths reached through CODE_TOOLS still fail open.
Affected Components
- Package:
praisonai - Current upstream main tested:
2f9677abb2ea68eab864ee8b6a828fd0141612e1 - Latest tested release:
v4.6.57 - Primary files:
src/praisonai/praisonai/code/agent_tools.pysrc/praisonai/praisonai/code/tools/read_file.pysrc/praisonai/praisonai/code/tools/search_replace.pysrc/praisonai/praisonai/code/tools/apply_diff.py
Root Cause
agent_tools.py initializes _workspace_root to None and passes it directly to lower-level helpers:
_workspace_root: Optional[str] = None
...
result = _read_file(..., workspace=_workspace_root)
...
result = _search_replace(..., workspace=_workspace_root)
The lower-level helpers only enforce containment if workspace is set:
if workspace:
if not is_path_within_directory(abs_path, workspace):
return {"success": False, ...}
The already-hardened write_file() path uses effective_workspace = workspace or os.getcwd(). Current tests assert that write_file(workspace=None) must stay inside the current working directory. The same fail-closed default is missing from read_file, search_replace, apply_diff, and the agent wrappers that call them.
Local-Only Reproduction
Run:
PYTHONPATH=/path/to/PraisonAI/src/praisonai:/path/to/PraisonAI/src/praisonai-agents \
python poc_code_tools_workspace_bypass.py
Expected vulnerable result:
[poc] HIT: CODE_TOOLS wrappers read and edit outside workspace when workspace is unset
The PoV creates a temporary workspace and a temporary file outside that workspace. With get_workspace() == None, code_read_file() reads the outside file, code_search_replace() modifies it, and code_apply_diff() modifies it again. After set_workspace(workspace), the same outside path is rejected by all three wrappers.
No external services, model providers, or network access are used.
Affected-Version Sweep
The same behavior was reproduced on:
- current upstream main:
2f9677abb2ea68eab864ee8b6a828fd0141612e1 v4.6.57v4.6.56v4.6.10v4.6.9v4.5.128v4.5.126v3.9.26v3.9.24
Disclosure Route
PraisonAI's official security documentation lists GitHub Security Advisories as the preferred reporting method and asks reports to include reproduction steps, affected versions, impact, and suggested fixes. The repository security policy page currently shows no configured SECURITY.md, but private vulnerability reporting is available.
Impact
If an application exposes PraisonAI Code's agent-compatible CODE_TOOLS to an LLM before setting a workspace boundary, prompt-influenced tool calls can read and modify files outside the intended project workspace. The practical attack shape matches the existing PraisonAI prompt-content advisory pattern: untrusted content influences an agent that has been given file-editing tools.
Practical impacts include:
- reading host secrets or local configuration files accessible to the process user;
- modifying arbitrary existing files when the attacker can supply or infer matching content for
code_search_replaceorcode_apply_diff; - using
code_read_fileto first learn file content and thencode_apply_diffto produce an exact modification; - bypassing the advertised workspace-boundary security posture unless the embedding application remembered to call
set_workspace()first.
This issue does not claim set_workspace() is ineffective. The control works when configured. The vulnerability is the fail-open default for the advertised agent-tool bundle and adjacent read/edit helpers.
Input manipulates file paths to reach files outside the intended directory, such as configuration or credential files. Typical impact: unauthorized file read or write outside the intended directory.
GHSA-GCQ3-MFVH-3X25 has a CVSS score of 7.3 (High). The vector is network-reachable, low privileges required, and user interaction required. A CVSS score reflects the worst-case severity of the vulnerability, not your specific exposure. Whether this affects your application depends on whether the vulnerable code is present and reachable in your environment. A fixed version is available (4.6.59); upgrading removes the vulnerable code path.
Affected versions
Security releases
Kodem intelligence
Severity tells you how bad this could be in the worst case. It does not tell you whether you are exposed. Exploitability and impact are functions of runtime truth: whether the vulnerable code is present, reachable, and actually executes in your application. A vulnerable package can sit in your dependency tree and never run.
Kodem, an Intelligent Application Security platform, uses runtime intelligence to reveal which vulnerabilities actually execute in production, so teams prioritize the ones that genuinely matter. Kodem's runtime-powered SCA identifies whether this CVE is reachable in your applications.
Remediation advice
Recommended fix:
- Make every low-level file helper compute
effective_workspace = workspace or os.getcwd()before resolving paths. - Make
code_read_file,code_list_files,code_apply_diff,code_search_replace, andcode_execute_commanduseos.getcwd()as the default workspace when_workspace_root is None. - Keep allowing absolute paths only when they resolve inside the effective workspace.
- Add regression tests proving outside absolute paths are rejected before and after
set_workspace(). - Consider failing closed if
CODE_TOOLSis used before a workspace is configured, or log a warning when the default current working directory is used.
Frequently Asked Questions
- What is GHSA-GCQ3-MFVH-3X25? GHSA-GCQ3-MFVH-3X25 is a high-severity path traversal vulnerability in praisonai (pip), affecting versions <= 4.6.57. It is fixed in 4.6.59. Input manipulates file paths to reach files outside the intended directory, such as configuration or credential files.
- How severe is GHSA-GCQ3-MFVH-3X25? GHSA-GCQ3-MFVH-3X25 has a CVSS score of 7.3 (High). This score reflects the worst-case severity of the vulnerability, not your specific exposure. Whether it represents real risk in your environment depends on whether the vulnerable code is present and reachable.
- Which versions of praisonai are affected by GHSA-GCQ3-MFVH-3X25? praisonai (pip) versions <= 4.6.57 is affected.
- Is there a fix for GHSA-GCQ3-MFVH-3X25? Yes. GHSA-GCQ3-MFVH-3X25 is fixed in 4.6.59. Upgrade to this version or later.
- Is GHSA-GCQ3-MFVH-3X25 exploitable, and should I be worried? Whether GHSA-GCQ3-MFVH-3X25 is exploitable in your environment depends on whether the vulnerable code is present and reachable. A CVSS score is a worst-case rating; it does not account for your specific deployment, configuration, or usage patterns. Kodem, an Intelligent Application Security platform, uses runtime intelligence to show which vulnerabilities actually execute in production, so you can focus on the ones that represent real risk. Get a demo
- What actually determines whether GHSA-GCQ3-MFVH-3X25 is exploitable, and how bad it is? Exploitability and impact are not fixed properties of a CVE. They depend on runtime truth: whether the vulnerable code is present, reachable, and actually executes in your application. A high CVSS score on a dependency that never runs is not the same as real risk. Kodem, an Intelligent Application Security platform, uses runtime intelligence to reveal which vulnerabilities actually execute in production, so teams prioritize the ones that genuinely matter.
- How do I fix GHSA-GCQ3-MFVH-3X25? Upgrade
praisonaito 4.6.59 or later.