{"id":"CVE-2025-58161","aliases":["CVE-2025-58161","GHSA-ccc3-fvfx-mw3v","PYSEC-2026-1672"],"related":[],"kind":"vulnerability","state":"published","title":"MobSF Path Traversal in GET /download/<filename> using absolute filenames","summary":"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 DWD_DIR download directory from \"neighboring\" directories whose absolute paths begin with the same prefix as DWD_DIR (e.g., .../downloads_bak, .../downloads.old). This is a Directory Traversal (escape) leading to a data leak. This issue has been patched in version 4.4.1.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"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 DWD_DIR download directory from \"neighboring\" directories whose absolute paths begin with the same prefix as DWD_DIR (e.g., .../downloads_bak, .../downloads.old). This is a Directory Traversal (escape) leading to a data leak. This issue has been patched in version 4.4.1.","source":"cvelist"},{"lang":"en","text":"### Summary\nThe GET /download/<filename> route uses string path verification via os.path.commonprefix, which allows an authenticated user to download files outside the DWD_DIR download directory from \"neighboring\" directories whose absolute paths begin with the same prefix as DWD_DIR (e.g., .../downloads_bak, .../downloads.old). This is a Directory Traversal (escape) leading to a data leak.\n\n### Details\n```\ndef is_safe_path(safe_root, check_path):\n    safe_root  = os.path.realpath(os.path.normpath(safe_root))\n    check_path = os.path.realpath(os.path.normpath(check_path))\n    return os.path.commonprefix([check_path, safe_root]) == safe_root\n```\ncommonprefix compares raw strings, not path components. For:\n```\nsafe_root  = /home/mobsf/.MobSF/downloads\ncheck_path = /home/mobsf/.MobSF/downloads_bak/test.txt\n```\nthe function returns True, incorrectly treating downloads_bak as inside downloads.\nDownload handler:\n```\n# MobSF/views/home.py\n@login_required\ndef download(request):\n    root = settings.DWD_DIR\n    filename = request.path.replace('/download/', '', 1)\n    dwd_file = Path(root) / filename  # absolute 'filename' ignores 'root'\n    if '../' in filename or not is_safe_path(root, dwd_file):\n        return HttpResponseForbidden(...)\n    ext = dwd_file.suffix\n    if ext in settings.ALLOWED_EXTENSIONS and dwd_file.is_file():\n        return file_download(dwd_file, ...)\n```\nIf the client supplies an absolute path in filename (starts with / or C:/), Path(root) / filename resolves to that absolute path; the flawed is_safe_path then accepts any sibling directory whose absolute path shares the same string prefix. The ../ check does not catch this.\n\nWhich file types are retrievable: Whatever is allowed by settings.ALLOWED_EXTENSIONS\n\n### PoC\nPrereqs: authenticated user; standard install.\nAssume:\n```\nsettings.DWD_DIR = /home/mobsf/.MobSF/downloads\n```\nPrepare a sibling directory with the same string prefix and a test file:\n```\nmkdir -p /home/mobsf/.MobSF/downloads_bak\necho \"test\" > /home/mobsf/.MobSF/downloads_bak/test.txt\n```\nAs an authenticated user, request (note the leading / in the filename and the double/triple slash after /download/ to preserve it):\n```\nGET /download///home/mobsf/.MobSF/downloads_bak/test.txt HTTP/1.1\nHost: <HOST>\nCookie: sessionid=<YOUR_SESSION>\n```\nOther working sibling directory names (if present):\n```\n…/downloads.old/...\n…/downloads_backup/...\n…/downloads1/...\n…/downloads-archive/...\n…/downloads 2024/... (URL-encoded space: downloads%202024)\n```\n### Impact\nAny authenticated user can download files (with allowed extensions) from sibling directories whose absolute paths start with the same string prefix as DWD_DIR.","format":"markdown","source":"ghsa"},{"lang":"es","text":"MobSF es una herramienta utilizada para pruebas de seguridad de aplicaciones móviles. En la versión 4.4.0, la ruta GET /download/ utiliza la verificación de rutas de cadena a través de os.path.commonprefix, lo que permite a un usuario autenticado descargar archivos fuera del directorio de descarga DWD_DIR desde directorios 'vecinos' cuyas rutas absolutas comienzan con el mismo prefijo que DWD_DIR (p. ej., .../downloads_bak, .../downloads.old). Esto es un salto de directorio (escape) que conduce a una fuga de datos. Este problema ha sido parcheado en la versión 4.4.1.","source":"nvd"}],"published":"2025-09-02T00:45:49.996Z","modified":"2026-10-19T17:10:00.173Z","severity":{"scorer":"GitHub_M","scheme":"CVSS:4.0","vector":"CVSS:4.0/AV:N/AC:L/AT:N/PR:L/UI:N/VC:L/VI:N/VA:N/SC:N/SI:N/SA:N/E:U","score":1.3,"rating":"LOW"},"severities":[{"scorer":"GitHub_M","scheme":"CVSS:4.0","vector":"CVSS:4.0/AV:N/AC:L/AT:N/PR:L/UI:N/VC:L/VI:N/VA:N/SC:N/SI:N/SA:N/E:U","score":1.3,"rating":"LOW"},{"scorer":"GitHub","scheme":"CVSS:4.0","vector":"CVSS:4.0/AV:N/AC:L/AT:N/PR:L/UI:N/VC:L/VI:N/VA:N/SC:N/SI:N/SA:N/E:U","rating":"LOW"},{"scorer":"NVD","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:L/I:N/A:N","score":4.3,"rating":"MEDIUM"},{"scorer":"PyPA Advisory Database","scheme":"CVSS:4.0","vector":"CVSS:4.0/AV:N/AC:L/AT:N/PR:L/UI:N/VC:L/VI:N/VA:N/SC:N/SI:N/SA:N/E:U"}],"cwes":["CWE-22"],"affected":[{"ranges":[{"version":"= 4.4.0","status":"affected"}],"vendor":"MobSF","product":"Mobile-Security-Framework-MobSF","source":"cvelist"},{"ranges":[{"type":"ecosystem","introduced":"0","status":"affected","fixed":"4.4.1"}],"ecosystem":"PyPI","package":"mobsf","purl":"pkg:pypi/mobsf","source":"ghsa"},{"ranges":[{"status":"affected","version":"4.4.0"}],"vendor":"opensecurity","product":"mobile_security_framework","cpe":"cpe:2.3:a:opensecurity:mobile_security_framework:4.4.0:*:*:*:*:*:*:*","source":"nvd"},{"ranges":[{"type":"ecosystem","introduced":"0","status":"affected","fixed":"4.4.1"}],"ecosystem":"PyPI","package":"mobsf","purl":"pkg:pypi/mobsf","source":"pysec"}],"references":[{"url":"https://github.com/MobSF/Mobile-Security-Framework-MobSF/security/advisories/GHSA-ccc3-fvfx-mw3v","tags":["exploit","third-party-advisory","web","x-refsource-confirm"],"sources":["cvelist","ghsa","nvd","pysec"]},{"url":"https://github.com/MobSF/Mobile-Security-Framework-MobSF/commit/7f3bc086c028c1b50889cab8a15f7b59b7abdaf9","tags":["patch","web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd","pysec"]},{"url":"https://github.com/MobSF/Mobile-Security-Framework-MobSF/releases/tag/v4.4.1","tags":["release-notes","web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd","pysec"]},{"url":"https://github.com/MobSF/Mobile-Security-Framework-MobSF","tags":["package"],"sources":["ghsa","pysec"]},{"url":"https://pypi.org/project/mobsf","tags":["package"],"sources":["pysec"]},{"url":"https://github.com/advisories/GHSA-ccc3-fvfx-mw3v","tags":["advisory"],"sources":["pysec"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2025-58161","tags":["advisory"],"sources":["pysec"]}],"credits":[],"assigner":"GitHub_M","ssvc":{"scorer":"CISA-ADP","exploitation":"poc","automatable":"no","technicalImpact":"partial","date":"2025-09-02T19:21:44.960Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2025-58161","url":"https://www.cve.org/CVERecord?id=CVE-2025-58161","licence":"CVE Terms of Use","modified":"2025-09-02T19:25:49.966Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-ccc3-fvfx-mw3v","url":"https://github.com/advisories/GHSA-ccc3-fvfx-mw3v","licence":"CC-BY-4.0","modified":"2026-07-07T17:57:01.315Z"},{"source":"nvd","name":"NVD","id":"CVE-2025-58161","url":"https://nvd.nist.gov/vuln/detail/CVE-2025-58161","licence":"Public domain","modified":"2026-10-19T17:10:00.173Z"},{"source":"pysec","name":"PyPA Advisory Database","id":"PYSEC-2026-1672","url":"https://osv.dev/vulnerability/PYSEC-2026-1672","licence":"CC-BY-4.0","modified":"2026-07-07T17:47:05.862Z"}],"updatedAt":"2026-11-25T22:59:03.981Z","epss":{"score":0.00824,"percentile":0.58482,"date":"2026-12-01T12:00:22.000Z"}}