Summary
PraisonAI's MCP server exposes file-handling tools that accept user-controlled path strings and join them to a rules directory without containment checks, allowing path traversal outside the intended folder.
When combined with permissive writes, an attacker can create or overwrite arbitrary files the PraisonAI user can access, which can escalate to arbitrary code execution by dropping Python loader artifacts in site-packages or other sensitive locations.
Affected context
This vulnerability affects PraisonAI deployments where the MCP server (praisonai mcp serve) is exposed to external tools or agents that can invoke its JSON-RPC tools.
The at-risk context includes:
- Installations using the default file-handling tools:
praisonai.rules.create,praisonai.rules.show,praisonai.rules.delete, andpraisonai.workflow.show - Environments where MCP tool arguments are influenced by untrusted or semi-trusted clients, plugins, or automation
- Systems where the PraisonAI process runs with access to sensitive filesystem locations such as user site-packages, configuration directories, or scripts that are later executed by Python
The issue is most dangerous when PraisonAI runs under a user account that is also used to run other Python processes, since written files can be consumed by those processes automatically.
Exploit preconditions
- Attack surface: MCP JSON-RPC interface (
praisonai mcp serve) and the exposed file-handling tools. - Required access: Ability to invoke MCP tools or influence
params["arguments"]for: praisonai.rules.createpraisonai.rules.showpraisonai.rules.deletepraisonai.workflow.show(accepts absolute paths)- Trigger point: A tool invocation that supplies a crafted
rule_nameor equivalent path/filename argument (e.g.,../../relative/path), which the server joins onto~/.praison/rules/without containment checks, or uses as an absolute path for workflows. - Why exploitation is possible:
- The JSON-RPC dispatcher forwards
params["arguments"]directly to handlers via**kwargs, bypassing validation against the declared input schema (CWE-20, CWE-913). - The handlers perform naive path concatenation and accept absolute or traversal paths without sanitization or normalization (CWE-22).
- The tools can write files in attacker-chosen locations that the PraisonAI-running user can write to, enabling crafted Python
.pthor similar loader files to be dropped into directories automatically processed by Python (CWE-94, CWE-829).
Why this happens
The underlying bug is a combination of improper input validation and unsafe filesystem handling.
The MCP server assumes that incoming tool arguments conform to the advertised schema and represent safe, relative rule names, but it does not enforce this assumption.
The JSON-RPC dispatcher passes params["arguments"] directly to tool handlers using **kwargs, skipping type, shape, or value checks (CWE-20: Improper Input Validation, CWE-913: Improper Control of Dynamically-Managed Code Resources).
Inside the handlers, the path handling logic naively appends user-controlled strings to ~/.praison/rules/ or accepts absolute paths, without normalizing or verifying that the resulting path resides within the intended directory.
This pattern is a classic path traversal / directory breakout (CWE-22), which becomes more severe because the tools can create or modify arbitrary files.
When an attacker chooses locations the Python interpreter consults automatically (e.g., user site-packages and .pth files), this arbitrary write primitive escalates into arbitrary code execution in later Python processes (CWE-94, CWE-829).
Potential impact
- Creation or modification of arbitrary files writable by the PraisonAI user account
- Insertion of malicious
.pthor other loader files into Python site-packages, enabling arbitrary code execution in subsequent Python processes - Persistence of attacker code that runs whenever the user launches PraisonAI, an IDE script, or a Python REPL
- Overwriting or corrupting user configuration files, workflows, or other application data
- Potential lateral movement within the user's environment by tampering with scripts or tooling invoked by automation
General mitigation guidance
Effective mitigation focuses on strictly validating tool inputs and constraining filesystem operations to safe, well-defined locations.
Pattern-based defensive measures include:
- Enforce input schemas server-side: Validate JSON-RPC parameters against declared schemas before invoking handlers, including type checks, allowed fields, and disallowing unexpected keyword arguments.
- Normalize and validate paths: Resolve user-supplied path segments to canonical absolute paths and verify that they remain within an approved base directory before performing any file I/O.
- Disallow traversal sequences: Reject inputs containing
.., absolute path prefixes, or path separators where only logical identifiers (e.g., rule names) are expected. - Use explicit allowlists: Treat rule names as opaque identifiers and map them to filenames via internal lookup tables or sanitized mappings, rather than accepting arbitrary filesystem paths.
- Limit tool capabilities by default: Disable or restrict file-writing tools in untrusted or multi-tenant MCP deployments; prefer read-only operations unless write access is absolutely necessary.
- Apply least privilege: Run PraisonAI under a dedicated, low-privilege user with limited write access, reducing the impact of any arbitrary file writes.
How teams detect issues like this
Detection should combine code-level analysis with runtime monitoring:
- Static analysis and code review:
- Flag handlers that:
- Accept arbitrary
**kwargsor dynamic parameter maps from RPC layers (indicative of CWE-20/CWE-913). - Directly concatenate user-controlled strings into filesystem paths.
- Search for uses of
os.path.join,Path(...), or file APIs where inputs originate from networked or external RPC arguments without normalization or containment checks. - Review MCP tool definitions to ensure their declared schemas are actually enforced server-side.
- Automated tooling and CI policies:
- Use static analysis tools or linters configured with custom rules to detect path traversal patterns and unsanitized path joins.
- Enforce secure coding policies in code review that require path normalization and base-directory enforcement for all file-handling tools.
- Runtime and operational monitoring:
- Log MCP tool invocations along with normalized target paths and alert on suspicious patterns, such as
..components or unexpected directories. - Monitor file system changes in sensitive locations (e.g., Python site-packages, configuration directories) for unexpected new or modified files generated by PraisonAI processes.

