Miggo Logo

CVE-2025-58161: MobSF Path Traversal in GET /download/<filename> using absolute filenames

N/A

CVSS Score

Basic Information

EPSS Score
0.49036%
Published
9/2/2025
Updated
9/2/2025
KEV Status
No
Technology
TechnologyPython

Technical Details

CVSS Vector
-
Package NameEcosystemVulnerable VersionsFirst Patched Version
mobsfpip<= 4.4.04.4.1

Vulnerability Intelligence
Miggo AIMiggo AI

Miggo AIRoot 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.download
mobsf/MobSF/views/home.py
The `download` function is the entry point for the vulnerability. It constructs the file path from user input and, prior to the patch, used a weak validation check (`is_safe_path`) that was susceptible to path traversal. The patch modifies the call to `is_safe_path`, passing the raw filename for more robust validation.
mobsf.MobSF.utils.is_safe_path
mobsf/MobSF/utils.py
The original `is_safe_path` function contained the core logic flaw. It relied on `os.path.commonprefix` to validate file paths, which was insufficient and allowed an attacker to access files in sibling directories. The patch introduces a new, more comprehensive check by calling `is_path_traversal` and changes the function signature to accept the raw filename for this check.

WAF Protection Rules

WAF Rule

### Summ*ry T** **T /*ownlo**/<*il*n*m*> rout* us*s strin* p*t* v*ri*i**tion vi* os.p*t*.*ommonpr**ix, w*i** *llows *n *ut**nti**t** us*r to *ownlo** *il*s outsi** t** *W*_*IR *ownlo** *ir**tory *rom "n*i***orin*" *ir**tori*s w*os* **solut* p*t*s ***

Reasoning

T** vuln*r**ility is * *l*ssi* p*t* tr*v*rs*l issu* in t** *il* *ownlo** *un*tion*lity o* Mo*S*. T** root **us* li*s in t** `is_s***_p*t*` *un*tion, w*i** in*orr**tly us** `os.p*t*.*ommonpr**ix` to v*li**t* t**t * r*qu*st** *il* p*t* is wit*in * **si