Описание
PraisonAIAgents: Path Traversal via Unvalidated Glob Pattern in list_files Bypasses Workspace Boundary
Summary
The list_files() tool in FileTools validates the directory parameter against workspace boundaries via _validate_path(), but passes the pattern parameter directly to Path.glob() without any validation. Since Python's Path.glob() supports .. path segments, an attacker can use relative path traversal in the glob pattern to enumerate arbitrary files outside the workspace, obtaining file metadata (existence, name, size, timestamps) for any path on the filesystem.
Details
The _validate_path() method at file_tools.py:25 correctly prevents path traversal by checking for .. segments and verifying the resolved path falls within the current workspace. All file operations (read_file, write_file, copy_file, etc.) route through this validation.
However, list_files() at file_tools.py:114 only validates the directory parameter (line 127), while the pattern parameter is passed directly to Path.glob() on line 130:
Python's Path.glob() resolves .. segments in patterns (tested on Python 3.10–3.13), allowing the glob to traverse outside the validated directory. The matched files on lines 136–144 are never checked against the workspace boundary, so their metadata is returned to the caller.
This tool is exposed to LLM agents via the file_ops tool profile in tools/profiles.py:53, making it accessible to any user who can prompt an agent.
PoC
When triggered via an LLM agent (e.g., through prompt injection in a document the agent processes):
Impact
An attacker who can influence the LLM agent's tool calls (via direct prompting or prompt injection in processed documents) can:
- Enumerate arbitrary files on the filesystem — discover sensitive files, application configuration, SSH keys, credentials files, and database files by their existence and metadata.
- Perform reconnaissance — map the server's directory structure, identify installed software (by checking
/usr/bin/*,/opt/*), discover user accounts (via/home/*), and find deployment paths. - Chain with other vulnerabilities — the discovered paths and file information can inform targeted attacks using other tools or vulnerabilities (e.g., knowing exact file paths for a separate file read vulnerability).
File contents are not directly exposed (the read_file function validates paths correctly), but metadata disclosure (existence, size, modification time) is itself valuable for attack planning.
Recommended Fix
Add validation to reject .. segments in the glob pattern and verify each matched file is within the workspace boundary:
Пакеты
praisonaiagents
< 1.5.128
1.5.128
Связанные уязвимости
PraisonAIAgents is a multi-agent teams system. Prior to 1.5.128, he list_files() tool in FileTools validates the directory parameter against workspace boundaries via _validate_path(), but passes the pattern parameter directly to Path.glob() without any validation. Since Python's Path.glob() supports .. path segments, an attacker can use relative path traversal in the glob pattern to enumerate arbitrary files outside the workspace, obtaining file metadata (existence, name, size, timestamps) for any path on the filesystem. This vulnerability is fixed in 1.5.128.