Skip to content

Special character in Filename inside Payload-Folder breaks IPA analysis #2285

@esoteric-programmer

Description

@esoteric-programmer

ENVIRONMENT

OS and Version: macOS-14.1.1-arm64-arm-64bit (23B81)
Python Version: Python 3.11.6 (main, Oct  2 2023, 13:45:54) [Clang 15.0.0 (clang-1500.0.40.1)] on darwin
MobSF Version: v3.7.9 Beta (4685d8e73d5c23f8418767a24f3015160adbc6db)

EXPLANATION OF THE ISSUE

When analyzing an IPA file that contains a special character "β" and a whitespace in the Payload/[APPNAME].app filename, analysis fails. Running MobSF under MacOS (see above) is affected as well as the Docker image opensecurity/mobile-security-framework-mobsf:latest

STEPS TO REPRODUCE THE ISSUE

1. Create IPA file with special character in application filename
2. Analyze IPA with MobSF

LOG FILE

Username and application name partially censored, [...] inserted insetad; brpken encoding of special character "β" in the app name not censored.

[INFO] 14/Nov/2023 11:29:34 - Mobile Security Framework v3.7.9 Beta
[INFO] 14/Nov/2023 11:29:34 - OS: Darwin
[INFO] 14/Nov/2023 11:29:34 - Platform: macOS-14.1.1-arm64-arm-64bit
[INFO] 14/Nov/2023 11:29:34 - Dist: darwin 23.1.0
[INFO] 14/Nov/2023 11:29:34 - MobSF Basic Environment Check
[WARNING] 14/Nov/2023 11:29:34 - Dynamic Analysis related functions will not work.
Make sure a Genymotion Android VM/Android Studio Emulator is running before performing Dynamic Analysis.
[INFO] 14/Nov/2023 11:29:34 - Checking for Update.
[INFO] 14/Nov/2023 11:29:34 - No updates available.
[INFO] 14/Nov/2023 11:30:17 - MIME Type: application/octet-stream FILE: E[...]7.ipa
[INFO] 14/Nov/2023 11:30:17 - Performing Static Analysis of iOS IPA
[INFO] 14/Nov/2023 11:30:17 - iOS Binary (IPA) Analysis Started
[INFO] 14/Nov/2023 11:30:17 - Generating Hashes
[INFO] 14/Nov/2023 11:30:17 - Extracting IPA
[INFO] 14/Nov/2023 11:30:17 - Unzipping
[INFO] 14/Nov/2023 11:30:18 - Get Files, BIN Plist -> XML, and Normalize
[WARNING] 14/Nov/2023 11:30:18 - Failed to convert plist
[INFO] 14/Nov/2023 11:30:18 - iOS Info.plist Analysis Started
[INFO] 14/Nov/2023 11:30:18 - Finding Info.plist in iOS Binary
[INFO] 14/Nov/2023 11:30:18 - Checking Permissions
[INFO] 14/Nov/2023 11:30:18 - Checking for Insecure Connections
[INFO] 14/Nov/2023 11:30:18 - Fetching Details from App Store: io.[...]
[WARNING] 14/Nov/2023 11:30:19 - Unable to get app details.
[INFO] 14/Nov/2023 11:30:19 - Starting Binary Analysis
[INFO] 14/Nov/2023 11:30:19 - Running MachO Analysis on: ╬▓ E[...].app
[ERROR] 14/Nov/2023 11:30:19 - Running MachO Analysis
Traceback (most recent call last):
  File "/Users/[...]/Mobile-Security-Framework-MobSF/mobsf/StaticAnalyzer/views/ios/binary_analysis.py", line 61, in ipa_macho_analysis
    libs = cs.get_libraries()
           ^^^^^^^^^^^^^^^^^^
  File "/Users/[...]/Mobile-Security-Framework-MobSF/mobsf/StaticAnalyzer/views/common/binary/macho.py", line 274, in get_libraries
    for i in self.macho.libraries:
             ^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'libraries'
[INFO] 14/Nov/2023 11:30:19 - Getting Binary Information
[ERROR] 14/Nov/2023 11:30:19 - IPA Binary Analysis
Traceback (most recent call last):
  File "/Users/[...]/Mobile-Security-Framework-MobSF/mobsf/StaticAnalyzer/views/ios/binary_analysis.py", line 108, in binary_analysis
    bin_info = get_bin_info(bin_path)
               ^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/[...]/Mobile-Security-Framework-MobSF/mobsf/StaticAnalyzer/views/ios/binary_analysis.py", line 39, in get_bin_info
    m = MachO(bin_file.as_posix())
        ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/[...]/Library/Caches/pypoetry/virtualenvs/mobsf-u6ypDL8M-py3.11/lib/python3.11/site-packages/macholib/MachO.py", line 120, in __init__
    with open(filename, "rb") as fp:
         ^^^^^^^^^^^^^^^^^^^^
IsADirectoryError: [Errno 21] Is a directory: '/Users/[...]/.MobSF/uploads/07d37e4dd405eba1dd2d463f1ecc3e5f/Payload/╬▓ E[...].app'
[INFO] 14/Nov/2023 11:30:19 - Library Binary Analysis Started
[INFO] 14/Nov/2023 11:30:19 - Framework Binary Analysis Started
[INFO] 14/Nov/2023 11:30:19 - Analyzing Frameworks/PPRiskMagnes.framework/PPRiskMagnes
[INFO] 14/Nov/2023 11:30:21 - Analyzing Frameworks/CoWorkingNetwork.framework/CoWorkingNetwork
[INFO] 14/Nov/2023 11:30:22 - Fetching icon path
[WARNING] 14/Nov/2023 11:30:22 - Could not find app binary directory
[INFO] 14/Nov/2023 11:30:22 - Starting IPA URL and Email Extraction
[INFO] 14/Nov/2023 11:30:24 - Performing Malware Check on extracted Domains
[INFO] 14/Nov/2023 11:30:25 - Maltrail Database is outdated!
[INFO] 14/Nov/2023 11:30:25 - Updating Maltrail Database
[INFO] 14/Nov/2023 11:30:26 - Finished URL and Email Extraction
[INFO] 14/Nov/2023 11:30:27 - Trackers Database is up-to-date
[INFO] 14/Nov/2023 11:30:27 - Detecting Trackers from Domains
[INFO] 14/Nov/2023 11:30:27 - Detecting Firebase URL(s)
[INFO] 14/Nov/2023 11:30:27 - Connecting to DB
[INFO] 14/Nov/2023 11:30:27 - Saving to Database
[DEBUG] 14/Nov/2023 11:30:27 - Exception while resolving variable 'arch' in template 'static_analysis/ios_binary_analysis.html'.
Traceback (most recent call last):
  File "/Users/[...]/Library/Caches/pypoetry/virtualenvs/mobsf-u6ypDL8M-py3.11/lib/python3.11/site-packages/django/template/base.py", line 880, in _resolve_lookup
    current = current[bit]
              ~~~~~~~^^^^^
KeyError: 'arch'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/[...]/Library/Caches/pypoetry/virtualenvs/mobsf-u6ypDL8M-py3.11/lib/python3.11/site-packages/django/template/base.py", line 890, in _resolve_lookup
    current = getattr(current, bit)
              ^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'dict' object has no attribute 'arch'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/[...]/Library/Caches/pypoetry/virtualenvs/mobsf-u6ypDL8M-py3.11/lib/python3.11/site-packages/django/template/base.py", line 896, in _resolve_lookup
    current = current[int(bit)]
                      ^^^^^^^^
ValueError: invalid literal for int() with base 10: 'arch'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/[...]/Library/Caches/pypoetry/virtualenvs/mobsf-u6ypDL8M-py3.11/lib/python3.11/site-packages/django/template/base.py", line 903, in _resolve_lookup
    raise VariableDoesNotExist(
django.template.base.VariableDoesNotExist: Failed lookup for key [arch] in {}
[DEBUG] 14/Nov/2023 11:30:27 - Exception while resolving variable 'subarch' in template 'static_analysis/ios_binary_analysis.html'.
Traceback (most recent call last):
  File "/Users/[...]/Library/Caches/pypoetry/virtualenvs/mobsf-u6ypDL8M-py3.11/lib/python3.11/site-packages/django/template/base.py", line 880, in _resolve_lookup
    current = current[bit]
              ~~~~~~~^^^^^
KeyError: 'subarch'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/[...]/Library/Caches/pypoetry/virtualenvs/mobsf-u6ypDL8M-py3.11/lib/python3.11/site-packages/django/template/base.py", line 890, in _resolve_lookup
    current = getattr(current, bit)
              ^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'dict' object has no attribute 'subarch'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/[...]/Library/Caches/pypoetry/virtualenvs/mobsf-u6ypDL8M-py3.11/lib/python3.11/site-packages/django/template/base.py", line 896, in _resolve_lookup
    current = current[int(bit)]
                      ^^^^^^^^
ValueError: invalid literal for int() with base 10: 'subarch'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/[...]/Library/Caches/pypoetry/virtualenvs/mobsf-u6ypDL8M-py3.11/lib/python3.11/site-packages/django/template/base.py", line 903, in _resolve_lookup
    raise VariableDoesNotExist(
django.template.base.VariableDoesNotExist: Failed lookup for key [subarch] in {}
[DEBUG] 14/Nov/2023 11:30:27 - Exception while resolving variable 'bit' in template 'static_analysis/ios_binary_analysis.html'.
Traceback (most recent call last):
  File "/Users/[...]/Library/Caches/pypoetry/virtualenvs/mobsf-u6ypDL8M-py3.11/lib/python3.11/site-packages/django/template/base.py", line 880, in _resolve_lookup
    current = current[bit]
              ~~~~~~~^^^^^
KeyError: 'bit'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/[...]/Library/Caches/pypoetry/virtualenvs/mobsf-u6ypDL8M-py3.11/lib/python3.11/site-packages/django/template/base.py", line 890, in _resolve_lookup
    current = getattr(current, bit)
              ^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'dict' object has no attribute 'bit'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/[...]/Library/Caches/pypoetry/virtualenvs/mobsf-u6ypDL8M-py3.11/lib/python3.11/site-packages/django/template/base.py", line 896, in _resolve_lookup
    current = current[int(bit)]
                      ^^^^^^^^
ValueError: invalid literal for int() with base 10: 'bit'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/[...]/Library/Caches/pypoetry/virtualenvs/mobsf-u6ypDL8M-py3.11/lib/python3.11/site-packages/django/template/base.py", line 903, in _resolve_lookup
    raise VariableDoesNotExist(
django.template.base.VariableDoesNotExist: Failed lookup for key [bit] in {}
[DEBUG] 14/Nov/2023 11:30:27 - Exception while resolving variable 'endian' in template 'static_analysis/ios_binary_analysis.html'.
Traceback (most recent call last):
  File "/Users/[...]/Library/Caches/pypoetry/virtualenvs/mobsf-u6ypDL8M-py3.11/lib/python3.11/site-packages/django/template/base.py", line 880, in _resolve_lookup
    current = current[bit]
              ~~~~~~~^^^^^
KeyError: 'endian'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/[...]/Library/Caches/pypoetry/virtualenvs/mobsf-u6ypDL8M-py3.11/lib/python3.11/site-packages/django/template/base.py", line 890, in _resolve_lookup
    current = getattr(current, bit)
              ^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'dict' object has no attribute 'endian'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/[...]/Library/Caches/pypoetry/virtualenvs/mobsf-u6ypDL8M-py3.11/lib/python3.11/site-packages/django/template/base.py", line 896, in _resolve_lookup
    current = current[int(bit)]
                      ^^^^^^^^
ValueError: invalid literal for int() with base 10: 'endian'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/[...]/Library/Caches/pypoetry/virtualenvs/mobsf-u6ypDL8M-py3.11/lib/python3.11/site-packages/django/template/base.py", line 903, in _resolve_lookup
    raise VariableDoesNotExist(
django.template.base.VariableDoesNotExist: Failed lookup for key [endian] in {}
[DEBUG] 14/Nov/2023 11:30:27 - Exception while resolving variable 'arch' in template 'static_analysis/ios_binary_analysis.html'.
Traceback (most recent call last):
  File "/Users/[...]/Library/Caches/pypoetry/virtualenvs/mobsf-u6ypDL8M-py3.11/lib/python3.11/site-packages/django/template/base.py", line 880, in _resolve_lookup
    current = current[bit]
              ~~~~~~~^^^^^
KeyError: 'arch'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/[...]/Library/Caches/pypoetry/virtualenvs/mobsf-u6ypDL8M-py3.11/lib/python3.11/site-packages/django/template/base.py", line 890, in _resolve_lookup
    current = getattr(current, bit)
              ^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'dict' object has no attribute 'arch'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/[...]/Library/Caches/pypoetry/virtualenvs/mobsf-u6ypDL8M-py3.11/lib/python3.11/site-packages/django/template/base.py", line 896, in _resolve_lookup
    current = current[int(bit)]
                      ^^^^^^^^
ValueError: invalid literal for int() with base 10: 'arch'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/[...]/Library/Caches/pypoetry/virtualenvs/mobsf-u6ypDL8M-py3.11/lib/python3.11/site-packages/django/template/base.py", line 903, in _resolve_lookup
    raise VariableDoesNotExist(
django.template.base.VariableDoesNotExist: Failed lookup for key [arch] in {}
[INFO] 14/Nov/2023 11:30:27 - Analysis is already Done. Fetching data from the DB...
[DEBUG] 14/Nov/2023 11:30:27 - Exception while resolving variable 'arch' in template 'static_analysis/ios_binary_analysis.html'.
Traceback (most recent call last):
  File "/Users/[...]/Library/Caches/pypoetry/virtualenvs/mobsf-u6ypDL8M-py3.11/lib/python3.11/site-packages/django/template/base.py", line 880, in _resolve_lookup
    current = current[bit]
              ~~~~~~~^^^^^
KeyError: 'arch'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/[...]/Library/Caches/pypoetry/virtualenvs/mobsf-u6ypDL8M-py3.11/lib/python3.11/site-packages/django/template/base.py", line 890, in _resolve_lookup
    current = getattr(current, bit)
              ^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'dict' object has no attribute 'arch'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/[...]/Library/Caches/pypoetry/virtualenvs/mobsf-u6ypDL8M-py3.11/lib/python3.11/site-packages/django/template/base.py", line 896, in _resolve_lookup
    current = current[int(bit)]
                      ^^^^^^^^
ValueError: invalid literal for int() with base 10: 'arch'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/[...]/Library/Caches/pypoetry/virtualenvs/mobsf-u6ypDL8M-py3.11/lib/python3.11/site-packages/django/template/base.py", line 903, in _resolve_lookup
    raise VariableDoesNotExist(
django.template.base.VariableDoesNotExist: Failed lookup for key [arch] in {}
[DEBUG] 14/Nov/2023 11:30:27 - Exception while resolving variable 'subarch' in template 'static_analysis/ios_binary_analysis.html'.
Traceback (most recent call last):
  File "/Users/[...]/Library/Caches/pypoetry/virtualenvs/mobsf-u6ypDL8M-py3.11/lib/python3.11/site-packages/django/template/base.py", line 880, in _resolve_lookup
    current = current[bit]
              ~~~~~~~^^^^^
KeyError: 'subarch'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/[...]/Library/Caches/pypoetry/virtualenvs/mobsf-u6ypDL8M-py3.11/lib/python3.11/site-packages/django/template/base.py", line 890, in _resolve_lookup
    current = getattr(current, bit)
              ^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'dict' object has no attribute 'subarch'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/[...]/Library/Caches/pypoetry/virtualenvs/mobsf-u6ypDL8M-py3.11/lib/python3.11/site-packages/django/template/base.py", line 896, in _resolve_lookup
    current = current[int(bit)]
                      ^^^^^^^^
ValueError: invalid literal for int() with base 10: 'subarch'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/[...]/Library/Caches/pypoetry/virtualenvs/mobsf-u6ypDL8M-py3.11/lib/python3.11/site-packages/django/template/base.py", line 903, in _resolve_lookup
    raise VariableDoesNotExist(
django.template.base.VariableDoesNotExist: Failed lookup for key [subarch] in {}
[DEBUG] 14/Nov/2023 11:30:27 - Exception while resolving variable 'bit' in template 'static_analysis/ios_binary_analysis.html'.
Traceback (most recent call last):
  File "/Users/[...]/Library/Caches/pypoetry/virtualenvs/mobsf-u6ypDL8M-py3.11/lib/python3.11/site-packages/django/template/base.py", line 880, in _resolve_lookup
    current = current[bit]
              ~~~~~~~^^^^^
KeyError: 'bit'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/[...]/Library/Caches/pypoetry/virtualenvs/mobsf-u6ypDL8M-py3.11/lib/python3.11/site-packages/django/template/base.py", line 890, in _resolve_lookup
    current = getattr(current, bit)
              ^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'dict' object has no attribute 'bit'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/[...]/Library/Caches/pypoetry/virtualenvs/mobsf-u6ypDL8M-py3.11/lib/python3.11/site-packages/django/template/base.py", line 896, in _resolve_lookup
    current = current[int(bit)]
                      ^^^^^^^^
ValueError: invalid literal for int() with base 10: 'bit'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/[...]/Library/Caches/pypoetry/virtualenvs/mobsf-u6ypDL8M-py3.11/lib/python3.11/site-packages/django/template/base.py", line 903, in _resolve_lookup
    raise VariableDoesNotExist(
django.template.base.VariableDoesNotExist: Failed lookup for key [bit] in {}
[DEBUG] 14/Nov/2023 11:30:27 - Exception while resolving variable 'endian' in template 'static_analysis/ios_binary_analysis.html'.
Traceback (most recent call last):
  File "/Users/[...]/Library/Caches/pypoetry/virtualenvs/mobsf-u6ypDL8M-py3.11/lib/python3.11/site-packages/django/template/base.py", line 880, in _resolve_lookup
    current = current[bit]
              ~~~~~~~^^^^^
KeyError: 'endian'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/[...]/Library/Caches/pypoetry/virtualenvs/mobsf-u6ypDL8M-py3.11/lib/python3.11/site-packages/django/template/base.py", line 890, in _resolve_lookup
    current = getattr(current, bit)
              ^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'dict' object has no attribute 'endian'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/[...]/Library/Caches/pypoetry/virtualenvs/mobsf-u6ypDL8M-py3.11/lib/python3.11/site-packages/django/template/base.py", line 896, in _resolve_lookup
    current = current[int(bit)]
                      ^^^^^^^^
ValueError: invalid literal for int() with base 10: 'endian'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/[...]/Library/Caches/pypoetry/virtualenvs/mobsf-u6ypDL8M-py3.11/lib/python3.11/site-packages/django/template/base.py", line 903, in _resolve_lookup
    raise VariableDoesNotExist(
django.template.base.VariableDoesNotExist: Failed lookup for key [endian] in {}
[DEBUG] 14/Nov/2023 11:30:27 - Exception while resolving variable 'arch' in template 'static_analysis/ios_binary_analysis.html'.
Traceback (most recent call last):
  File "/Users/[...]/Library/Caches/pypoetry/virtualenvs/mobsf-u6ypDL8M-py3.11/lib/python3.11/site-packages/django/template/base.py", line 880, in _resolve_lookup
    current = current[bit]
              ~~~~~~~^^^^^
KeyError: 'arch'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/[...]/Library/Caches/pypoetry/virtualenvs/mobsf-u6ypDL8M-py3.11/lib/python3.11/site-packages/django/template/base.py", line 890, in _resolve_lookup
    current = getattr(current, bit)
              ^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'dict' object has no attribute 'arch'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/[...]/Library/Caches/pypoetry/virtualenvs/mobsf-u6ypDL8M-py3.11/lib/python3.11/site-packages/django/template/base.py", line 896, in _resolve_lookup
    current = current[int(bit)]
                      ^^^^^^^^
ValueError: invalid literal for int() with base 10: 'arch'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/[...]/Library/Caches/pypoetry/virtualenvs/mobsf-u6ypDL8M-py3.11/lib/python3.11/site-packages/django/template/base.py", line 903, in _resolve_lookup
    raise VariableDoesNotExist(
django.template.base.VariableDoesNotExist: Failed lookup for key [arch] in {}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions