Introducing a new way to review your PRs.

Read the announcement

mobsf / mobile-security-framework-mobsf

Mobile Security Framework (MobSF) is an automated, all-in-one mobile application (Android/iOS/Windows) pen-testing, malware analysis and security assessment framework capable of performing static and dynamic analysis.

View on GitHub

13 documents · Updated Nov 16, 2026

docs / ios-static-analysis

iOS Static Analysis

Overview

The iOS static-analysis entry point is mobsf/…/static_analyzer.py. static_analyzer_ios() validates that the request checksum is an MD5, looks up RecentScansDB for the uploaded file type/name, accepts only configured iOS extensions plus ZIP/source uploads, builds the shared app_dict with upload paths, tool paths, original filename, checksum, and icon placeholder, then dispatches by scan type: IPA/source ZIP in mobsf/…/ipa.py, standalone .dylib in mobsf/…/dylib.py, and static .a archives through the common archive analyzer.

IPA scans are orchestrated by ipa_analysis() and ipa_analysis_task() in mobsf/…/ipa.py. Cached scans are reconstructed from StaticAnalyzerIOS by mobsf/…/db_interaction.py; rescans or cache misses require scan permission and can run synchronously or through async_analysis. A fresh IPA scan computes size and SHA hashes, unzips the IPA, safely locates the Payload/*.app bundle, and stores bin_dir plus app_root in app_dict. common_analysis() then runs file listing, plist parsing, App Store lookup, and plist secret extraction before binary-specific work starts.

Source ZIP scans use the same ipa.py orchestration through ios_analysis() and ios_analysis_task(), but assume the upload directory is already extracted. They call common_analysis('zip', ...), run source SAST with ios_source_analysis(), collect strings/entropy from source files, choose an .appiconset PNG as the report icon, and save a mostly source-focused context with empty Mach-O checks.

File and plist normalization happen early. mobsf/…/file_analysis.py walks the scan root, normalizes + in filenames to x, converts IPA binary plists to XML, and returns all_files with files_short, files_long, and grouped special_files for certificates/keys, SQLite databases, plist files, and JSON files. mobsf/…/plist_analysis.py finds Info.plist differently for source ZIPs and IPA bundles, loads it with plistlib, extracts display name, executable, bundle ID, version/build/platform/minimum OS, URL types, supported platforms, and raw plist XML. Bundle ID discovery also searches .entitlements files and project.pbxproj for source archives. The same plist pass aggregates permission usage from mobsf/…/permission_analysis.py and App Transport Security findings from mobsf/…/app_transport_security.py; get_plist_secrets() scans plist XML for known secret patterns and suspicious secret-like keys.

For IPAs, mobsf/…/binary_analysis.py locates the app executable from CFBundleExecutable or the .app name, rejects traversal/symlink/special-file paths, then uses LIEF and shared Mach-O helpers to populate bin_info, checksec output, symbol lists, linked libraries, and binary type (Swift if libswiftCore.dylib is linked, otherwise Objective-C). mobsf/…/classdump.py dumps classes/selectors through platform tools (class-dump, class-dump-swift, or jtool) and supplements them with LIEF-extracted Objective-C/Swift string sections; the bytes are saved as classdump.txt in the upload directory. mobsf/…/binary_rule_matcher.py evaluates mobsf/…/ipa_rules.py regex rules over symbols plus classdump bytes for insecure C APIs, weak crypto/hash/random APIs, logging, anti-debugging, deprecated UIWebView, weak Keychain constants, TLS validation bypass selectors, WKWebView local-file access selectors, pasteboard use, SQLite APIs, and related standards metadata.

Entitlement and code-signing analysis is integrated into binary findings by mobsf/…/entitlements.py. ipa_entitlements_analysis() extracts embedded Mach-O code-signature entitlements and the CMS signer, parses embedded.mobileprovision for provisioning metadata, picks Mach-O entitlements first when present, evaluates debuggable builds, sandbox-weakening entitlements, enterprise/all-devices provisioning, wildcard/shared Keychain groups, app groups, and Associated Domains, then appends a human-readable code-signing summary to bin_info['code_signing']. The same module contributes source findings with source_entitlements_analysis() by scanning .entitlements files inside source ZIPs and adding rule-shaped entries to the source SAST result.

String, URL, domain, tracker, JavaScript, and SBOM outputs are assembled after binary/source analysis. For IPAs, mobsf/…/strings.py merges binary strings, dylib/framework strings from shared library_analysis(), and readable files from all_files['files_long'], skipping framework internals and common binary/resource extensions, then returns unique URL lists plus URL/email-with-file mappings and augments app secrets with binary secret hits. ipa_analysis_task() also analyzes embedded JavaScript/hybrid/Hermes content with the common iOS JS analyzer and folds JS URLs, emails, and secrets into the same structures. For source ZIPs, mobsf/…/code_analysis.py runs SastEngine over Objective-C rules, Swift rules, and API rules from mobsf/…/*.yaml, extracts URLs/emails from .m and .swift files, runs common JS analysis, identifies source type (Swift, Objective-C, both, or no code), and runs MalwareDomainCheck on deduplicated URLs. Both IPA and source scans call Firebase analysis, tracker matching, and ios_sbom() before persistence; IPA tracker matching also includes embedded .framework names and bundle IDs discovered by get_embedded_framework_deps().

App Store enrichment is handled by mobsf/…/appstore.py. app_search() validates the bundle identifier with strict_package_check, queries the configured iTunes lookup endpoint through fixed_endpoint_request and upstream proxy settings, and stores metadata such as title, icon URL, developer, category, price, score, supported devices, description, and iTunes URL, or {'error': True} when validation/lookup fails.

Standalone dylib scans in mobsf/…/dylib.py reuse the iOS persistence/reporting model without an app bundle. They synthesize a minimal infoplist keyed by the filename, compute file hashes and Mach-O bin_info, call shared library_analysis() over the upload directory, convert collected symbols into file-analysis entries, run binary_rule_matcher() against those symbols, extract string metadata and domains, run Firebase/tracker analysis, and save through the same save_get_ctx() path. VirusTotal enrichment is added at response time for IPA and dylib scans when settings.VT_ENABLED is true; source ZIP responses do not perform VirusTotal lookup.

Persistence and response contexts are centralized in mobsf/…/db_interaction.py. save_or_update() maps app_dict['infoplist'], app_dict['all_files'], code_dict, and bin_dict into StaticAnalyzerIOS columns including hashes, app identity, plist XML, permissions, ATS findings, binary/checksec findings, dylib/framework analysis, API/source findings, files, URLs/domains/emails, strings, Firebase URLs, App Store details, secrets, trackers, SBOM, and JS analysis. It also updates RecentScansDB app name/package/version. get_context_from_analysis() and get_context_from_db_entry() return the template/API context with suppressions applied to source, binary, and JS findings and secrets sorted. ipa.py adds dynamic-only report fields such as AppSec dashboard, average CVSS, and VirusTotal before rendering static_analysis/ios_binary_analysis.html or static_analysis/ios_source_analysis.html.

Source viewing for iOS report links lives under mobsf/…/view_source.py. run() validates API/UI parameters with the iOS view-source forms, anchors the requested file under either the upload root (type=ios) or Payload directory (type=ipa), rejects traversal and pipe/link paths, and renders or returns source content. It chooses syntax/output handling with set_ext_api(): Objective-C as C++, JS/HTML/bundles through paged JS source windows, XML/text as plain reads, plist/entitlements as JSON when parseable, SQLite files through read_sqlite(), and classdump.txt from the upload directory.

Coupling

Risks

  • mobsf/…/plist_analysis.py, mobsf/…/app_transport_security.py, and mobsf/…/appstore.py are sensitive to malformed or unexpected plist/bundle-ID input: recent history includes 915ecd7 fix(ios): guard non-dict plists in check_transport_security... and 2e3e04e ... store lookups behind proxy.... If plist parsing returns non-dicts or invalid bundle IDs are allowed into app_search(), scans can fail or make unsafe/unbounded external lookup requests.
  • mobsf/…/binary_analysis.py, mobsf/…/icon_analysis.py, and mobsf/…/ipa.py rely on dynamic paths from archives and plist values; recent history includes 28c2a92 Harden archive parsing, iOS dynamic paths.... If a future change drops the safe-path/symlink checks around Payload, .app, CFBundleExecutable, or icon paths, a crafted IPA can make analysis read or copy files outside the scan directory.
  • mobsf/…/classdump.py feeds both stored classdump.txt and binary-rule matching; recent fixes 60bb438 ... classdump fallback... and 1aac43c ... add LIEF classdump show churn around external tool failures and fallback extraction. If platform-specific classdump tools hang/fail or LIEF extraction is removed, rules for UIWebView, selectors, Swift metadata, and other classdump-only evidence silently lose coverage.
  • mobsf/…/entitlements.py parses Mach-O CMS blobs and provisioning profiles and injects findings via _add_bfindings() from mobsf/…/binary_rule_matcher.py; history includes 90a0dee ... Entitlements and Provisioning Profile security analysis, 4f044f3 fix(ios): address ... CMS signer SID and Mach-O entitlement precedence, and b0af1f9 ... dedicated report section. If precedence or CMS/profile parsing changes incorrectly, reports may miss debuggable/enterprise/sandbox-weakening builds or show the wrong signer/team.
  • mobsf/…/strings.py mutates bin_dict['strings'] and app_dict['secrets'] while merging IPA, dylib/framework, JS, and plist secrets. If callers pass an incomplete all_files structure or if skip filters around frameworks/resources are changed, URL/domain/secret extraction can become noisy enough to pollute malware-domain checks, tracker matching, Firebase detection, and persisted secrets.