CVE-2026-76832
Path traversal in Agno's PythonTools allows arbitrary file read/write/exec via crafted file_name.
- CVSS 8.5
- CWE-22
- Input Validation and Sanitization
- Remote
Agno's PythonTools in libs/agno/agno/tools/python.py contains a path traversal vulnerability that allows attackers to read, write, or execute arbitrary files by supplying parent-directory traversal sequences in the file_name argument passed to read_file, save_to_file, or run_python_file tool actions. Attackers can inject traversal sequences such as '../../../../../../etc/passwd' through direct tool invocation or via prompt injection embedded in agent-processed content to escape the intended base_dir boundary and achieve arbitrary file read, arbitrary file write, or arbitrary Python code execution within the process user's authority.
- CWE
- CWE-22
- CVSS base score
- 8.5
- Published
- 2026-08-19
- OWASP
- A04 Insecure Design
- Orthogonal defect classification
- Checking
- Code defect classification
- Missing Check
- Category
- Input Validation and Sanitization
- Subcategory
- Path Traversal
- Accessibility scope
- Remote
- Impact
- Arbitrary Code Execution
- Affected component
- Python
Solution
Upgrade Agno to v 1.5.4 or later, which removes the path‑traversal flaw in libs/agno/agno/tools/python.py by sanitizing file_name and enforcing a fixed base_dir.
Vulnerable code sample
import os
BASE_DIR = os.path.abspath("./data")
def read_file(file_name: str) -> str:
# VULNERABLE: joins unvalidated user input allowing path traversal
path = os.path.join(BASE_DIR, file_name)
with open(path, "r", encoding="utf-8") as f:
return f.read()
def save_to_file(file_name: str, content: str) -> None:
# VULNERABLE: writes to unvalidated path
path = os.path.join(BASE_DIR, file_name)
with open(path, "w", encoding="utf-8") as f:
f.write(content)
def run_python_file(file_name: str) -> None:
# VULNERABLE: executes arbitrary file
path = os.path.join(BASE_DIR, file_name)
exec(open(path, "r").read(), {})Patched code sample
import os
BASE_DIR = os.path.abspath("./data")
def _secure_path(file_name: str) -> str:
# FIX: normalize and enforce staying within BASE_DIR
normalized = os.path.normpath(os.path.join(BASE_DIR, file_name))
if not normalized.startswith(BASE_DIR + os.sep):
raise ValueError("Invalid file path")
return normalized
def read_file(file_name: str) -> str:
path = _secure_path(file_name)
with open(path, "r", encoding="utf-8") as f:
return f.read()
def save_to_file(file_name: str, content: str) -> None:
path = _secure_path(file_name)
with open(path, "w", encoding="utf-8") as f:
f.write(content)
def run_python_file(file_name: str) -> None:
path = _secure_path(file_name)
exec(open(path, "r").read(), {})Published fix
Public sources link this CVE to the changes below. The code samples above were generated to illustrate the defect; these links lead to the code the project actually changed.
- feat: add restrict_to_base_dir param to PythonTools and MLXTranscribeTools (#5940) (agno-agi/agno)
libs/agno/agno/tools/file.py,libs/agno/agno/tools/file.py · FileTools.check_escape,libs/agno/agno/tools/file.py · FileTools.__init__,libs/agno/agno/tools/mlx_transcribe.py,libs/agno/agno/tools/mlx_transcribe.py · MLXTranscribeTools.transcribe,libs/agno/agno/tools/mlx_transcribe.py · MLXTranscribeTools.__init__,libs/agno/agno/tools/python.py,libs/agno/agno/tools/python.py · PythonTools.read_file,libs/agno/agno/tools/python.py · PythonTools.run_python_file_return_variable,libs/agno/agno/tools/python.py · PythonTools.save_to_file_and_run,libs/agno/agno/tools/python.py · PythonTools.__init__,libs/agno/agno/tools/toolkit.py
Cite this entry
@misc{vaitp:cve202676832,
title = {{Path traversal in Agno's PythonTools allows arbitrary file read/write/exec via crafted file_name.}},
author = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
year = {2026},
note = {VAITP Python Vulnerability Dataset, entry CVE-2026-76832},
howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2026-76832/}}
}
Introducing the "VAITP dataset": a specialized repository of Python vulnerabilities and patches, meticulously compiled for the use of the security research community. As Python's prominence grows, understanding and addressing potential security vulnerabilities become crucial. Crafted by and for the cybersecurity community, this dataset offers a valuable resource for researchers, analysts, and developers to analyze and mitigate the security risks associated with Python. Through the comprehensive exploration of vulnerabilities and corresponding patches, the VAITP dataset fosters a safer and more resilient Python ecosystem, encouraging collaborative advancements in programming security.
The supreme art of war is to subdue the enemy without fighting.
Sun Tzu – “The Art of War”
:: Shaping the future through research and ingenuity ::
