CVE-2025-58161: MobSF Path Traversal in GET /download/<filename> using absolute filenames
N/A
Basic Information
Technical Details
| Package Name | Ecosystem | Vulnerable Versions | First Patched Version |
|---|---|---|---|
| mobsf | pip | <= 4.4.0 | 4.4.1 |
Vulnerability Intelligence
Miggo AI
Root Cause Analysis
The vulnerability is a classic path traversal issue in the file download functionality of MobSF. The root cause lies in the is_safe_path function, which incorrectly used os.path.commonprefix to validate that a requested file path is within a designated safe directory. This method of validation can be bypassed by providing an absolute path that shares a common prefix with the safe directory, allowing access to sibling directories.
The download function in mobsf/MobSF/views/home.py is the entry point that receives the user-controlled filename. It then calls is_safe_path to perform the security check. The provided patch addresses the vulnerability by significantly strengthening the path validation logic. A new function, is_path_traversal, is introduced in mobsf/MobSF/utils.py to perform more rigorous checks, including looking for absolute paths, URL-encoded traversal sequences, and other malicious patterns. The is_safe_path function is updated to use this new, more secure validation function, and the download function is updated to call the patched is_safe_path with the necessary parameters.
Therefore, both mobsf.MobSF.views.home.download and mobsf.MobSF.utils.is_safe_path are identified as vulnerable. The former is the entry point that handles the malicious input, and the latter contains the flawed validation logic that enables the exploit.
Vulnerable functions
mobsf.MobSF.views.home.downloadmobsf/MobSF/views/home.py
mobsf.MobSF.utils.is_safe_pathmobsf/MobSF/utils.py