Potato Server, Path Traversal via String Prefix Check, CVE(unknown) (Medium)

Listen to this Post

The vulnerability exists in the `validate_path_security` function within potato/server_utils/config_module.py. This function attempts to restrict file access to a base directory (e.g., project directory) by using Python’s string `startswith()` method on resolved real paths. Specifically, lines 370–373 compute `real_path = os.path.realpath(normalized_path)` and real_base = os.path.realpath(base_dir), then check if not real_path.startswith(real_base): raise ConfigSecurityError. Similarly, lines 384–389 perform the same check using project_dir. Because `startswith()` operates on string prefixes, it fails to enforce directory boundaries when an attacker supplies a path that shares the same string prefix as the allowed base directory but lies outside it. For example, if the base directory is /tmp/potato_proj_demo, a malicious path like `/tmp/potato_proj_demo_evil/file.txt` will pass the check, as its string starts with the base string. This bypasses the intended security boundary. Affected call sites include `validate_file_paths` for `task_dir` (line 2113) and `data_files` (line 2151), as well as `validate_training_config` for `training.data_file` (line 2286). The proof-of-concept demonstrates that `validate_path_security(‘/tmp/potato_proj_demo_evil/file.txt’, base, base)` does not raise an exception, whereas a completely unrelated path like `/tmp/other_demo/file.txt` is correctly rejected. This allows unauthorized sibling-prefix file access outside the intended project directory, impacting read paths (data_files, training.data_file, base_css, header_logo) and potentially output placement.

dailycve form:

Platform: Potato Server
Version: Affected versions unspecified
Vulnerability: Path prefix bypass
Severity: Medium
date: 2026-05-08

Prediction: Patch expected 30days

Analytics under heading What Undercode Say:

Vulnerable path check demonstration
python3 -c "
from potato.server_utils.config_module import validate_path_security
base = '/tmp/potato_proj_demo'
evil = '/tmp/potato_proj_demo_evil/file.txt'
print(validate_path_security(evil, base, base)) No exception, path accepted
"
Check realpath equivalence
realpath /tmp/potato_proj_demo
realpath /tmp/potato_proj_demo_evil
List files that could be accessed
find /tmp -path '/tmp/potato_proj_demo' -type f

Exploit:

Craft a path that shares the allowed directory’s string prefix but adds extra characters, e.g., /tmp/potato_proj_demo_evil/../../etc/passwd. Supply this as task_dir, data_files, or `training.data_file` in configuration. The `startswith()` check passes, allowing read or write access outside the intended project boundary.

Protection from this CVE

Replace `startswith()` with `os.path.commonpath()` or `os.path.relpath()` to verify that the real path is within the base directory. Example fix:

if os.path.commonpath([real_path, real_base]) != real_base:
raise ConfigSecurityError(...)

Alternatively, use `os.path.realpath` and ensure that the relative path does not contain `..` after checking with os.path.relpath.

Impact

Unauthorized file read (e.g., configuration files, source code, system files) outside the project directory. Potential write access if the vulnerable function is used for output path validation. Allows sibling-directory traversal and information disclosure.

🎯Let’s Practice Exploiting & Learn Patching For Free:

Sources:

Reported By: github.com
Extra Source Hub:
Undercode

🔐JOIN OUR CYBER WORLD [ CVE News • HackMonitor • UndercodeNews ]

💬 Whatsapp | 💬 Telegram

📢 Follow DailyCVE & Stay Tuned:

𝕏 formerly Twitter 🐦 | @ Threads | 🔗 Linkedin Featured Image

Scroll to Top