iOS Pentesting
iOS is more closed than Android: sandboxing is strict, the filesystem is more protected, and without a jailbreak access is limited. Apps ship as an IPA (a ZIP with the Mach-O binary encrypted by the App Store, resources, and Info.plist). Still, with a jailbroken device —or no-jailbreak techniques— and Frida you can inspect, instrument, and audit an iOS app following the same MASVS.
flowchart TD
IPA["IPA (Payload/App.app)"] --> ENC["Encrypted binary (FairPlay)"]
ENC --> DUMP["frida-ios-dump / bagbak"]
DUMP --> MACHO["Decrypted Mach-O"]
MACHO --> STATIC["class-dump / otool / strings"]
IPA --> PLIST["Info.plist"]
PLIST --> URLS["URL schemes / ATS"]
STATIC --> DYN["Dynamic: Frida / Objection"]
URLS --> DYN
DYN --> KC["Keychain + storage"]
DYN --> BK["Backend / API"]
Threat model
Section titled “Threat model”The iOS sandbox already protects a lot, so the realistic attacker usually holds the device (jailbreak) or targets the traffic and backend:
- Jailbroken user: reads the app’s filesystem, dumps the Keychain and the decrypted binary.
- Network attacker: MITM if ATS is relaxed or pinning is bypassable (see SSL Pinning and Bypass).
- Another app / system: poorly validated URL schemes and Universal Links, shared pasteboard (see Deeplinks and IPC).
- Physical/backup access: sensitive data without proper Data Protection, or included in iCloud backups.
The IPA and its pieces
Section titled “The IPA and its pieces”# an IPA is a ZIP; its structure:unzip -l app.ipa# Payload/App.app/# <Mach-O binary> executable (encrypted by FairPlay if from the App Store)# Info.plist config, URL schemes (deeplinks), ATS, permissions# embedded.mobileprovision provisioning profile# _CodeSignature/ signature# resources (.plist, .db, assets)The FairPlay encryption challenge
Section titled “The FairPlay encryption challenge”App Store apps ship encrypted (FairPlay); for static analysis of the binary you must decrypt it first by dumping it from memory on a real device:
# on a jailbroken device, dump the decrypted IPAfrida-ios-dump # AloneMonkey: extracts the already-decrypted IPA# alternativesbagbak com.target.app # modern Frida-based dump# check whether a section is encryptedotool -l App.app/App | grep -A4 LC_ENCRYPTION_INFO # cryptid 1 = encryptedTest environment
Section titled “Test environment”# with jailbreak (full access), depending on iOS version# checkra1n / palera1n (bootrom), unc0ver / Dopamine (rootless)# SSH access to the device; Sileo/Cydia for tooling# no jailbreak (more limited): re-sign with an injected Frida gadget and sideloadobjection patchipa --source app.ipa # injects FridaGadget into the IPA# then sideload with Sideloadly / AltStore and a developer accountStatic analysis
Section titled “Static analysis”# on the decrypted Mach-O binaryclass-dump App.app/App # classes, methods, Objective-C metadataotool -L App.app/App # linked librariesotool -l App.app/App # load commands (encryption, flags)strings -a App.app/App | grep -iE 'https?://|key|secret|password'# Info.plist (it's binary; plutil converts it)plutil -p App.app/Info.plist# look for NSAllowsArbitraryLoads (ATS disabled -> HTTP allowed)For Swift, class-dump sees less; use the symbol panel in Hopper/Ghidra or jtool2 for Swift metadata.
Dynamic analysis
Section titled “Dynamic analysis”# instrumentation with Frida (see mob-frida)frida -U -f com.target.app -l script.js --no-pauseobjection -g com.target.app explore # explore, bypass, dump# bypass jailbreak detection and SSL pinning (see mob-ssl)Inside Objection:
ios jailbreak disable # bypass jailbreak detectionios sslpinning disable # bypass SSL pinningios keychain dump # dump the app's Keychainios nsuserdefaults get # NSUserDefaults (cleartext keys)Keychain and Data Protection
Section titled “Keychain and Data Protection”The Keychain is the “right” place for secrets, but with a jailbreak it can be dumped, and the protection class decides when it’s readable:
kSecAttrAccessibleWhenUnlocked— accessible only with the device unlocked (recommended).kSecAttrAccessibleAfterFirstUnlock— accessible after the first unlock (common for background processes).kSecAttrAccessibleAlways— deprecated and insecure: always readable.
Adding ThisDeviceOnly prevents the secret from travelling in backups or to another device.
Red Team
Section titled “Red Team”Testing against an app you own or have permission to test:
- Decrypt and read the binary:
frida-ios-dump+class-dump/stringsfor endpoints and secrets. - Dump the Keychain and review overly permissive protection classes.
- Review the container:
/var/mobile/Containers/Data/Application/<UUID>/— NSUserDefaults (.plist), SQLite, cache, logs (see Insecure Storage). - Bypass jailbreak detection and pinning with Objection/Frida, and attack the backend (Web Methodology).
- Deeplinks/Universal Links: unverified URL schemes and weak validation (see Deeplinks and IPC).
# locate the app's data container (inside objection)envls /var/mobile/Containers/Data/Application/<UUID>/Library/Preferences/Blue Team
Section titled “Blue Team”- Secrets in the Keychain with the right protection class (
WhenUnlocked,ThisDeviceOnly), never in.plist/NSUserDefaults/code. - ATS enabled: no
NSAllowsArbitraryLoads; TLS + pinning (SSL Pinning and Bypass). - Data Protection (encryption tied to unlock) for sensitive files; clear cache, pasteboard, and the background snapshot.
- Validate URL schemes and Universal Links; prefer domain-verified Universal Links.
- MASVS-RESILIENCE (jailbreak detection, anti-debug, obfuscation) raises the cost, it doesn’t replace backend security.
Checklist
Section titled “Checklist”- Get and decrypt the IPA (frida-ios-dump / bagbak)
- Environment: jailbreak or Frida gadget (no jailbreak)
- Static: class-dump, strings, Info.plist (URL schemes, ATS)
- Dynamic: Frida/Objection, bypass jailbreak detection
- Keychain dump and protection classes
- Container storage (Insecure Storage)
- SSL pinning bypass (SSL Pinning and Bypass)
- Deeplinks / Universal Links (Deeplinks and IPC)
- Backend/API (Web Methodology)