CVE-2026-55540: PraisonAI: [Path Traversal] agent tools escape the configured workspace via symlinks

Published Aug 25, 2026
·
Updated

Summary PraisonAI's praisonai.code tool wrappers (exported as CODETOOLS for agents) expose a workspace setting that the module itself treats as a path-traversal security boundary — readfile, writefile, applydiff, and searchreplace explicitly call ispathwithindirectory() and return "… is outside the workspace" on violations. That boundary is enforced unsoundly and inconsistently: 1. The containment helper uses os.path.abspath(), not realpath()/Path.resolve(). A symlink located inside the workspace whose target is outside has an abspath() that is still inside the workspace, so it passes the check while open() follows the link. This bypasses read, write, applydiff, and searchreplace (CWE-59). 2. listfiles() resolves path against the workspace but never calls the containment helper at all — ../ and absolute paths escape directly (CWE-22). 3. executecommand() takes a workspace argument documented "for security validation" but performs no cwd containment check; codeexecutecommand() resolves a relative cwd against the workspace and also never validates it (and never even passes workspace to the low-level helper). A relative cwd="../outside" runs commands from outside the workspace (CWE-22). An attacker who can influence an agent that has these tools attached (untrusted prompt, indirect prompt injection, or a server-exposed agent) can read, overwrite, list, and execute from outside the configured workspace, bounded only by the process user's filesystem permissions.

Technical Detail 1. Unsound containment helper (symlink bypass — CWE-59) python src/praisonai/praisonai/code/utils/fileutils.py — ispathwithindirectory() absfile = os.path.abspath(filepath) # does NOT resolve symlinks absdir = os.path.abspath(directory) if not absdir.endswith(os.sep): absdir += os.sep return absfile.startswith(absdir) or absfile == absdir.rstrip(os.sep) readfile/writefile/applydiff/searchreplace call this with the configured workspace (e.g. readfile.py: # Security check - ensure path is within workspace). Because abspath() does not canonicalize symlinks, a link at WORKSPACE/linktosecret.txt → /outside/secret.txt has abspath WORKSPACE/linktosecret.txt (inside) and passes, while open() follows it to the real outside target. 2. listfiles() has no containment check (CWE-22) python src/praisonai/praisonai/code/tools/listfiles.py if workspace and not os.path.isabs(path): abspath = os.path.abspath(os.path.join(workspace, path)) # ../ collapses out of workspace else: abspath = os.path.abspath(path) # absolute path used as-is ... os.path.isdir(abspath) then listed. ispathwithindirectory() is NEVER called. 3. executecommand() never validates cwd (CWE-22) python src/praisonai/praisonai/code/tools/executecommand.py — workspace param doc: "for security validation" if cwd: if workspace and not os.path.isabs(cwd): workdir = os.path.abspath(os.path.join(workspace, cwd)) # ../ escapes; no containment check else: workdir = os.path.abspath(cwd) subprocess.run(args, cwd=workdir, ...) # no ispathwithindirectory() anywhere python src/praisonai/praisonai/code/agenttools.py — codeexecutecommand() if workdir and workspaceroot and not os.path.isabs(workdir): workdir = os.path.join(workspaceroot, workdir) # joins, never validates result = executecommand(command=command, cwd=workdir, timeout=120) # workspace not even passed Note: executecommand rejects shell=True and runs shlex.split(command) via subprocess.run (no shell), so shell metacharacters (&&, >, pipes) do not work — but any binary still runs with attacker-chosen argv from the escaped cwd, which is sufficient to read/write outside the workspace. The workspace is an intended boundary (pre-empts "by design") The module asserts this control itself: readfile.py "Security check - ensure path is within workspace"; writefile.py "default workspace is cwd so relative paths cannot escape"; ispathwithindirectory docstring "(prevents path traversal)"; executecommand workspace param "for security validation". The bug is that the asserted control is unsound (abspath vs realpath) and not applied to listfiles/executecommand cwd.

Proof of Concept Self-contained, local temp fixtures only; no network, no untrusted commands. Real praisonai.code agent tools were called. workspace = /tmp/.../workspace outside = /tmp/.../outside [1] baseline plain ../ read -> BLOCKED: "Path '../outside/secret.txt' is outside the workspace" [2] symlink read (in-WS link) -> SUCCESS: returned "SECRETOUTSIDEWORKSPACE" [3] symlink write (in-WS link) -> SUCCESS: outside file now contains "OVERWRITTENVIASYMLINK" [4] codelistfiles("../outside") -> SUCCESS: "Contents of ../outside: 📄 secret.txt" [5] codeexecutecommand(cwd="../outside","pwd") -> SUCCESS: stdout "/tmp/.../outside" [6] codeexecutecommand(cwd="../outside", python3 -c open('planted.txt','w')...) -> SUCCESS: new file created OUTSIDE workspace, "PWNEDOUTSIDEWORKSPACE" Steps 2–6 each cross the configured workspace boundary; step 1 shows the plain-../ guard that the symlink and unscoped vectors bypass. Impact - Confidentiality: read files outside the workspace (in-workspace symlink; or list/enumerate outside dirs via listfiles). - Integrity: overwrite outside files via symlink; create/modify files outside the workspace via executecommand running in an escaped cwd. - Execution boundary: run arbitrary available binaries (argv-controlled) from a directory outside the workspace. Bounded by the process user's permissions. In a code-agent or server-exposed agent processing untrusted input, this exposes secrets / project-adjacent / host files and breaks the project-boundary integrity guarantee the workspace setting advertises.

Suggested Fix - Replace ispathwithindirectory() with a realpath() / Path.resolve()-based containment check, and compare with os.path.commonpath() rather than startswith. - Apply that check consistently to every file path, directory path, backup path, diff/search-replace target, and command working directory, after full canonicalization (resolve the symlink's real target, not the link path). - listfiles(): reject absolute paths and ../ escapes when workspace is set. - executecommand(): validate cwd containment when workspace is set; codeexecutecommand() should pass workspaceroot to the low-level helper or validate itself. - Regression tests: symlink read/write/diff/search-replace to outside targets; listfiles("../outside", workspace=…); executecommand(cwd="../outside", workspace=…); absolute outside paths with a workspace set.

Other sources

PraisonAI is a multi-agent teams system. Prior to praisonai 4.6.51, ispathwithindirectory() uses os.path.abspath() rather than os.path.realpath() for the workspace boundary. A symlink inside workspace can point outside and still pass the check, allowing readfile and other code tools to access files outside the configured workspace. This issue is fixed in version 4.6.58.

MITRE

Affected Software

1 affected componentFixes available
pip/PraisonAI<4.6.58
4.6.58

Remediation

Recommended actions to resolve this vulnerability, in priority order.

  1. Upgrade

    Upgrade pip/PraisonAI to a version that resolves this vulnerability.

    Fixed in 4.6.58
  2. Upgrade

    Upgrade praisonai.code (praisonai 4.6.58) to a version that resolves this vulnerability.

    Fixed in 4.6.58
  3. Configuration

    Replace the workspace boundary containment logic to canonicalize both the candidate path and workspace root via realpath()/Path.resolve() (resolving symlinks) and compare containment using os.path.commonpath(), not string prefix checks (startswith) and not abspath().

    is_path_within_directory() / workspace containment helper containment check implementation = realpath()/Path.resolve() + os.path.commonpath() (instead of abspath()/startswith)
  4. Configuration

    In execute_command(), when the workspace argument is set, validate that the provided command working directory (cwd) is contained within the workspace after full canonicalization (realpath()/resolve + commonpath containment). In code_execute_command(), either pass _workspace_root to the low-level helper or validate cwd in the wrapper itself.

    execute_command()/code_execute_command() cwd validation when workspace is set = validate _workspace_root containment
  5. Configuration

    In list_files(), add enforcement that rejects absolute paths and any ../ escapes when workspace is set (using the same realpath()/resolve + commonpath containment check).

    list_files() absolute path and ../ escape handling when workspace is set = reject absolute paths and ../ escapes
  6. Configuration

    Ensure is_path_within_directory() (implemented with realpath()/resolve + commonpath) is called consistently for every path category under the workspace boundary, including file paths, directory paths, backup paths, diff/search-replace targets, and the execute_command working directory.

    read_file.py / write_file.py / apply_diff / search_replace workspace path checks consistency = call the containment helper for every relevant target (including backup/diff/search-replace targets and command working directory)

Event History

Aug 25, 2026
CVE Published
via MITRE·02:54 PM
Data Sourced
via MITRE·02:54 PM
DescriptionSeverityWeakness
Advisory Published
via GitHub·02:54 PM
Data Sourced
via GitHub·02:54 PM
DescriptionSeverityWeaknessAffected Software
Data Sourced
via NVD·03:16 PM
DescriptionSeverityWeakness

Frequently Asked Questions

1

Which operations can access paths outside the intended workspace?

Symlinks within the workspace can bypass checks in read_file, write_file, apply_diff, and search_replace when they point outside it. list_files can escape directly through ../ or absolute paths, and command execution paths do not validate the supplied working directory.

2

Are symlinks necessary to escape the workspace?

No. Symlinks are needed to bypass the containment checks used by the file read and write operations, but list_files does not perform a containment check at all. Its path handling permits direct traversal using ../ and absolute paths.

3

What access conditions are reflected in the severity vector?

The supplied vector indicates that exploitation is network-reachable, requires no privileges, requires user interaction, and has high attack complexity. Successful exploitation can have high confidentiality and integrity impact and low availability impact.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203