PraisonAI Has Path Traversal in FileTools

Description

Executive Summary:

The path validation has a critical logic bug: it checks for .. AFTER normpath() has already collapsed all .. sequences. This makes the check completely useless and allows trivial path traversal to any file on the system.
The path validation function also does not resolve the symlink wich could potentially cause path traversal.

Details:

_validate_path() calls os.path.normpath() first, which collapses .. sequences, then checks for '..' in normalized. Since .. is already collapsed, the check always passes.

Vulnerable File:
src/praisonai-agents/praisonaiagents/tools/file_tools.py

Lines:
42-49

class FileTools:
    """Tools for file operations including read, write, list, and information."""

    @staticmethod
    def _validate_path(filepath: str) -> str:
        # Normalize the path
        normalized = os.path.normpath(filepath)
        absolute = os.path.abspath(normalized)

        # Check for path traversal attempts (.. after normalization)
        # We check the original input for '..' to catch traversal attempts
        if '..' in normalized:
            raise ValueError(f"Path traversal detected: {filepath}")

        return absolute

Severity: CRITICAL

CVSS v3.1: 9.2 (CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:H/VI:N/VA:N/SC:H/SI:N/SA:N

CWE: CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')

Proof of concept (PoC)

Prerequisites:
- Ability to specify a file path can call file operations

Steps to reproduce:
poc.py

from praisonaiagents.tools.file_tools import FileTools

print(FileTools._validate_path('/tmp/../etc/passwd'))
# Returns: /etc/passwd

print(FileTools.read_file('/tmp/../etc/passwd'))
# Returns: content of /etc/passwd

Why this works:

# Current vulnerable code:
normalized = os.path.normpath(filepath)  # Collapses .. HERE
absolute = os.path.abspath(normalized)
if '..' in normalized:  # Check AFTER collapse - ALWAYS FALSE!
    raise ValueError(...)

Impact:

  • Complete bypass of path traversal protection
  • Access to ANY file on the system with path from any starting directory
  • Read sensitive files: /etc/passwd, /etc/shadow, ~/.ssh/id_rsa
  • Write arbitrary files if combined with write operations
  • Affect file operations read_file, write_file, list_files, get_file_info, copy_file, move_file, delete_file, download_file

Additional Notes:

  • Fix: Check for '..' in filepath BEFORE calling normpath(), not after
  • _validate_path uses os.path.normpath and os.path.abspath, which don't resolve symlinks, making it vulnerable to path traversal via symlink if attacker can control the symlink.

Basic information

Type
reviewed
Severity
critical
Advisory on GitHub
Open advisory ↗
Repository advisory
Open repository advisory ↗
Source code
Browse source ↗
Published (advisory)
2026-04-06 23:09:28 UTC
Updated
2026-04-07 22:10:20 UTC
GitHub reviewed
2026-04-06 23:09:28 UTC
NVD published
2026-04-07 17:16:35 UTC

EPSS Score

Score Percentile
0.06% 17.74%

CVSS Scores

Base score Version Severity Vector
9.2 4.0
CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:H/VI:N/VA:N/SC:H/SI:N/SA:N Click to expand
Attack vector (AV:N)
Could be attacked over the internet or any normal routed network.
Attack complexity (AC:L)
Exploitation conditions are straightforward and stable.
Attack requirements (AT:N)
No additional preconditions are required beyond normal reachability.
Privileges required (PR:N)
No privileges are required.
User interaction (UI:N)
No user interaction is required.
Vulnerable system confidentiality impact (VC:H)
High confidentiality impact on the vulnerable system.
Vulnerable system integrity impact (VI:N)
No integrity impact on the vulnerable system.
Vulnerable system availability impact (VA:N)
No availability impact on the vulnerable system.
Subsequent system confidentiality impact (SC:H)
High confidentiality impact on subsequent systems.
Subsequent system integrity impact (SI:N)
No integrity impact on subsequent systems.
Subsequent system availability impact (SA:N)
No availability impact on subsequent systems.

Identifiers

CWEs

CWE id Name
CWE-22 Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')

Credits

  • kritsana-chaikaew (reporter)

Affected packages (1)

Vulnerable version ranges and first patched releases as published by GitHub.

Ecosystem Package Vulnerable range First patched Vulnerable functions
pip PraisonAI <= 1.5.112 1.5.113

References

cvelogic Threat Intelligence