2021 Sthack Jailbreak
2021 Sthack Jailbreak
Jailbreak detection
mechanisms and how
to bypass them
Sthack - 0x0a Edition
2021 October 15
Whoami 2
Eloi Benoist-Vanderbeken
@elvanderb on twitter
2 / 31
3
Introduction
JailBreak detection 4
iOS
Closed operating system
No easy way to get root
JailBreaks bypass iOS security to get (almost) full access
JailBreak detection
Used by banking applications and games
To make sure that the environment is “safe”…
…or to block cheats/cracks
Security researchers need to
Assess / reverse protected applications
4 / 31
iOS specificities 5
Signature
All the code must be signed by Apple (enforced by the system)
All the data is also signed (enforced by the App Store)
Memory protection
W^X
Only WebContent process can use JiT pages
No side loading
“Apps may not […] download, install, or execute code which introduces or
changes features or functionality of the app”
Public API
“Apps may only use public APIs”
Theoretically enforced by the App Store review process
Actually only used to block malicious tracking methods or deprecated/buggys
APIs
5 / 31
Frida 6
https://frida.re
“Dynamic instrumentation toolkit for developers, reverse-
engineers, and security researchers”
Allows you to inject JavaScript to instrument any process
iOS / Android / Windows / macOS / Linux / QNX...
Lots of features
Lots of bindings (.NET, Python, Node.js, Swift…)
Low level C API
6 / 31
Debugging an iOS app 7
Without a JailBreak
With ptrace (lldb / frida) → app needs the get-task-allow entitlement
By injecting code (frida) → app needs to be repackaged
And you can only do data only instrumentation
In both case, you need to resign the application…
… but it has a lot of side effect
Different Team ID
File are modified
With a JailBreak
No entitlements are required
Frida is able to attach to any process
Except system ones on post A12 iPhones because of PPL
7 / 31
8
Case study
The target 9
A banking app
Immediately crash when launched on a jailbroken device
Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Subtype: KERN_INVALID_ADDRESS at 0x0000000000000200
Executable is quite large
31MB
Nothing special at first sight
Methods name are not obfuscated
Strings are in cleartext
We tried a few scripts¹
But without luck
9 / 31
1: most notably this one: https://blog.spacepatroldelta.com/a?ID=01600-8a224e7e-6ceb-4e65-88b9-4545d6523275
Around the crash… 10
10 / 31
Around the crash… 11
11 / 31
Around the crash… 12
12 / 31
Around the crash… 13
13 / 31
Around the crash… 14
14 / 31
Syscalls 15
15 / 31
Interception with Frida
Examples are from the doc: https://frida.re/docs/javascript-api/
16
16 / 31
Interception with Frida 17
17 / 31
Using breakpoints 18
18 / 31
Patch all the syscalls 19
19 / 31
The nasty crash… 20
20 / 31
Stalker 21
21 / 31
Stalker 22
22 / 31
Protections 23
23 / 31
24
Solution
A generic API 25
25 / 31
A generic API 26
26 / 31
27
Future
Other techniques 28
28 / 31
Future of iOS instrumentation 29
29 / 31
PPL 30
30 / 31
31