CVE-2026-51851
Directory traversal via unsanitized file paths in FileBrowser.save_text_file.
- CWE-22 (inferred)
- Input Validation and Sanitization
- Remote
modelscope agent-zero 1.7, 1.8, 1.9, and 1.10 is vulnerable to Directory Traversal in python/helpers/file_browser.py:FileBrowser.save_text_file. The save_text_file method accepts user-controlled file paths without normalization or validation, allowing path traversal attacks.
- CWE
- CWE-22 (inferred)
- Published
- 2026-10-29
- 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
- Information Disclosure
- Affected component
- Python
- Fixed by upgrading
- Yes
Solution
Upgrade to modelscope‑agent‑zero ≥ 1.11, where the Directory Traversal issue in FileBrowser.save_text_file is fixed.
Vulnerable code sample
import os
class FileBrowser:
def __init__(self, root_dir: str):
self.root_dir = root_dir
def save_text_file(self, rel_path: str, content: str) -> None:
# VULNERABLE: writes to user‑controlled path without validation
full_path = os.path.join(self.root_dir, rel_path)
with open(full_path, "w", encoding="utf-8") as f:
f.write(content)Patched code sample
import os
class FileBrowser:
def __init__(self, root_dir: str):
self.root_dir = os.path.abspath(root_dir)
def save_text_file(self, rel_path: str, content: str) -> None:
# FIX: normalize and restrict to root_dir to prevent traversal
normalized = os.path.normpath(rel_path)
full_path = os.path.abspath(os.path.join(self.root_dir, normalized))
if not full_path.startswith(self.root_dir + os.sep):
raise ValueError("Invalid file path")
with open(full_path, "w", encoding="utf-8") as f:
f.write(content)Cite this entry
@misc{vaitp:cve202651851,
title = {{Directory traversal via unsanitized file paths in FileBrowser.save_text_file.}},
author = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
year = {2026},
note = {VAITP Python Vulnerability Dataset, entry CVE-2026-51851},
howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2026-51851/}}
}
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 ::
