iOS Pentesting
iOS testing divides along the jailbreak boundary rather than requiring one throughout. Static analysis of a signed IPA, entitlement inspection and proxy interception work on a stock device; reading the app container, dumping keychain items and decrypting the binary need a jailbroken handset, so every finding records which side of that line produced it.
Static Analysis
Static work on an iOS build starts with its identity rather than its behaviour. A container path, a keychain item or an intercepted request is only meaningful against one specific build, so the note leads with that identity; a finding quoted against "the app" stops being reproducible the moment the client ships again.
Extract and analyze the IPA:
# The bundle container holds the .app; there is no .ipa at this path
ls /var/containers/Bundle/Application/<UUID>/
# Pull the bundle itself
scp -r root@device:/var/containers/Bundle/Application/<UUID>/App.app .
# Read the shipped Info.plist
plutil -p App.app/Info.plist
# A decrypted copy for offline work comes from a dumper running on the device:
# pull the IPA it writes, then unzip it
unzip App-decrypted.ipa -d app_extracted
cd app_extracted/Payload/App.app
plutil -p Info.plist
The entitlement dump is usually the shortest evidence path to a capability finding, and it costs
one codesign
call. App-group membership, associated domains, keychain access groups and extension entitlements
are all declared before any runtime work, and each one widens what a compromised device can reach
across app boundaries.
Binary analysis:
# List libraries
otool -L App
# Search for strings
strings App | grep -iE "password|secret|key|token"
# Check for PIE and ARC
otool -hv App # Check for PIE flag
otool -Iv App | grep _objc_release # Check for ARC
# Objective-C class and protocol metadata
otool -ov App | head -200
# Symbol table with Swift names demangled
nm -m App | xcrun swift-demangle | head -200The IPA as an Artefact
An IPA is a zip whose single top-level directory is Payload, and the order
its parts are read in matters because each answers a different question.
Info.plist declares the surface: identity, URL schemes, background modes, the
App Transport Security dictionary, whether documents reach the Files app. The embedded provisioning
profile says what the signing authority allowed this build to do; the entitlement blob in the
signature says what it asked for. A capability in the profile but not in the binary was never
claimed, and one in the binary the profile lacks would not have validated. Frameworks and plug-ins
come last because each is another Mach-O with its own signature.
The Parts of a Signed IPA, Read in Order
Scroll sideways to see the whole diagram
The profile also tells you which target you have. A development profile carries
ProvisionedDevices and get-task-allow, the
entitlement that lets a debugger attach without a jailbreak; an App Store distribution profile
carries neither.
Anything proven only against the former is a build-configuration finding: verbose logging or a
staging endpoint behind a debug flag, seeded test accounts, a binary never FairPlay-encrypted because
it was installed from Xcode. Test the distribution artefact before calling any of it a property of
the app.
# What is in the bundle, before extracting it
unzip -l App.ipa
# Identity and the declared surface
plutil -p Payload/App.app/Info.plist
# The profile that signed it: a CMS blob, not a plist you can read directly
security cms -D -i Payload/App.app/embedded.mobileprovision
# What the signature carries; the trailing colon sends the plist to stdout
codesign -d --entitlements :- Payload/App.app
codesign -dvvv Payload/App.app
# The other binaries in the same bundle, and what the main one links against
ls -R Payload/App.app/Frameworks Payload/App.app/PlugIns
otool -L Payload/App.app/App
The PlugIns directory is the part most often skipped. Each
.appex is a separate process with its own entitlements and container, so an
extension granted an app group the app lacks has widened reach without the app binary.
Binary Protections as Graded Evidence
Mach-O has no single hardening score, so read these as deductions that each enable or remove an
analysis path. Encryption comes first because it decides whether static reading is possible:
cryptid is 1 for a FairPlay-wrapped binary and 0 for one that is not, and the
encrypted range covers text and read-only data, so strings and disassembly from it mean nothing. The
symbol table sits in __LINKEDIT, outside that range, so names survive where
code does not.
| Check | Where it reads | What the result changes |
|---|---|---|
| Encryption | otool -l, cryptid |
1: strings and text are unusable until decrypted. 0: static reading can start. |
| PIE | otool -hv, MH_PIE |
Present: a run's address needs the slide subtracted before it is reusable as an offset. |
| Stack canary | nm -u, __stack_chk_fail |
Present: overflow of a protected frame aborts. Absent: a corruption route is cheaper to develop. |
| ARC | otool -Iv, objc_release |
Absent in an Objective-C binary: manual retain and release, so lifetime bugs are plausible. |
__RESTRICT |
otool -l, segment name |
Present: DYLD_INSERT_LIBRARIES is ignored, closing the cheapest injection route. Says nothing about a device already past kernel restrictions. |
| Language mix | otool -L, __swift5_* |
Swift-only exposes fewer methods to the runtime, so the hook surface shrinks. |
An absent protection is a statement about effort, not a vulnerability: a missing canary or a non-PIE image says how hard a memory-corruption bug would be to develop, and listing either as a finding is how a report stops being read. The entries that change the next step are encryption, which decides whether static reading is worth starting, and language mix, which decides whether the hook surface exists for the methods you care about.
What a Jailbreak Buys, Task by Task
The answer differs by task and by build, and the difference is what the client acts on. Each row names the mechanism that decides it.
| Task | Stock device | Jailbroken | Mechanism |
|---|---|---|---|
| Read another app's container | Its own only, from a development build | Any container | The sandbox is a kernel policy on the process, so a read outside it needs a process outside it. |
| Dump keychain items | No | Within the process's access groups | Items are gated by access group and accessibility attribute, so the read runs in the app's context. |
| Obtain a decrypted Mach-O | If the build was never wrapped | For a wrapped build | FairPlay wraps an App Store binary; an install from Xcode is already unwrapped. |
| Attach an instrumentation framework | Only a re-signed build | Yes | Injection needs a task port from a debug entitlement, or removed kernel restrictions. |
| Get past certificate pinning | Detection only | Yes | A proxy with a CA installed shows that pinning is enforced, because the handshake fails. Seeing the payload needs a hook. |
Every finding therefore carries the column that produced it. A container or keychain read on a jailbroken handset is a device-compromise finding unless the build exposed the data itself, while a pinning failure seen through a proxy is a stock-device finding. A task that needed the jailbreak gets a retest note rather than a fix: the client cannot verify reachability that depends on a modified device, only that the data is not readable through a backup, stored under a weak class, or valid after logout. Detection is the same boundary reported wrongly — an app that refuses to run on a modified device is enforcing a control, not failing one, and its bypass is itself a hook, so the finding is that detection is a client-side decision. Whether the server notices is the separate question.
Dynamic Analysis
Most dynamic iOS testing depends on a jailbreak, and that dependency has to travel with the observation. The application container is readable on a jailbroken device by definition, so the path that reached the data is not the finding; unencrypted, non-migrating data sitting in it is. Saying for each result whether it required the jailbreak is what lets the client separate a device-compromise finding from one that survives on a stock handset.
A hook that makes trust evaluation return success needs the same qualification. It proves the app delegates the decision to the platform store, not that an attacker holding the device can repeat it without a tweak or an instrumentation framework — so the write-up names the control that was defeated, not merely the traffic that appeared.
Frida setup:
# Frida on a jailbroken device
# Either install it from a jailbreak package manager that still serves packages,
# or push the server binary over SSH and start it
scp frida-server root@device:/usr/sbin/
ssh root@device 'chmod 755 /usr/sbin/frida-server && /usr/sbin/frida-server &'
# List processes
frida-ps -USSL Pinning Bypass
Save as ios_ssl_bypass.js:
var resolver = new ApiResolver('objc');
resolver.enumerateMatches('*[* URLSession:didReceiveChallenge:completionHandler:]', {
onMatch: function(match) {
Interceptor.attach(match.address, {
onEnter: function(args) {
var completionHandler = new ObjC.Block(args[4]);
var NSURLSessionAuthChallengeUseCredential = 0;
completionHandler.implementation = function(disposition, credential) {
completionHandler(NSURLSessionAuthChallengeUseCredential, null);
};
}
});
},
onComplete: function() {}
});Run bypass:
frida -U -f com.target.app -l ios_ssl_bypass.jsTwo results are easy to over-read. Caches and values visible to an attached debugger may not survive to an offline attacker, so state the access model that produced them rather than the value alone. The simulator has no Secure Enclave and no real keychain either, so behaviour observed there does not transfer to a device, and anything that depends on the enclave has to be reproduced on hardware.
Objection & Forensics
# An instrumentation session inside the target process
objection -g com.target.app explore
# Inside the objection prompt:
# ios sslpinning disable
# ios keychain dump
# ios cookies get
# A shell on the device instead reads the container, which is a different scope
ls -la /var/mobile/Containers/Data/Application/<UUID>/The keychain line is a capability rather than a program. Items are keyed to an access group, so a dump returns what the calling process may read: a session injected into the app sees the app's own items, while a root process outside the sandbox must reach the keychain daemon and satisfy it instead. A standalone dumper binary is tied to the system interfaces of the release it was built against; the injected command is not.
The Objective-C Runtime as a Hook Surface
Objective-C dispatches through a class's method list, and the runtime exposes that list while the
process runs: a selector's implementation can be exchanged with another
(method_exchangeImplementations) or overwritten outright
(method_setImplementation). Instrumentation frameworks wrap the second form,
so a hook reads as a replacement that receives the receiver, the selector and the arguments. The
receiver is not decoration: instance state lives on it, and the saved original has to be called with
it and with the selector, or the original runs against the wrong object.
The failure that catches everyone first is recursion. Once the implementation is replaced, calling
this.method(...) from inside the replacement sends the same selector, which
resolves to the replacement again until the stack runs out. Capture the original before installing
the replacement and call it with the receiver you were handed — orig.call(this, ...) where
the original is held as a wrapper, the explicit original(handle, selector, ...) form
below otherwise. A crash that appears only when a hook is loaded, with the hooked selector repeating
in the stack, is this mistake rather than an application bug. A Swift method with no Objective-C
exposure has no selector to replace at all.
// Capture the original before replacing it, or the hook calls itself
var cls = ObjC.classes.SessionStore;
var method = cls['- tokenForAccount:'];
var original = method.implementation;
method.implementation = ObjC.implement(method, function (handle, selector, account) {
var value = original(handle, selector, account);
console.log('tokenForAccount: called for ' + new ObjC.Object(account).toString());
// The caller sees whatever this returns. Returning value observes the call;
// returning nil changes the caller's decision without touching its code.
return value;
});What a hook shows and what it changes are separate claims. A replacement that makes a trust evaluation succeed shows the decision was taken in the process and that nothing re-checked it on that path; it does not show the server accepts the resulting session, and it proves nothing once the hook is removed. One that only logs shows a value reached that call site, not where it was stored. One that changes a value and produces different server behaviour is the strongest, because it shows the client was trusted with the decision.
Storage and Protection Classes
iOS grades stored data with two attributes rather than a file mode: the keychain accessibility attribute and the file protection class. A keychain item readable only while the device is unlocked, and marked non-migrating, is materially stronger than a plaintext file in the container, so report the attribute rather than the value; a file at no-protection is a finding, and one protected until first unlock is a much weaker one.
A container path needs the entitlement that made it reachable — the absolute path plus the app-group membership or entitlement is what tells the client whether the exposure is single-app or cross-app. The app-switcher snapshot and the pasteboard belong to the same question: both are transient by design, so a value that exists only during an active session may sit outside the threat model the engagement agreed to.
Worked Example: One Value Through Storage
Take one value the app persists — a session token is the usual case — and follow the value rather
than the storage API. Written with NSUserDefaults, it lands in
Library/Preferences/<bundle-id>.plist as a binary plist: no keychain
protection, included in every backup, covered only by the file protection class the app applies to
that path. Written to a file under Documents, it carries that file's class and
stays backup-eligible unless the URL was marked with
NSURLIsExcludedFromBackupKey. Written to the keychain, it leaves the
container: gated by an access group and an accessibility attribute, backed up only when migratable,
and not deleted when the app is.
# The data container, not the bundle container
ls -la /var/mobile/Containers/Data/Application/<UUID>/Library/Preferences/
# Defaults are a plist; read it in place rather than copying it first
plutil -p /var/mobile/Containers/Data/Application/<UUID>/Library/Preferences/com.target.app.plist
# A Core Data or SQLite store holding the same value
sqlite3 "/var/mobile/Containers/Data/Application/<UUID>/Library/Application Support/store.sqlite" ".tables"
# The protection class is proven by behaviour, not by a path listing:
# lock the device and attempt the same read againThe value is a finding when three answers are yes: whether it is recoverable from an artefact the attacker can obtain — a backup, a stolen unlocked device, another app in the same group, a device where the sandbox no longer applies — whether it is still valid when recovered, and whether it is personal, privileged or a credential. Recoverability is the storage class plus the protection attributes: a defaults plist is included in a backup, a device-only keychain item in none, and a file classed complete-until-first-unlock is readable for the rest of the session after one unlock. Validity is a server question, tested by logging out and replaying.
What is merely normal belongs in the same paragraph: a re-derived cache, UI state, an opaque reference the server can revoke in one call, data visible only to an attached debugger, and a keychain item that is device-only and readable only while unlocked. The last is still evidence of an access model, and the value stays redacted. What is worth reporting is the tuple — storage class, protection attribute, backup eligibility, lifetime after logout.
iOS Tools
otool
Reverse EngineeringApple's Mach-O inspection tool, shipped with the Xcode command-line tools. Prints load commands, Objective-C class and protocol metadata, and the symbol table.
Installation
otool -ov App.app/AppHopper Disassembler
DisassemblerA reverse engineering tool for macOS and Linux that lets you disassemble, decompile, and debug your 32/64bits Intel Mac, Linux, Windows and iOS executables.
Installation
# Download from websiteFrida-based IPA dumper
DecryptionA Frida script that attaches to the running app, reads the decrypted pages of the Mach-O back out of memory and repackages them into an IPA. It runs on the device, so the app still has to be launched under instrumentation on a jailbroken handset.
Installation
# Runs on a jailbroken device with frida-server startedKeychain item dump
ForensicsA capability rather than a standalone binary: a session injected into the app process reads items through the app's own access group and reports the item class, account, service, access group and accessibility attribute. It needs an instrumentation session, so it inherits the jailbreak dependency described above.
Practice Lab
Archive a build you compiled and read the artefact set this page puts in read order: the shipped Info.plist and its App Transport Security dictionary, the entitlement dump, the profile that signed it. Then remove one exception and record what changed — done when you can name every ATS key your build sets and show the difference its removal made. No App Store binary and no jailbreak is involved.
Evidence to Capture
Device and OS: Model, iOS or iPadOS version, jailbreak state and the method used.
Application identity: Bundle identifier, version and build number, with the SHA-256 of the IPA that was tested.
Container path: The absolute path under the application data container, and the entitlement or app group that allowed the read.
Keychain item: Item class, accessibility attribute and access group, with the value itself redacted.
Hook output: The Frida script hash, the class or method hooked, and the console output.
Entitlements: The codesign entitlement dump for the app and its extensions.
Likely False Positives
- Jailbreak-only reachability: A container read that required the jailbreak.
- Keychain accessibility attribute: A value guarded by a strict accessibility attribute.
- File protection class: A file protected until first unlock.
- Transient in-memory state: A debugger-visible cache that never reaches disk.
- Bypass achieved with a jailbreak tweak: A tweak that disables trust evaluation.
- Simulator behaviour: No Secure Enclave and no real keychain.
- Pasteboard or snapshot timing: A session-scoped pasteboard or snapshot item.
Testing Checklist
Device and build
- ☐ Model, OS version and jailbreak state recorded
- ☐ Bundle identifier, version and build recorded
- ☐ IPA hash recorded
- ☐ Entitlements and app-group membership dumped
Storage
- ☐ Documents, Library, Caches and shared containers reviewed
- ☐ Keychain items classified by accessibility attribute
- ☐ NSUserDefaults and plist files searched for tokens
- ☐ Core Data and SQLite stores checked for unencrypted personal data
- ☐ App-switcher snapshot and pasteboard behaviour tested
Transport
- ☐ Proxy interception attempted with a pinning bypass
- ☐ App Transport Security configuration reviewed, including arbitrary-load exceptions
- ☐ Intercepted traffic inspected for token and personal-data exposure
- ☐ WebView traffic distinguished from app client traffic
Platform interaction
- ☐ Keychain sharing groups reviewed for cross-app exposure
- ☐ Universal links and URL schemes tested for state change
- ☐ Jailbreak and tamper detection behaviour recorded
- ☐ Evidence reproducible without the specific jailbreak tool where possible
Remediation & Defense
Client
- • Migrate tokens and personal data to the Keychain with the strictest accessibility the feature allows
- • Set an explicit file protection class for files that hold personal data
- • Exclude caches holding personal data from backup where the data can be re-derived
- • Clear the app-switcher snapshot and pasteboard on backgrounding for sensitive screens
- • Treat jailbreak detection as a signal to the server rather than a client decision
Transport
- • Remove App Transport Security exceptions and require TLS 1.2 or later
- • Pin public keys with a backup pin and an owned rotation process
- • Reject cleartext and mixed content in WebViews
Server
- • Bind tokens to a secure-enclave key or to a proof-of-possession assertion
- • Shorten token lifetime and support revocation per device
- • Require re-authentication server-side for sensitive operations
Process
- • Retest against the release build on a signed device where a jailbreak is not required
- • Enforce file protection and keychain accessibility as a build-time lint rule
- • Record the jailbreak tool and version so the retest is comparable