Mobile Application Security Testing
Mobile Exploitation Techniques · Mobile Exploitation track
7 min read
In this module
The Testing Spectrum
Mobile application security testing splits into two complementary disciplines: static analysis (poking at the app without running it) and dynamic analysis (watching the app's behaviour while it actually runs). A serious assessment uses both, because each one finds bugs the other never could.
Static Analysis
Static analysis pokes at the application's code, configuration, and resources without ever running it. You're looking for vulnerabilities, misconfigurations, and embedded secrets by inspecting the app's contents directly.
iOS Static Analysis
For iOS apps, static analysis begins with the IPA file:
- Unzip the IPA to access the app bundle.
- Examine the Mach-O binary with tools like
otool(load commands, linked libraries) andclass-dump(Objective-C class declarations). - Check entitlements with
codesign --display --entitlementsto see what capabilities the app declares. - Search for embedded secrets - API keys, hardcoded credentials, and debug endpoints in the binary and resource files.
- Inspect Info.plist for transport security exceptions (ATS), URL schemes, and exported services.
One catch: an IPA downloaded from the App Store is FairPlay-encrypted (otool -l shows LC_ENCRYPTION_INFO_64 with cryptid 1). class-dump and disassemblers only see ciphertext until you dump a decrypted copy from the app running on a jailbroken device, using a tool such as frida-ios-dump. Builds you get from the developer for testing are usually unencrypted.
# iOS static analysis commands$ unzip MyApp.ipa -d MyApp_extracted && cd MyApp_extracted$ otool -L Payload/MyApp.app/MyApp # linked libraries$ otool -l Payload/MyApp.app/MyApp # load commands$ class-dump Payload/MyApp.app/MyApp # ObjC class headers$ codesign -d --entitlements - Payload/MyApp.app$ strings Payload/MyApp.app/MyApp | grep -i "api_key\|secret\|password"Android Static Analysis
Android APKs are far friendlier to static analysis, because DEX bytecode decompiles back into near-source-quality Java:
- Decompile the APK using jadx or apktool.
- Examine AndroidManifest.xml for exported components, permissions, and intent filters.
- Review decompiled source for hardcoded secrets, insecure cryptography, and SQL injection.
- Check for insecure configurations -
android:debuggable="true",android:allowBackup="true", cleartext traffic. - Analyse native libraries (.so files) with Ghidra or IDA for vulnerabilities in JNI code.
Static analysis inspects an app's code, manifest, entitlements, and resources without executing it. It reveals hardcoded secrets, insecure configurations, exported components, and code-level vulnerabilities. Android apps are particularly amenable to static analysis because DEX bytecode decompiles to readable Java/Kotlin source.
Dynamic Analysis
Dynamic analysis watches the app while it runs in a controlled environment. This catches the runtime behaviour static analysis simply can't predict: real network traffic, file system access, IPC calls, and how the app reacts when you start feeding it weird input.
Network Interception
The bread-and-butter dynamic analysis technique is intercepting network traffic with a proxy (Burp Suite, mitmproxy). To intercept HTTPS, you have to install a trusted CA certificate on the device. From there the tester can read and tamper with every API request and response.
# Setting up mitmproxy for mobile traffic interception$ mitmproxy --listen-port 8080# Configure device to use proxy: <host_ip>:8080# Install mitmproxy CA certificate on device# All HTTPS traffic is now visible and modifiableMany apps implement certificate pinning, rejecting any certificate that doesn't match an expected value even if the device's CA store trusts it. Bypassing certificate pinning is a standard step in dynamic analysis, usually pulled off through runtime hooking (see Frida below).
Runtime Monitoring
Beyond network traffic, dynamic analysis monitors:
- File system operations: What files the app creates, reads, and writes. Sensitive data stored unencrypted in the app's sandbox is a common finding.
- Keychain/Keystore usage: How the app stores secrets. Insecure storage attributes (accessible when unlocked vs. always accessible) are a frequent issue.
- IPC and URL scheme handling: How the app responds to deep links and inter-app communication. Improper URL scheme validation can allow other apps to trigger sensitive operations.
- Logging: Sensitive data logged to the system log (visible to other apps on older Android versions, visible via logcat with physical access).
Frida: Dynamic Instrumentation
Frida is the most widely used dynamic instrumentation framework in mobile security testing. It injects a JavaScript engine into a running process, letting the tester hook functions, rewrite arguments and return values, and peek at internal state, all without ever editing the app's binary on disk.
# Frida: spawn the app with the script loaded (-f spawns, -n attaches by name)$ frida -U -f com.example.app -l ssl_pinning_bypass.jsX509TrustManager is an interface, so there's no method body on it to hook. The usual trick is to register your own trust-all class and slip it into every SSLContext the app creates:
// ssl_pinning_bypass.js: swap in a trust-all TrustManager (Android)Java.perform(function () { var X509TrustManager = Java.use('javax.net.ssl.X509TrustManager'); var SSLContext = Java.use('javax.net.ssl.SSLContext');
var TrustAll = Java.registerClass({ name: 'com.example.TrustAll', implements: [X509TrustManager], methods: { checkClientTrusted: function (chain, authType) {}, checkServerTrusted: function (chain, authType) {}, // accept anything (testing only!) getAcceptedIssuers: function () { return []; } } });
var init = SSLContext.init.overload( '[Ljavax.net.ssl.KeyManager;', '[Ljavax.net.ssl.TrustManager;', 'java.security.SecureRandom'); init.implementation = function (km, tm, random) { console.log('[+] SSLContext.init: using trust-all TrustManager'); init.call(this, km, [TrustAll.$new()], random); };});That defeats apps that rely on the platform's trust checks or a custom TrustManager. Libraries that pin separately, such as OkHttp's CertificatePinner, need their own hooks, which is why most testers reach for a maintained script or objection's android sslpinning disable first.
Frida works by injecting its agent (frida-agent) into the target process. On a jailbroken iOS device or rooted Android device, Frida can latch onto any process. On non-jailbroken/non-rooted devices, Frida Gadget gets embedded into the app's binary, and the repackaged app is installed for testing.
Frida is a dynamic instrumentation toolkit that injects a JavaScript engine into running processes. It allows security testers to hook functions, modify arguments and return values, bypass security checks (SSL pinning, jailbreak detection), and trace API calls at runtime. It operates on both iOS and Android and is the standard tool for mobile dynamic analysis.
Objection: Automated Mobile Testing
Objection is built on top of Frida and provides automated, pre-built scripts for common mobile security testing tasks:
- Bypassing SSL certificate pinning.
- Bypassing jailbreak/root detection.
- Dumping the keychain (iOS) or KeyStore (Android).
- Listing and exploring the app's file system.
- Monitoring clipboard access.
- Hooking cryptographic operations to capture plaintext data.
Objection collapses what used to be hours of bespoke Frida scripting into simple command-line operations, by packaging expert-written scripts behind a friendly CLI.
Testing Methodology
A structured mobile security assessment follows a methodology such as the OWASP Mobile Application Security Testing Guide (MASTG):
Each phase feeds the next. Static analysis tells you which functions are worth hooking during dynamic analysis. Network interception turns up endpoints worth probing for authentication and authorisation flaws. The aim is systematic coverage, so no whole category of vulnerability quietly slips past.