GitHub advisory · PyPI
PraisonAI: FastContext path resolution permits absolute and traversal reads outside the workspace
Description
PraisonAI's praisonaiagents.context.fast FastContext feature treats workspace_path as the root directory for code search, but its model-facing search tools and high-level read_context() helper accept absolute paths and .. traversal paths without checking that the resolved path remains under that workspace. A lower-trust prompt or caller that can influence FastContext tool arguments can read, search, and enumerate files outside the intended project workspace; the resulting file content is then returned to the caller or injected into the model's tool-result context.
FastContextAgent documents workspace_path as the "Root directory for searches" and stores it as an absolute path:
class FastContextAgent:
"""Specialized agent for fast parallel code search.
Attributes:
workspace_path: Root directory for searches
"""
def __init__(self, workspace_path: str, ...):
self.workspace_path = os.path.abspath(workspace_path)
The same class exposes grep_search, glob_search, read_file, and list_directory as model function-call tools via get_tools(). Those tools are intended to retrieve code context from the configured workspace.
The problem is in FastContextAgent.execute_tool(). It prepends workspace_path only when the caller supplies a relative path, but it does not reject absolute paths and does not canonicalize the joined relative path before enforcing containment:
if tool_name in ("grep_search", "glob_search"):
if "search_path" not in kwargs or kwargs["search_path"] == ".":
kwargs["search_path"] = self.workspace_path
elif not os.path.isabs(kwargs["search_path"]):
kwargs["search_path"] = os.path.join(self.workspace_path, kwargs["search_path"])
elif tool_name == "list_directory":
if "dir_path" not in kwargs or kwargs["dir_path"] == ".":…
Manual fix · PyPI
pip install --upgrade "praisonaiagents>=1.6.78"Sources