CVE-2025-58162: Mobsf MobSF Vulnerable To Arbitrary File Vulnerability

MODERATE
Advisory Identifier: GHSA-9gh8-9r95-3fc3
CVSS 6.5
CWE-22
Published
Advisory Summary

CVE-2025-58162 is a MODERATE (CVSS 6.5) mobsf vulnerable to arbitrary file vulnerability (CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')) affecting Mobsf libraries in the PyPI ecosystem. The issue involves mobsf vulnerable to arbitrary file write (ar-slip) via absolute path in .a extraction. Remediation is available by upgrading affected packages to version 4.4.1.

CVE-2025-58162 at a Glance

CVE Identifier CVE-2025-58162
GHSA Identifier GHSA-9gh8-9r95-3fc3
Severity MODERATE
CVSS v3.1 Base Score 6.5
CWE Classification CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')
Affected Product Mobsf
Package Ecosystem PyPI
Published Date
Last Updated

Security Impact

CVSS: 6.5

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:H/UI:N/S:U/C:N/I:H/A:H).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required High (PR:H)
User Interaction None (UI:N)
Scope Unchanged (S:U)
Confidentiality None (C:N)
Integrity High (I:H)
Availability High (A:H)

How to Fix CVE-2025-58162

To remediate this vulnerability, upgrade all affected Mobsf dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

mobsf fixed: 4.4.1
pip install mobsf>=4.4.1
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

pip show mobsf

How to Check if You Are Affected

To determine whether your Python environment is affected by CVE-2025-58162, inspect your installed packages using pip:

pip show mobsf

Analyze the terminal output to locate any version of Mobsf in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 4.4.1), your application is affected.

Note: The pip show mobsf command checks currently installed packages in your active Python environment.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal'), where the product uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the product does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the restricted directory. In Mobsf, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

### Summary The vulnerability allows any user to overwrite any files available under the account privileges of the running process. ### Details As part of static analysis, iOS MobSF supports loading and parsing statically linked libraries `.a`. When parsing such archives, the code extracts the embedded objects to the file system in the working directory of the analysis. The problem is that the current implementation does not prohibit absolute file names inside `.a`. If an archive item has a name like /abs/path/to/file, the resulting path is constructed as Path(dst) /name; for absolute paths, this leads to a complete substitution of the destination directory: writing occurs directly to the specified absolute directory. the path (outside the working directory). Thus, an authenticated user who uploaded a specially prepared `.a`, can write arbitrary files to any directory writable by the user of the MobSF process (for example, `/tmp`, neighboring directories inside `~/.MobSF`, etc.). The key reason is that checking the "sliding" paths only takes into account the presence of `..` (relative traversal), but does not take into account the absoluteness of the name and does not compare the normalized target path with the root directory of the extraction. ### What exactly is vulnerable: **mobsf/StaticAnalyzer/views/common/shared_func.py** Function for extracting objects from `.a` — ar_extract ``` def ar_extract(checksum, src, dst): """Extract AR archive.""" ... ar = arpy.Archive(src) ar.read_all_headers() for a, val in ar.archived_files.items(): # Handle archive slip attacks filtered = a.decode('utf-8', 'ignore') if is_path_traversal(filtered): msg = f'Zip slip detected. skipped extracting {filtered}' logger.warning(msg) append_scan_status(checksum, msg) continue out = Path(dst) / filtered out.write_bytes(val.read()) ``` - The “slip” check is limited to is_path_traversal(filtered), which looks only for traversal patterns like `..`, `%2e%2e`, `%252e`. - Therefore, if the .a archive contains a member named '/tmp/pwned.txt', MobSF will write it to `/tmp/pwned.txt`, outside the intended working directory. ar_extract is called from: **mobsf/StaticAnalyzer/views/common/a.py** ``` def extract_n_get_files(checksum, src, dst): dst = Path(dst) / 'static_objects' dst.mkdir(parents=True, exist_ok=True) ar_extract(checksum, src, dst.as_posix()) ``` The expectation is that extraction happens only under the static_objects subdirectory, but absolute file names inside the `.a` break this assumption by directing writes outside that directory. ### Attack Scenario 1. The attacker creates a valid AR archive.a, in which the name of one of the members is the absolute path (as an example) /home/mobsf/.MobSF/db.sqlite3. This is done by the standard AR (GNU long filename table) mechanism. 2. It downloads this one via the web interface or the Static library loading API `.a` in MobSF. 3. During the analysis, MobSF extracts the contents: due to the absolute name, the resulting path becomes /home/mobsf/.MobSF/db.sqlite3, and the file is created/overwritten outside the working directory. 4. In our case, the database file was overwritten, which caused MobSF to malfunction. ### PoC 1. Using the script, create a file with the payload. In the example, this is "/home/mobsf/.MobSF/db.sqlite3" <img width="786" height="342" alt="image" src="https://github.com/user-attachments/assets/0b7aee5c-6938-45cc-b668-9ad19f48c2c5" /> 2. Connect to the container and verify that the db.sqlite3 file is a database. The scan has not been performed yet. <img width="2535" height="1507" alt="image" src="https://github.com/user-attachments/assets/0cc92da7-91c0-453f-b1ed-080c9cfaa7f1" /> 3. Upload the file for scanning and then update the page to get a server error. <img width="2559" height="1476" alt="image" src="https://github.com/user-attachments/assets/a5b84ace-b853-46ad-9e2e-afad59ed058a" /> 4. Check the file structure after scanning and see that the file has been overwritten. <img width="797" height="213" alt="image" src="https://github.com/user-attachments/assets/758ba3da-ae25-4c8d-bd8b-932573ca2306" /> 5. There is a database error in the MobSF log. <img width="1724" height="1476" alt="image" src="https://github.com/user-attachments/assets/cd4211b1-2896-45e0-9934-9425b6035f2a" /> ### Impact 1. Arbitrary writing/overwriting of files within the rights of the MobSF process (for example, /tmp, directories with analysis results, logs). 2. Distortion of analysis results (substitution of artifacts) and undermining the integrity of reports. 3. Implementation of a system malfunction (overwriting the db.sqlite3 file). 4. Compromise of the UI (if you have write rights to statics/templates): Stored XSS by overwriting the plug-in.js/template. 5. Potential escalation of risks with lax configuration of containers/rights (for example, writing to system paths inside the container if the process is running with excessive privileges). ### Mitigation Reject absolute paths and normalize before writing. ### **Please, assign all credits to Vasily Leshchenko (Solar AppSec)**

CVE-2025-58162 Affected Mobsf Versions

1 component(s)
Fixed Versions:
4.4.1
Product / Package Ecosystem Affected Versions Fixed Version
mobsf
PyPI
< 4.4.1
4.4.1

References

Frequently Asked Questions

What is CVE-2025-58162?
CVE-2025-58162 is a security vulnerability in Mobsf involving MobSF Vulnerable to Arbitrary File Write (AR-Slip) via Absolute Path in .a Extraction under CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal').
Which Mobsf versions are affected?
Affected versions include releases prior to 4.4.1 across affected packages: mobsf.
What version fixes CVE-2025-58162?
Upgrading to 4.4.1 (or the latest patched release for your respective branch) resolves the vulnerability.
Is mobsf affected?
Yes, mobsf is affected in releases prior to 4.4.1. Upgrade your dependency to 4.4.1 or later.
What is the CVSS score of CVE-2025-58162?
CVE-2025-58162 has a CVSS v3.1 base score of 6.5 (MODERATE) with vector string CVSS:3.1/AV:N/AC:L/PR:H/UI:N/S:U/C:N/I:H/A:H.
What CWE is associated with CVE-2025-58162?
CVE-2025-58162 is classified under CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal') (The product uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the product does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the restricted directory.).
How can I check PyPI dependencies for CVE-2025-58162?
Run the dependency tree command: 'pip show mobsf'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-9gh8-9r95-3fc3",
  "modified" : "2025-09-02T17:12:52Z",
  "published" : "2025-09-02T17:12:52Z",
  "aliases" : [ "CVE-2025-58162" ],
  "summary" : "MobSF Vulnerable to Arbitrary File Write (AR-Slip) via Absolute Path in .a Extraction",
  "details" : "### Summary\nThe vulnerability allows any user to overwrite any files available under the account privileges of the running process.\n\n### Details\nAs part of static analysis, iOS MobSF supports loading and parsing statically linked libraries `.a`. When parsing such archives, the code extracts the embedded objects to the file system in the working directory of the analysis. The problem is that the current implementation does not prohibit absolute file names inside `.a`. If an archive item has a name like /abs/path/to/file, the resulting path is constructed as Path(dst) /name; for absolute paths, this leads to a complete substitution of the destination directory: writing occurs directly to the specified absolute directory. the path (outside the working directory).\n\nThus, an authenticated user who uploaded a specially prepared `.a`, can write arbitrary files to any directory writable by the user of the MobSF process (for example, `/tmp`, neighboring directories inside `~/.MobSF`, etc.).\n\nThe key reason is that checking the \"sliding\" paths only takes into account the presence of `..` (relative traversal), but does not take into account the absoluteness of the name and does not compare the normalized target path with the root directory of the extraction.\n\n### What exactly is vulnerable:\n**mobsf/StaticAnalyzer/views/common/shared_func.py**\nFunction for extracting objects from `.a` — ar_extract\n```\ndef ar_extract(checksum, src, dst):\n    \"\"\"Extract AR archive.\"\"\"\n    ...\n    ar = arpy.Archive(src)\n    ar.read_all_headers()\n    for a, val in ar.archived_files.items():\n        # Handle archive slip attacks\n        filtered = a.decode('utf-8', 'ignore')\n        if is_path_traversal(filtered):\n            msg = f'Zip slip detected. skipped extracting {filtered}'\n            logger.warning(msg)\n            append_scan_status(checksum, msg)\n            continue\n        out = Path(dst) / filtered\n        out.write_bytes(val.read())\n```\n- The “slip” check is limited to is_path_traversal(filtered), which looks only for traversal patterns like `..`, `%2e%2e`, `%252e`.\n- Therefore, if the .a archive contains a member named '/tmp/pwned.txt', MobSF will write it to `/tmp/pwned.txt`, outside the intended working directory.\n\nar_extract is called from:\n**mobsf/StaticAnalyzer/views/common/a.py**\n```\ndef extract_n_get_files(checksum, src, dst):\n    dst = Path(dst) / 'static_objects'\n    dst.mkdir(parents=True, exist_ok=True)\n    ar_extract(checksum, src, dst.as_posix())\n```\nThe expectation is that extraction happens only under the static_objects subdirectory, but absolute file names inside the `.a` break this assumption by directing writes outside that directory.\n\n### Attack Scenario\n1. The attacker creates a valid AR archive.a, in which the name of one of the members is the absolute path (as an example) /home/mobsf/.MobSF/db.sqlite3. This is done by the standard AR (GNU long filename table) mechanism.\n2. It downloads this one via the web interface or the Static library loading API `.a` in MobSF.\n3. During the analysis, MobSF extracts the contents: due to the absolute name, the resulting path becomes /home/mobsf/.MobSF/db.sqlite3, and the file is created/overwritten outside the working directory.\n4. In our case, the database file was overwritten, which caused MobSF to malfunction.\n### PoC\n1. Using the script, create a file with the payload. In the example, this is \"/home/mobsf/.MobSF/db.sqlite3\"\n<img width=\"786\" height=\"342\" alt=\"image\" src=\"https://github.com/user-attachments/assets/0b7aee5c-6938-45cc-b668-9ad19f48c2c5\" />\n\n2. Connect to the container and verify that the db.sqlite3 file is a database. The scan has not been performed yet.\n<img width=\"2535\" height=\"1507\" alt=\"image\" src=\"https://github.com/user-attachments/assets/0cc92da7-91c0-453f-b1ed-080c9cfaa7f1\" />\n\n3. Upload the file for scanning and then update the page to get a server error.\n<img width=\"2559\" height=\"1476\" alt=\"image\" src=\"https://github.com/user-attachments/assets/a5b84ace-b853-46ad-9e2e-afad59ed058a\" />\n\n4. Check the file structure after scanning and see that the file has been overwritten.\n<img width=\"797\" height=\"213\" alt=\"image\" src=\"https://github.com/user-attachments/assets/758ba3da-ae25-4c8d-bd8b-932573ca2306\" />\n\n5. There is a database error in the MobSF log.\n<img width=\"1724\" height=\"1476\" alt=\"image\" src=\"https://github.com/user-attachments/assets/cd4211b1-2896-45e0-9934-9425b6035f2a\" />\n\n### Impact\n1. Arbitrary writing/overwriting of files within the rights of the MobSF process (for example, /tmp, directories with analysis results, logs).\n2. Distortion of analysis results (substitution of artifacts) and undermining the integrity of reports.\n3. Implementation of a system malfunction (overwriting the db.sqlite3 file).\n4. Compromise of the UI (if you have write rights to statics/templates): Stored XSS by overwriting the plug-in.js/template.\n5. Potential escalation of risks with lax configuration of containers/rights (for example, writing to system paths inside the container if the process is running with excessive privileges).\n\n\n### Mitigation\nReject absolute paths and normalize before writing. \n\n\n\n### **Please, assign all credits to Vasily Leshchenko (Solar AppSec)**",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:H/UI:N/S:U/C:N/I:H/A:H"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "PyPI",
      "name" : "mobsf"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "4.4.1"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 4.4.0"
    }
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/MobSF/Mobile-Security-Framework-MobSF/security/advisories/GHSA-9gh8-9r95-3fc3"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/MobSF/Mobile-Security-Framework-MobSF/commit/7f3bc086c028c1b50889cab8a15f7b59b7abdaf9"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/MobSF/Mobile-Security-Framework-MobSF"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/MobSF/Mobile-Security-Framework-MobSF/releases/tag/v4.4.1"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-22" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2025-09-02T17:12:52Z",
    "nvd_published_at" : null
  }
}