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

Published Sep 2, 2025
·
Updated

Summary The GET /download/<filename> route uses string path verification via os.path.commonprefix, which allows an authenticated user to download files outside the DWDDIR download directory from "neighboring" directories whose absolute paths begin with the same prefix as DWDDIR (e.g., .../downloadsbak, .../downloads.old). This is a Directory Traversal (escape) leading to a data leak.

Details def issafepath(saferoot, checkpath): saferoot = os.path.realpath(os.path.normpath(saferoot)) checkpath = os.path.realpath(os.path.normpath(checkpath)) return os.path.commonprefix([checkpath, saferoot]) == saferoot commonprefix compares raw strings, not path components. For: saferoot = /home/mobsf/.MobSF/downloads checkpath = /home/mobsf/.MobSF/downloadsbak/test.txt the function returns True, incorrectly treating downloadsbak as inside downloads. Download handler: MobSF/views/home.py @loginrequired def download(request): root = settings.DWDDIR filename = request.path.replace('/download/', '', 1) dwdfile = Path(root) / filename # absolute 'filename' ignores 'root' if '../' in filename or not issafepath(root, dwdfile): return HttpResponseForbidden(...) ext = dwdfile.suffix if ext in settings.ALLOWEDEXTENSIONS and dwdfile.isfile(): return filedownload(dwdfile, ...) If the client supplies an absolute path in filename (starts with / or C:/), Path(root) / filename resolves to that absolute path; the flawed issafepath then accepts any sibling directory whose absolute path shares the same string prefix. The ../ check does not catch this.

Which file types are retrievable: Whatever is allowed by settings.ALLOWEDEXTENSIONS

PoC Prereqs: authenticated user; standard install. Assume: settings.DWDDIR = /home/mobsf/.MobSF/downloads Prepare a sibling directory with the same string prefix and a test file: mkdir -p /home/mobsf/.MobSF/downloadsbak echo "test" > /home/mobsf/.MobSF/downloadsbak/test.txt As an authenticated user, request (note the leading / in the filename and the double/triple slash after /download/ to preserve it): GET /download///home/mobsf/.MobSF/downloadsbak/test.txt HTTP/1.1 Host: <HOST> Cookie: sessionid=<YOURSESSION> Other working sibling directory names (if present): …/downloads.old/... …/downloadsbackup/... …/downloads1/... …/downloads-archive/... …/downloads 2024/... (URL-encoded space: downloads%202024) Impact Any authenticated user can download files (with allowed extensions) from sibling directories whose absolute paths start with the same string prefix as DWDDIR.

Other sources

MobSF is a mobile application security testing tool used. In version 4.4.0, the GET /download/ route uses string path verification via os.path.commonprefix, which allows an authenticated user to download files outside the DWDDIR download directory from "neighboring" directories whose absolute paths begin with the same prefix as DWDDIR (e.g., .../downloadsbak, .../downloads.old). This is a Directory Traversal (escape) leading to a data leak. This issue has been patched in version 4.4.1.

MITRE

Affected Software

3 affected componentsFixes available
MobSF MobSF<4.4.1
pip/mobsf<=4.4.0
4.4.1
Opensecurity Mobile Security Framework=4.4.0

Event History

Sep 2, 2025
CVE Published
via MITRE·12:45 AM
Data Sourced
via MITRE·12:45 AM
DescriptionWeakness
Data Sourced
via NVD·01:15 AM
RemedyDescriptionSeverityWeaknessAffected Software
Advisory Published
via GitHub·05:14 PM
Data Sourced
via GitHub·05:14 PM
DescriptionWeaknessAffected Software

Frequently Asked Questions

1

What is the severity of CVE-2025-58161?

CVE-2025-58161 is considered a moderate severity vulnerability due to improper path verification allowing unauthorized file access.

2

How do I fix CVE-2025-58161?

To fix CVE-2025-58161, update MobSF to version 4.4.1 or later where the vulnerability has been addressed.

3

What is the affected software version for CVE-2025-58161?

CVE-2025-58161 affects MobSF versions prior to 4.4.1.

4

Can CVE-2025-58161 be exploited by unauthenticated users?

No, CVE-2025-58161 requires authentication to exploit, as it affects authenticated users accessing file downloads.

5

What impact does CVE-2025-58161 have on file security?

CVE-2025-58161 allows unauthorized download of files from directories outside of the intended download directory, posing a security risk.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203