SlideShare ist ein Scribd-Unternehmen logo
1 von 76
Downloaden Sie, um offline zu lesen
iOS 678 Security

—== A Study in Fail ==—
Stefan Esser <stefan.esser@sektioneins.de>
http://www.sektioneins.de
Stefan Esser • iOS 678 Security - A Study In Fail • March 2015 • 
Who am I?
Stefan Esser
• from Cologne / Germany
• in information security since 1998
• invested in PHP security from 2001 to 20xx
• since 2010 focused on iPhone security (ASLR/jailbreak)
• founder of SektionEins GmbH
2
Stefan Esser • iOS 678 Security - A Study In Fail • March 2015 • 
Lots of Fail, but this talk is not about …
• Apple releasing an iOS 8.0.1 update that would kill cell service on iPhone 6/6p
• Apple adding unsecured double linked lists as meta-data to the iOS 7 kernel
heap that made kernel heap exploitation easy (safe unlink in iOS 8)
• Apple “improving” their iOS 7 early random number generator so that Tarjei
Mandt would totally rip it apart and calculate all past and future numbers
• Apple having a double “goto fail” in their SSL for iOS 6 - iOS 7.0.5 that broke it
completely
• … so yes I am skipping a lot of fail but what I cover is already too much for 45 minutes
3
Stefan Esser • iOS 678 Security - A Study In Fail • March 2015 • 
So what is it about?
this talk is about iOS jailbreaks
and Apple fixing the bugs within
4
Stefan Esser • iOS 678 Security - A Study In Fail • March 2015 • 
Fixing Bugs …
5
Stefan Esser • iOS 678 Security - A Study In Fail • March 2015 • 
BUT APPLE SECURITY
AIN’T NO JEDI
6
BUT APPLE SECURITY
AIN’T NO JEDI
Stefan Esser • iOS 678 Security - A Study In Fail • March 2015 • 
So actually …
this talk is about iOS jailbreaks
and Apple not fixing the bugs within
7
Stefan Esser • iOS 678 Security - A Study In Fail • March 2015 • 
Before we start …
what are the ingredients
of an iOS jailbreak?
8
Stefan Esser • iOS 678 Security - A Study In Fail • March 2015 • 
Ingredients
Initial Injection Vector
Persistency
9
Stefan Esser • iOS 678 Security - A Study In Fail • March 2015 • 
Not talking about that
Initial Injection Vector
but apparently Apple had
to issue several updates to fix those bugs, too
10
Stefan Esser • iOS 678 Security - A Study In Fail • March 2015 • 
Concentrating on
Jailbreak
Persistency
11
Stefan Esser • iOS 678 Security - A Study In Fail • March 2015 • 
Jailbreak Persistency (I)
• why concentrate on persistency?
• attack surface for injection is just extremely = huge no chance of win
• injection vectors for iOS can be easily exchanged
• USB, mobile safari, malicious apps
• some injections would require more powerful kernel bugs than public
jailbreaks, but those do exist and are traded in the underground
12
Stefan Esser • iOS 678 Security - A Study In Fail • March 2015 • 
Jailbreak Persistency (II)
• attack surface for jailbreak persistency is in comparison extremely small
• could be made even smaller and smaller if Apple would do it right
• i just want the public to pressure Apple into changing
• PUBLIC PERSISTENCE EXPLOITS CAN BE EASILY REUSED IN STATE
SPONSORED ATTACKS = LOT CHEAPER + NOT WASTE BUGS
13
Stefan Esser • iOS 678 Security - A Study In Fail • March 2015 • 
AMFI trickery
14
Stefan Esser • iOS 678 Security - A Study In Fail • March 2015 • 
AMFI Trickery
• whole story starts with the exploit chain evad3rs “invented” for iOS 6
• for signature verification
• kernel asks AMFI driver
• AMFI driver asks AMFID user space daemon
• AMFID uses libmis.dylib
• Attack: 

inject a malicious library into AMFID that makes libmis.dylib return “true”
15
Stefan Esser • iOS 678 Security - A Study In Fail • March 2015 • 
Injecting a malicious dylib AMFI attack
• injecting malicious dylib / replacing libmis.dylib not as easy at it sounds
• need to trick dynamic linker into attempting to do it
• need to trick dynamic linker into accepting a not signed library
• Idea: 

use launch daemon config + DYLD_INSERT_LIBRARIES for first part

use incomplete codesigning bypass for second part
16
Stefan Esser • iOS 678 Security - A Study In Fail • March 2015 • 
Putting the full chain together
17
Stefan Esser • iOS 678 Security - A Study In Fail • March 2015 • 
Apple “trying” to fix evasi0n
• launchd.conf no longer loaded
• __restrict in AMFID stops DYLD_INSERT_LIBRARIES
• apply patch to fix incomplete code signing bypass (patient ALPHA)
• fix kernel info leak and memory corruption
18
Stefan Esser • iOS 678 Security - A Study In Fail • March 2015 • 
evad3rs needed new tricks
• patch of incomplete code signing trick (patient ALPHA) required new
incomplete code signing trick
➡ evad3rs unnecessarily burned a new vulnerability some gave to them
• __restrict in AMFID required new way to replace/inject library
➡ just use dyld feature enable-dylibs-to-override-cache

(makes dyld load a replacement library instead of original one)
19
Stefan Esser • iOS 678 Security - A Study In Fail • March 2015 • 
evad3rs needed new tricks (II)
• removal of launchd.conf required trick to inject launch daemons beside
launch daemon codesigning
• just use previous two also load a malicious xpcd_cache.dylib
• kernel bugs required to be replaced
• they just used some new bugs (because there are plenty)
20
Stefan Esser • iOS 678 Security - A Study In Fail • March 2015 • 
New chain for evasi0n 7
21
Stefan Esser • iOS 678 Security - A Study In Fail • March 2015 • 
Apple fixing evasi0n7 *LESS AGGRESSIVE*
• new incomplete codesigning bypass trick fixed
• kernel bugs are fixed
• rest of chain is left completely untouched
22
Stefan Esser • iOS 678 Security - A Study In Fail • March 2015 • 
Pangu7 Jailbreak
• Pangu realised that original bug Patient ALPHA was fixed incorrectly
• used new kernel bugs
23
DejaVu
Stefan Esser • iOS 678 Security - A Study In Fail • March 2015 • 
Apple “trying to fix” Pangu7
• they try to fix their broken fix for the codesigning
• kernel bugs are claimed fixed
• rest of chain is still completely untouched
24
DejaVu
Stefan Esser • iOS 678 Security - A Study In Fail • March 2015 • 
Pangu8 Jailbreak
• Pangu realised that fix for fix for Patient ALPHA is still incorrect
• also their kernel bugs were apparently not patched correctly
25
DejaVu
Stefan Esser • iOS 678 Security - A Study In Fail • March 2015 • 
Apple “trying to fix” Pangu8
• they try to fix their broken fix for the broken fix for the codesigning
• kernel bugs are claimed fixed again
• rest of chain is still completely untouched
26
DejaVu
Stefan Esser • iOS 678 Security - A Study In Fail • March 2015 • 
TaiG Jailbreak
• Pangu TaiG realised that fix for fix for fix for Patient ALPHA is still incorrect
• used other kernel bugs
27
DejaVu
Stefan Esser • iOS 678 Security - A Study In Fail • March 2015 • 
enable-dylibs-to-override-cache
28
Stefan Esser • iOS 678 Security - A Study In Fail • March 2015 • 
enable-dylibs-to-override-cache
• a flag file in /System/Library/Caches/com.apple.dyld
• when present libraries on disk will be loaded instead of a cached copy
• used by jailbreaks to trick dyld into loading
• malicious libmis.dylib into AMFID
• malicious list of launchd daemons xpcd_cache.dylib into launchctl
29
Stefan Esser • iOS 678 Security - A Study In Fail • March 2015 • 
enable-dylibs-to-override-cache
• see how enable-dylibs-to-override-cache is in center of everything?
• without this element the whole chain would have been destroyed
30
Stefan Esser • iOS 678 Security - A Study In Fail • March 2015 • 
enable-dylibs-to-override-cache
• first abused in iOS 7.0 jailbreak by evad3rs (December 2013)
• without it the whole exploit chains of all jailbreaks since then would have fallen apart
• after 14 months still unfixed
• from a strategic standpoint it is unbelievable that Apple did not fix this
• by not fixing this for 14 months Apple made persistence on device easier
• fixing this bug would have made iOS far more secure than the 

security by obscurity patches that Apple implemented to stop

the root filesystem from being writable or the team identifier hack
31
Stefan Esser • iOS 678 Security - A Study In Fail • March 2015 • 
Patient Alpha
(incomplete codesigning)
32
Stefan Esser • iOS 678 Security - A Study In Fail • March 2015 • 
Incomplete Codesigning
• simplified:
• if a page is not executable a missing code sig is not a problem
• if a page is executable there must be a code sig on first access
• prior to iOS 5 therefore jailbreaks would use ALL DATA dylibs to
exploit dyld via various meta-data structures
• around the end of iOS 4 Apple added checks to dyld to enforce load
commands are in an executable segment
• therefore while header parsing (first access) code sig is required
33
Stefan Esser • iOS 678 Security - A Study In Fail • March 2015 • 
mach-o dynamic library loading
• mach-o dynamic libraries loaded by dyld
• load commands describe i.a. layout of
segments in memory
• virtual address and 

virtual size of segments
• file position and 

file size of segment
34
Stefan Esser • iOS 678 Security - A Study In Fail • March 2015 • 
Ohhh really?
• actually it is not that simple
• mach-o header is first loaded into stack
• initial LC parse is performed to collect info
• this info is used to map the file into memory
• segments are touched to enforce code sig
• another LC parse is performed to make dyld
use the mach-o header from paged memory
• more and more parsing
35
Stefan Esser • iOS 678 Security - A Study In Fail • March 2015 • 
evad3rs come along
• and then the evad3rs came along
• for evasi0n (iOS 6) they used a 

TOCTOU trick to bypass the checks
• attack logic between
sniffLoadCommands and
crashIfInvalidCodesignature
• just trick mapSegments
36
Stefan Esser • iOS 678 Security - A Study In Fail • March 2015 • 
mapSegments
• mapSegments uses mmap()
• mmap allows to override previous mappings
• just have two mappings at same virtual address
• 1st contains LC and is R+X
• 2nd contains fake LC and is R / RW
• therefore at time of later access to page it will not
require a code signature
37
Stefan Esser • iOS 678 Security - A Study In Fail • March 2015 • 
Apple’s first fix
• Apple added a detection for 

overlapping segments
• code tests LC segment against all others so
that it does not get overlapped by other
segment
• test uses virtual address and virtual size
38
Stefan Esser • iOS 678 Security - A Study In Fail • March 2015 • 
Problem with Apple’s first fix
• the security check by Apple did not account for
integer wraps
• a segment with vmaddr at end of address space
and wrapping around is not detected as
overlapping
• in reality the mapping is not wrapping around the
address space due to being slid for ASLR
39
Stefan Esser • iOS 678 Security - A Study In Fail • March 2015 • 
Apple’s second fix
• Apple added a detection for LC segment
wrapping around
• such a setup will be detected and disallowed
40
Stefan Esser • iOS 678 Security - A Study In Fail • March 2015 • 
Problem with Apple’s second fix
• the integer wrap check was only done on the 

LC segment
• just doing the same trick again but letting the other
segment wrap around would still do the trick
• what was Apple thinking?
41
Stefan Esser • iOS 678 Security - A Study In Fail • March 2015 • 
Apple’s third fix
• Apple added a detection for other segments
wrapping around
• such a setup will now also be detected and
disallowed
42
Stefan Esser • iOS 678 Security - A Study In Fail • March 2015 • 
Problem with Apple’s third fix
• all these battles by Apple security with Chinese
jailbreakers were for nothing
• the security checks by Apple all did detect
overlaps by checking vmaddr + vmsize
• however mapSegments never used vmsize
• mapping into memory uses filesize
• filesize could be a lot larger than vmsize
• overlapping would never be detected
43
Stefan Esser • iOS 678 Security - A Study In Fail • March 2015 • 
Apple’s fourth fix
• Apple now detects when filesize is bigger
than vmsize
• such segments are now forbidden
• they now added a number of other checks
that also killed another bypass by accident
(will be disclosed in my blog)
• it took Apple only 2 years to realise this ;-)
44
• DISCLAIMER: I am absolutely NOT claiming that this is the end
Stefan Esser • iOS 678 Security - A Study In Fail • March 2015 • 
mach_port_kobject
45
Stefan Esser • iOS 678 Security - A Study In Fail • March 2015 • 
mach_port_kobject
• debugging Mach API call
• returns kobject associated with a mach port
• kobject filled with different values depending on type of port
• IOKit object ports: a kernel heap address containing a function table
• Host ports: address of realhost variable in kernel
• other ports: something else
• SECURITY PROBLEM: leaked addresses very useful for exploitation
46
*typep = (unsigned int) ip_kotype(port);
kaddr = (mach_vm_address_t)port->ip_kobject;
ip_unlock(port);
if (0 != kaddr && is_ipc_kobject(*typep))
*addrp = kaddr;
else
*addrp = 0;
Stefan Esser • iOS 678 Security - A Study In Fail • March 2015 • 
Fix 1
47
Stefan Esser • iOS 678 Security - A Study In Fail • March 2015 • 
mach_port_kobject in iOS 6.0
• Apple added kernel address obfuscation
• random 32 / 64 bit secret vm_kernel_addrperm
• added to all returned addresses
• should stop leakage of valid kernel pointers
48
*typep = (unsigned int) ip_kotype(port);
kaddr = (mach_vm_address_t)port->ip_kobject;
ip_unlock(port);
if (0 != kaddr && is_ipc_kobject(*typep))
*addrp = VM_KERNEL_ADDRPERM(VM_KERNEL_UNSLIDE(kaddr));
else
*addrp = 0;
Stefan Esser • iOS 678 Security - A Study In Fail • March 2015 • 
Weakness of ADD Obfuscation
• all returned addresses are obfuscated with the same secret summand
• ADDR + SECRET = OBFUSCATED_ADDR
• a single pair of ADDR and its OBFUSCATED_ADDR break the security
• if SECRET is known all obfuscated addresses can be easily decrypted
49
Stefan Esser • iOS 678 Security - A Study In Fail • March 2015 • 
Houston we have a problem …
• Remember this?
• kobject filled with different values depending on type of port
• IOKit object ports: a kernel heap address containing a function table
• Host ports: address of realhost variable in kernel
• other ports: something else
• SECURITY PROBLEM: 

we know realhost’s address and can break obfuscation
50
we know
plain address of
this variable
therefore we can break obfuscation
Stefan Esser • iOS 678 Security - A Study In Fail • March 2015 • 
Fix 2
51
Stefan Esser • iOS 678 Security - A Study In Fail • March 2015 • 
mach_port_kobject in iOS 8.0
• Apple now detects pointers inside kernel and does not obfuscate
• stops attack via e.g. host ports
52
*typep = (unsigned int) ip_kotype(port);
kaddr = (mach_vm_address_t)port->ip_kobject;
ip_unlock(port);
if (0 != kaddr && is_ipc_kobject(*typep))
*addrp = VM_KERNEL_UNSLIDE_OR_PERM(kaddr);
else
*addrp = 0;
Stefan Esser • iOS 678 Security - A Study In Fail • March 2015 • 
Houston we have a problem …
• Remember this?
• kobject filled with different values depending on type of port
• IOKit object ports: a kernel heap address containing a function table
• Host ports: address of realhost variable in kernel
• other ports: something else
• master ports: the value of kobject is 1
• SECURITY PROBLEM:

Obfuscation secret is mach_port_kobject(master)-1
53
Stefan Esser • iOS 678 Security - A Study In Fail • March 2015 • 
Fun Fact
• master port attack was taught to Pangu in SektionEins’ iOS training
• Pangu used it in their jailbreak in June 2014
• This means this attack was used in public 3 MONTHS before iOS 8.0 release*
• TaiG reused this trick in November 2014 for their jailbreak
54
* this means when fix 2 was released to public this was already known to be insufficient
Stefan Esser • iOS 678 Security - A Study In Fail • March 2015 • 
Fix 3
55
Stefan Esser • iOS 678 Security - A Study In Fail • March 2015 • 
mach_port_kobject in iOS 8.1.3
• Apple released iOS 8.1.3 at end of January
• they fixed the problem the Apple’s wayTM
• they just removed the function altogether
• removing the function took them ONLY 7 MONTHS
• This bug was assigned CVE-2014-4496 and Apple wrongly credits TaiG for it
56
Stefan Esser • iOS 678 Security - A Study In Fail • March 2015 • 
kext_request
57
Stefan Esser • iOS 678 Security - A Study In Fail • March 2015 • 
kext_request()
• Mach API call
• allows applications to request information about kernel modules
• active operations are locked down (load, unload, start, stop, …)
• passive operations partially working from even within the sandbox
• Apple fixed it to unslide load addresses to protect against KASLR leaks
58
Stefan Esser • iOS 678 Security - A Study In Fail • March 2015 • 
kext_request() - Get Loaded Kext Info
• of special interest is a sub request called
• Get Loaded Kext Info
• returns a serialised dictionary with information about all loaded Kext
• information contained includes the mach-o headers
• Apple even modifies those headers to protect KASLR
59
Stefan Esser • iOS 678 Security - A Study In Fail • March 2015 • 
kext_request() - Get Loaded Kext Info
60
mach_msg_type_number_t reqlen, resplen = 0, loglen = 0;
char *request, *response = NULL, *log = NULL;
kern_return_t kr;
request =
"<dict><key>Kext Request Predicate</key><string>Get Loaded Kext Info</string></dict>";
reqlen = strlen(request) + 1;
kext_request(mach_host_self(), 0, request, reqlen, &response,
&resplen, &log, &loglen, &kr);
Stefan Esser • iOS 678 Security - A Study In Fail • March 2015 • 
kext_request() - iPhone 6plus / iOS 8.0.2
61
<dict ID="0"><key>__kernel__</key><dict ID="1"><key>OSBundleMachOHeaders</key><data ID="2">z/rt/gwAAAEAAAAAAgAAAA
8AAABACwAAAQAgAAAAAAAZAAAAOAEAAF9fVEVYVAAAAAAAAAAAAAAAIAACgP///wAgSAAAAAAAAAAAAAAAAAAAIEgAAAAAAAUAAAAFA
AAAAwAAAAAAAABfX3RleHQAAAAAAAAAAAAAX19URVhUAAAAAAAAAAAAAAAwAAKA////rCJCAAAAAAAAEAAADAAAAAAAAAAAAAAAAAQAgAAAAAA
AAAAAAAAAAF9fY29uc3QAAAAAAAAAAABfX1RFWFQAAAAAAAAAAAAAwFJCAoD///9oYAIAAAAAAMAyQgAFAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAX19jc3RyaW5nAAAAAAAAAF9fVEVYVAAAAAAAAAAAAAAos0QCgP///2h
+AwAAAAAAKJNEAAAAAAAAAAAAAAAAAAIAAAAAAAAAAAAAAAAAAAAZAAAAyAIAAF9fREFUQQAAAAAAAAAAAAAAQEgCgP///
wBACwAAAAAAACBIAAAAAAAAwAQAAAAAAAMAAAADAAAACAAAAAAAAABfX21vZF9pbml0X2Z1bmMAX19EQVRBAAAAAAAAAAAAAABASAKA////
CAIAAAAAAAAAIEgAAwAAAAAAAAAAAAAACQAAAAAAAAAAAAAAAAAAAF9fbW9kX3Rlcm1fZnVuYwBfX0RBVEEAAAAAAAAAAAAACEJIAoD///
8AAgAAAAAAAAgiSAADAAAAAAAAAAAAAAAKAAAAAAAAAAAAAAAAAAAAX19jb25zdAAAAAAAAAAAAF9fREFUQQAAAAAAAAAAAAAQREgCgP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AAAAABkAAACYAAAAX19QUkVMSU5LX0lORk8AAADAzBOA////
AFAIAAAAAAAAMCYBAAAAAPhPCAAAAAAAAwAAAAMAAAABAAAAAAAAAF9faW5mbwAAAAAAAAAAAABfX1BSRUxJTktfSU5GTwAAAMDME4D////
4TwgAAAAAAAAwJgEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAGQAAAEgAAABfX0xJTktFRElUAAAAAAAAALDzEoD///
94eQUAAAAAAAAgTQAAAAAAeHkFAAAAAAABAAAAAQAAAAAAAAAAAAAAAgAAABgAAADwnU8AnhAAANCnUACo8QEACwAAAFAAAAAAAAAAAAAAAAAAAACeEAAAn
hAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACBNAPVHAAAbAAAAGAAAAPke8gf2KzpJlbujQoICCjclAAAAEAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAWIANAoD///8AAAAAAAAAACYAAAAQAAAAqF9PAEg+AAA=
</data><key>OSBundleCPUType</key><integer size="32" ID="3">0x100000c</integer><key>OSBundleCPUSubtype</key><integer size="32"
ID="4">0x0</
integer><key>CFBundleIdentifier</key><string ID="5">__kernel__</string><key>CFBundleVersion</key><string
ID="6">14.0.0</string><key>OSBundleUUID</key><data ID="7">+R7yB/YrOkmVu6NCggIKNw==</data><key>OSKernelResource</
key><true/><key>OSBundleIsInterface</key><false/><key>OSBundlePrelinked</key><false/><key>OSBundleStarted</key><true/
><key>OSBundleLoadTag</key><integer size="32" ID="8">0x0</integer><key>OSBundleLoadAddress</key><integer size="64"
ID="9">0xffffff8002002000</integer><key>OSBundleLoadSize</key>
Stefan Esser • iOS 678 Security - A Study In Fail • March 2015 • 
kext_request() vs. Mark Dowd
• so in October 2012 Mark Dowd disclosed that Apple forgot to unslide
addresses in mach-o section defintion
• Apple released a fix in iOS 6.0.1
• so KASLR was easy to defeat in iOS 6.0
• at this point everyone was auditing this function
62
I was informed by Mark Dowd
that disclosure of bug
was actually done by Tarjei Mandt.
So I am sorry for crediting it to the wrong person :)
Stefan Esser • iOS 678 Security - A Study In Fail • March 2015 • 
However …
• however there were ADDITIONAL bugs
• macro Apple used did only unslide main kernel and
pre-loaded kernel extensions
• but there are parts in the kernelcache that were in
between and therefore not unslid
• leaks KASLR slide once again => KASLR broken
63
#define VM_KERNEL_UNSLIDE(_v) 
((VM_KERNEL_IS_SLID(_v) || 
VM_KERNEL_IS_KEXT(_v)) ? 
(vm_offset_t)(_v) - vm_kernel_slide : 
(vm_offset_t)(_v))
#define VM_KERNEL_IS_SLID(_o) 
(((vm_offset_t)(_o) >= vm_kernel_base) && 
((vm_offset_t)(_o) < vm_kernel_top))
#define VM_KERNEL_IS_KEXT(_o) 
(((vm_offset_t)(_o) >= vm_kext_base) && 
((vm_offset_t)(_o) < vm_kext_top))
Stefan Esser • iOS 678 Security - A Study In Fail • March 2015 • 
Apple Releases a Fix
• end of January 2015 Apple releases iOS 8.1.3 to fix this
• fixed it the Apple way: they remove the OSBundleMachOHeaders altogether
• but they lie about it in the release announcement (claim it was fixed/not removed)
• took them only more than 2 years to realize this 2nd vulnerability
• and only 7 months from it being publicly used in a jailbreak
• people in training saw this within 10 min when checking out fix for Dowd’s 2012 bug
64
Tarjei Mandt's
Stefan Esser • iOS 678 Security - A Study In Fail • March 2015 • 
one more thing
65
Stefan Esser • iOS 678 Security - A Study In Fail • March 2015 • 
one more thing
• Of course all of these bugs also apply to OS X
• so no surprise that Apple fixed kext_request() in OS X 10.10.2
• but for 10.10.2 they keep the OSBundleMachOHeaders and try to do it correctly
66
Stefan Esser • iOS 678 Security - A Study In Fail • March 2015 • 
one more thing
• at this point it might not surprise the audience anymore
• kext_request KASLR info leak is still not fully fixed in Mac OS X 10.10.2
• the slide still leaks through the contained OSBundleMachOHeaders
• reason is that they use < instead of <= in the code
• therefore __LAST::__last (the last kernel symbol) is not unslid
67
#define VM_KERNEL_UNSLIDE(_v) 
((VM_KERNEL_IS_SLID(_v) || 
VM_KERNEL_IS_KEXT(_v)) ? 
(vm_offset_t)(_v) - vm_kernel_slide : 
(vm_offset_t)(_v))
#define VM_KERNEL_IS_SLID(_o) 
(((vm_offset_t)(_o) >= vm_kernel_base) && 
((vm_offset_t)(_o) < vm_kernel_top))
#define VM_KERNEL_IS_KEXT(_o) 
(((vm_offset_t)(_o) >= vm_kext_base) && 
((vm_offset_t)(_o) < vm_kext_top))
Stefan Esser • iOS 678 Security - A Study In Fail • March 2015 • 
Jailbreak made in China
68
Stefan Esser • iOS 678 Security - A Study In Fail • March 2015 • 
Jailbreak made in China
• there has been a change in guard
• recent Jailbreaks are no longer developed by “Westeners”
• now Chinese teams seem to rule the scene
• but why?
69
Stefan Esser • iOS 678 Security - A Study In Fail • March 2015 • 
Jailbreak made in China - Why?
• “Western” Jailbreak developers
• shared a lot of tools and techniques
• now have to deal with exploit export control regulations
• worked hard for nearly nothing (few donations)
• while information security companies made millions of their work
• on top of that had to deal with greedy JB community
70
Stefan Esser • iOS 678 Security - A Study In Fail • March 2015 • 
Jailbreak made in China - Why?
• “Chinese” Jailbreak developers
• are paid by Chinese companies with app
stores ( e.g. 1 Mio USD )
• use money to buy vulnerabilities /
exploits ( from the west )
• use questionable methods like stolen
enterprise certificates
• use public & non public code ignoring
software licenses / copyright
71
at the moment I have no permission to disclose identity of jailbreaker who wrote this
if you can offer 100.000 USD for buying a vulnerability / exploit this means you must get a lot for the end product
Stefan Esser • iOS 678 Security - A Study In Fail • March 2015 • 
Jailbreak made in China - and Apple
• so far “Chinese” Jailbreakers
• had a lucky time because of Apple security’s total lack of QA
• have mostly relied on techniques invented by westerners
• could reuse the same vulnerabilities over and over
72
Stefan Esser • iOS 678 Security - A Study In Fail • March 2015 • 
Jailbreak made in China - Community
• so far “Chinese” Jailbreakers have
• not released any code to advance the iOS research community
• instead have heavily obfuscated their jailbreaks
• intentionally removed patches to hinder work of other researchers
• have destructive kernel patches that overwrite part of kernel binary
• they are in it for the money and don’t want competition
73
Stefan Esser • iOS 678 Security - A Study In Fail • March 2015 • 
Conclusion
74
Stefan Esser • iOS 678 Security - A Study In Fail • March 2015 • 
Conclusion
• looking at how Apple security fails over and over again shows they are
not taking it seriously and have no QA on their security fixes AT ALL.
• Basically Apple Security’s failed patches made the Chinese jb possible
• IMHO the fact that media is celebrating Jailbreaks instead of taking
them as what they are: exploits for vulnerabilities is partly the reason
why Apple does not take fixing them seriously
• media should stress the fact that every unfixed jailbreak makes it CHEAP
for state sponsored attackers to spy on people
• actually it has been shown that several iOS surveillance tools fully rely
on release of public jailbreaks
75
Stefan Esser • iOS 678 Security - A Study In Fail • March 2015 • 
Questions
?
76

Weitere ähnliche Inhalte

Was ist angesagt?

Securing AEM webapps by hacking them
Securing AEM webapps by hacking themSecuring AEM webapps by hacking them
Securing AEM webapps by hacking themMikhail Egorov
 
Hacking Adobe Experience Manager sites
Hacking Adobe Experience Manager sitesHacking Adobe Experience Manager sites
Hacking Adobe Experience Manager sitesMikhail Egorov
 
Pentesting iOS Applications
Pentesting iOS ApplicationsPentesting iOS Applications
Pentesting iOS Applicationsjasonhaddix
 
Introduction to iOS Development
Introduction to iOS DevelopmentIntroduction to iOS Development
Introduction to iOS DevelopmentAsim Rais Siddiqui
 
iOS Application Static Analysis - Deepika Kumari.pptx
iOS Application Static Analysis - Deepika Kumari.pptxiOS Application Static Analysis - Deepika Kumari.pptx
iOS Application Static Analysis - Deepika Kumari.pptxdeepikakumari643428
 
Intro to Pentesting Jenkins
Intro to Pentesting JenkinsIntro to Pentesting Jenkins
Intro to Pentesting JenkinsBrian Hysell
 
OS X Drivers Reverse Engineering
OS X Drivers Reverse EngineeringOS X Drivers Reverse Engineering
OS X Drivers Reverse EngineeringPositive Hack Days
 
Braavos Wallet Workshop.pdf
Braavos Wallet Workshop.pdfBraavos Wallet Workshop.pdf
Braavos Wallet Workshop.pdfTinaBregovi
 
Android pentesting the hackers-meetup
Android pentesting the hackers-meetupAndroid pentesting the hackers-meetup
Android pentesting the hackers-meetupkunwaratul hax0r
 
MacOS memory allocator (libmalloc) Exploitation
MacOS memory allocator (libmalloc) ExploitationMacOS memory allocator (libmalloc) Exploitation
MacOS memory allocator (libmalloc) ExploitationAngel Boy
 
HTTP Security Headers Every Java Developer Must Know
HTTP Security Headers Every Java Developer Must KnowHTTP Security Headers Every Java Developer Must Know
HTTP Security Headers Every Java Developer Must KnowAyoma Wijethunga
 
Hunting for security bugs in AEM webapps
Hunting for security bugs in AEM webappsHunting for security bugs in AEM webapps
Hunting for security bugs in AEM webappsMikhail Egorov
 
Racing The Web - Hackfest 2016
Racing The Web - Hackfest 2016Racing The Web - Hackfest 2016
Racing The Web - Hackfest 2016Aaron Hnatiw
 
Fuzzing: The New Unit Testing
Fuzzing: The New Unit TestingFuzzing: The New Unit Testing
Fuzzing: The New Unit TestingDmitry Vyukov
 
DAIS19: On the Performance of ARM TrustZone
DAIS19: On the Performance of ARM TrustZoneDAIS19: On the Performance of ARM TrustZone
DAIS19: On the Performance of ARM TrustZoneLEGATO project
 
Android Security & Penetration Testing
Android Security & Penetration TestingAndroid Security & Penetration Testing
Android Security & Penetration TestingSubho Halder
 

Was ist angesagt? (20)

Securing AEM webapps by hacking them
Securing AEM webapps by hacking themSecuring AEM webapps by hacking them
Securing AEM webapps by hacking them
 
Hacking Adobe Experience Manager sites
Hacking Adobe Experience Manager sitesHacking Adobe Experience Manager sites
Hacking Adobe Experience Manager sites
 
Secure coding practices
Secure coding practicesSecure coding practices
Secure coding practices
 
Pentesting iOS Applications
Pentesting iOS ApplicationsPentesting iOS Applications
Pentesting iOS Applications
 
Introduction to iOS Development
Introduction to iOS DevelopmentIntroduction to iOS Development
Introduction to iOS Development
 
iOS Application Static Analysis - Deepika Kumari.pptx
iOS Application Static Analysis - Deepika Kumari.pptxiOS Application Static Analysis - Deepika Kumari.pptx
iOS Application Static Analysis - Deepika Kumari.pptx
 
Intro to Pentesting Jenkins
Intro to Pentesting JenkinsIntro to Pentesting Jenkins
Intro to Pentesting Jenkins
 
OS X Drivers Reverse Engineering
OS X Drivers Reverse EngineeringOS X Drivers Reverse Engineering
OS X Drivers Reverse Engineering
 
Braavos Wallet Workshop.pdf
Braavos Wallet Workshop.pdfBraavos Wallet Workshop.pdf
Braavos Wallet Workshop.pdf
 
Android pentesting the hackers-meetup
Android pentesting the hackers-meetupAndroid pentesting the hackers-meetup
Android pentesting the hackers-meetup
 
MacOS memory allocator (libmalloc) Exploitation
MacOS memory allocator (libmalloc) ExploitationMacOS memory allocator (libmalloc) Exploitation
MacOS memory allocator (libmalloc) Exploitation
 
HTTP Security Headers Every Java Developer Must Know
HTTP Security Headers Every Java Developer Must KnowHTTP Security Headers Every Java Developer Must Know
HTTP Security Headers Every Java Developer Must Know
 
iOS jailbreaking
iOS jailbreakingiOS jailbreaking
iOS jailbreaking
 
Hunting for security bugs in AEM webapps
Hunting for security bugs in AEM webappsHunting for security bugs in AEM webapps
Hunting for security bugs in AEM webapps
 
Racing The Web - Hackfest 2016
Racing The Web - Hackfest 2016Racing The Web - Hackfest 2016
Racing The Web - Hackfest 2016
 
Hacking and Securing iOS Applications
Hacking and Securing iOS ApplicationsHacking and Securing iOS Applications
Hacking and Securing iOS Applications
 
Fuzzing: The New Unit Testing
Fuzzing: The New Unit TestingFuzzing: The New Unit Testing
Fuzzing: The New Unit Testing
 
DAIS19: On the Performance of ARM TrustZone
DAIS19: On the Performance of ARM TrustZoneDAIS19: On the Performance of ARM TrustZone
DAIS19: On the Performance of ARM TrustZone
 
VolgaCTF 2018 - Neatly bypassing CSP
VolgaCTF 2018 - Neatly bypassing CSPVolgaCTF 2018 - Neatly bypassing CSP
VolgaCTF 2018 - Neatly bypassing CSP
 
Android Security & Penetration Testing
Android Security & Penetration TestingAndroid Security & Penetration Testing
Android Security & Penetration Testing
 

Ähnlich wie SyScan 2015 - iOS 678 Security - A Study in Fail

iOS 6 Exploitation 280 days later
iOS 6 Exploitation 280 days lateriOS 6 Exploitation 280 days later
iOS 6 Exploitation 280 days laterWang Hao Lee
 
CanSecWest 2013 - iOS 6 Exploitation 280 Days Later
CanSecWest 2013 - iOS 6 Exploitation 280 Days LaterCanSecWest 2013 - iOS 6 Exploitation 280 Days Later
CanSecWest 2013 - iOS 6 Exploitation 280 Days LaterStefan Esser
 
iOS 6 Exploitation: 280 days later
iOS 6 Exploitation: 280 days lateriOS 6 Exploitation: 280 days later
iOS 6 Exploitation: 280 days laterSeguridad Apple
 
Antid0te 2.0 – ASLR in iOS
Antid0te 2.0 – ASLR in iOSAntid0te 2.0 – ASLR in iOS
Antid0te 2.0 – ASLR in iOSSeguridad Apple
 
OWASP Melbourne - Introduction to iOS Application Penetration Testing
OWASP Melbourne - Introduction to iOS Application Penetration TestingOWASP Melbourne - Introduction to iOS Application Penetration Testing
OWASP Melbourne - Introduction to iOS Application Penetration Testingeightbit
 
Ruxmon April 2014 - Introduction to iOS Penetration Testing
Ruxmon April 2014 - Introduction to iOS Penetration TestingRuxmon April 2014 - Introduction to iOS Penetration Testing
Ruxmon April 2014 - Introduction to iOS Penetration Testingeightbit
 
Attacking and Defending Apple iOS Devices
Attacking and Defending Apple iOS DevicesAttacking and Defending Apple iOS Devices
Attacking and Defending Apple iOS DevicesTom Eston
 
Targeting the iOS kernel
Targeting the iOS kernelTargeting the iOS kernel
Targeting the iOS kernelSeguridad Apple
 
SyScan Singapore 2011 - Stefan Esser - Targeting the iOS Kernel
SyScan Singapore 2011 - Stefan Esser - Targeting the iOS KernelSyScan Singapore 2011 - Stefan Esser - Targeting the iOS Kernel
SyScan Singapore 2011 - Stefan Esser - Targeting the iOS KernelStefan Esser
 
iOS Application Penetation Test
iOS Application Penetation TestiOS Application Penetation Test
iOS Application Penetation TestJongWon Kim
 
[OWASP Poland Day] Saving private token
[OWASP Poland Day] Saving private token[OWASP Poland Day] Saving private token
[OWASP Poland Day] Saving private tokenOWASP
 
iOS Forensics: where are we now and what are we missing?
iOS Forensics: where are we now and what are we missing?iOS Forensics: where are we now and what are we missing?
iOS Forensics: where are we now and what are we missing?Reality Net System Solutions
 
Toorcon 2010: IPhone Rootkits? There's an App for That
Toorcon 2010: IPhone Rootkits? There's an App for ThatToorcon 2010: IPhone Rootkits? There's an App for That
Toorcon 2010: IPhone Rootkits? There's an App for ThatEric Monti
 
SyScan360 - Stefan Esser - OS X El Capitan sinking the S\H/IP
SyScan360 - Stefan Esser - OS X El Capitan sinking the S\H/IPSyScan360 - Stefan Esser - OS X El Capitan sinking the S\H/IP
SyScan360 - Stefan Esser - OS X El Capitan sinking the S\H/IPStefan Esser
 
iOS and BlackBerry Forensics
iOS and BlackBerry ForensicsiOS and BlackBerry Forensics
iOS and BlackBerry ForensicsAndrey Belenko
 
Exploring Your Apple M1 devices with Open Source Tools
Exploring Your Apple M1 devices with Open Source ToolsExploring Your Apple M1 devices with Open Source Tools
Exploring Your Apple M1 devices with Open Source ToolsKoan-Sin Tan
 
Evaluating iOS Applications
Evaluating iOS ApplicationsEvaluating iOS Applications
Evaluating iOS Applicationsiphonepentest
 
iOS Ecosystem @ Fiera del Radioamatore Pordenone
iOS Ecosystem @ Fiera del Radioamatore PordenoneiOS Ecosystem @ Fiera del Radioamatore Pordenone
iOS Ecosystem @ Fiera del Radioamatore PordenoneKlaus Lanzarini
 
Vulnerability, exploit to metasploit
Vulnerability, exploit to metasploitVulnerability, exploit to metasploit
Vulnerability, exploit to metasploitTiago Henriques
 
Webhooks with Azure Functions - Live 360 Conference
Webhooks with Azure Functions - Live 360 ConferenceWebhooks with Azure Functions - Live 360 Conference
Webhooks with Azure Functions - Live 360 ConferenceSparkPost
 

Ähnlich wie SyScan 2015 - iOS 678 Security - A Study in Fail (20)

iOS 6 Exploitation 280 days later
iOS 6 Exploitation 280 days lateriOS 6 Exploitation 280 days later
iOS 6 Exploitation 280 days later
 
CanSecWest 2013 - iOS 6 Exploitation 280 Days Later
CanSecWest 2013 - iOS 6 Exploitation 280 Days LaterCanSecWest 2013 - iOS 6 Exploitation 280 Days Later
CanSecWest 2013 - iOS 6 Exploitation 280 Days Later
 
iOS 6 Exploitation: 280 days later
iOS 6 Exploitation: 280 days lateriOS 6 Exploitation: 280 days later
iOS 6 Exploitation: 280 days later
 
Antid0te 2.0 – ASLR in iOS
Antid0te 2.0 – ASLR in iOSAntid0te 2.0 – ASLR in iOS
Antid0te 2.0 – ASLR in iOS
 
OWASP Melbourne - Introduction to iOS Application Penetration Testing
OWASP Melbourne - Introduction to iOS Application Penetration TestingOWASP Melbourne - Introduction to iOS Application Penetration Testing
OWASP Melbourne - Introduction to iOS Application Penetration Testing
 
Ruxmon April 2014 - Introduction to iOS Penetration Testing
Ruxmon April 2014 - Introduction to iOS Penetration TestingRuxmon April 2014 - Introduction to iOS Penetration Testing
Ruxmon April 2014 - Introduction to iOS Penetration Testing
 
Attacking and Defending Apple iOS Devices
Attacking and Defending Apple iOS DevicesAttacking and Defending Apple iOS Devices
Attacking and Defending Apple iOS Devices
 
Targeting the iOS kernel
Targeting the iOS kernelTargeting the iOS kernel
Targeting the iOS kernel
 
SyScan Singapore 2011 - Stefan Esser - Targeting the iOS Kernel
SyScan Singapore 2011 - Stefan Esser - Targeting the iOS KernelSyScan Singapore 2011 - Stefan Esser - Targeting the iOS Kernel
SyScan Singapore 2011 - Stefan Esser - Targeting the iOS Kernel
 
iOS Application Penetation Test
iOS Application Penetation TestiOS Application Penetation Test
iOS Application Penetation Test
 
[OWASP Poland Day] Saving private token
[OWASP Poland Day] Saving private token[OWASP Poland Day] Saving private token
[OWASP Poland Day] Saving private token
 
iOS Forensics: where are we now and what are we missing?
iOS Forensics: where are we now and what are we missing?iOS Forensics: where are we now and what are we missing?
iOS Forensics: where are we now and what are we missing?
 
Toorcon 2010: IPhone Rootkits? There's an App for That
Toorcon 2010: IPhone Rootkits? There's an App for ThatToorcon 2010: IPhone Rootkits? There's an App for That
Toorcon 2010: IPhone Rootkits? There's an App for That
 
SyScan360 - Stefan Esser - OS X El Capitan sinking the S\H/IP
SyScan360 - Stefan Esser - OS X El Capitan sinking the S\H/IPSyScan360 - Stefan Esser - OS X El Capitan sinking the S\H/IP
SyScan360 - Stefan Esser - OS X El Capitan sinking the S\H/IP
 
iOS and BlackBerry Forensics
iOS and BlackBerry ForensicsiOS and BlackBerry Forensics
iOS and BlackBerry Forensics
 
Exploring Your Apple M1 devices with Open Source Tools
Exploring Your Apple M1 devices with Open Source ToolsExploring Your Apple M1 devices with Open Source Tools
Exploring Your Apple M1 devices with Open Source Tools
 
Evaluating iOS Applications
Evaluating iOS ApplicationsEvaluating iOS Applications
Evaluating iOS Applications
 
iOS Ecosystem @ Fiera del Radioamatore Pordenone
iOS Ecosystem @ Fiera del Radioamatore PordenoneiOS Ecosystem @ Fiera del Radioamatore Pordenone
iOS Ecosystem @ Fiera del Radioamatore Pordenone
 
Vulnerability, exploit to metasploit
Vulnerability, exploit to metasploitVulnerability, exploit to metasploit
Vulnerability, exploit to metasploit
 
Webhooks with Azure Functions - Live 360 Conference
Webhooks with Azure Functions - Live 360 ConferenceWebhooks with Azure Functions - Live 360 Conference
Webhooks with Azure Functions - Live 360 Conference
 

Kürzlich hochgeladen

WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsRoshan Dwivedi
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilV3cube
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 

Kürzlich hochgeladen (20)

WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 

SyScan 2015 - iOS 678 Security - A Study in Fail

  • 1. iOS 678 Security
 —== A Study in Fail ==— Stefan Esser <stefan.esser@sektioneins.de> http://www.sektioneins.de
  • 2. Stefan Esser • iOS 678 Security - A Study In Fail • March 2015 •  Who am I? Stefan Esser • from Cologne / Germany • in information security since 1998 • invested in PHP security from 2001 to 20xx • since 2010 focused on iPhone security (ASLR/jailbreak) • founder of SektionEins GmbH 2
  • 3. Stefan Esser • iOS 678 Security - A Study In Fail • March 2015 •  Lots of Fail, but this talk is not about … • Apple releasing an iOS 8.0.1 update that would kill cell service on iPhone 6/6p • Apple adding unsecured double linked lists as meta-data to the iOS 7 kernel heap that made kernel heap exploitation easy (safe unlink in iOS 8) • Apple “improving” their iOS 7 early random number generator so that Tarjei Mandt would totally rip it apart and calculate all past and future numbers • Apple having a double “goto fail” in their SSL for iOS 6 - iOS 7.0.5 that broke it completely • … so yes I am skipping a lot of fail but what I cover is already too much for 45 minutes 3
  • 4. Stefan Esser • iOS 678 Security - A Study In Fail • March 2015 •  So what is it about? this talk is about iOS jailbreaks and Apple fixing the bugs within 4
  • 5. Stefan Esser • iOS 678 Security - A Study In Fail • March 2015 •  Fixing Bugs … 5
  • 6. Stefan Esser • iOS 678 Security - A Study In Fail • March 2015 •  BUT APPLE SECURITY AIN’T NO JEDI 6 BUT APPLE SECURITY AIN’T NO JEDI
  • 7. Stefan Esser • iOS 678 Security - A Study In Fail • March 2015 •  So actually … this talk is about iOS jailbreaks and Apple not fixing the bugs within 7
  • 8. Stefan Esser • iOS 678 Security - A Study In Fail • March 2015 •  Before we start … what are the ingredients of an iOS jailbreak? 8
  • 9. Stefan Esser • iOS 678 Security - A Study In Fail • March 2015 •  Ingredients Initial Injection Vector Persistency 9
  • 10. Stefan Esser • iOS 678 Security - A Study In Fail • March 2015 •  Not talking about that Initial Injection Vector but apparently Apple had to issue several updates to fix those bugs, too 10
  • 11. Stefan Esser • iOS 678 Security - A Study In Fail • March 2015 •  Concentrating on Jailbreak Persistency 11
  • 12. Stefan Esser • iOS 678 Security - A Study In Fail • March 2015 •  Jailbreak Persistency (I) • why concentrate on persistency? • attack surface for injection is just extremely = huge no chance of win • injection vectors for iOS can be easily exchanged • USB, mobile safari, malicious apps • some injections would require more powerful kernel bugs than public jailbreaks, but those do exist and are traded in the underground 12
  • 13. Stefan Esser • iOS 678 Security - A Study In Fail • March 2015 •  Jailbreak Persistency (II) • attack surface for jailbreak persistency is in comparison extremely small • could be made even smaller and smaller if Apple would do it right • i just want the public to pressure Apple into changing • PUBLIC PERSISTENCE EXPLOITS CAN BE EASILY REUSED IN STATE SPONSORED ATTACKS = LOT CHEAPER + NOT WASTE BUGS 13
  • 14. Stefan Esser • iOS 678 Security - A Study In Fail • March 2015 •  AMFI trickery 14
  • 15. Stefan Esser • iOS 678 Security - A Study In Fail • March 2015 •  AMFI Trickery • whole story starts with the exploit chain evad3rs “invented” for iOS 6 • for signature verification • kernel asks AMFI driver • AMFI driver asks AMFID user space daemon • AMFID uses libmis.dylib • Attack: 
 inject a malicious library into AMFID that makes libmis.dylib return “true” 15
  • 16. Stefan Esser • iOS 678 Security - A Study In Fail • March 2015 •  Injecting a malicious dylib AMFI attack • injecting malicious dylib / replacing libmis.dylib not as easy at it sounds • need to trick dynamic linker into attempting to do it • need to trick dynamic linker into accepting a not signed library • Idea: 
 use launch daemon config + DYLD_INSERT_LIBRARIES for first part
 use incomplete codesigning bypass for second part 16
  • 17. Stefan Esser • iOS 678 Security - A Study In Fail • March 2015 •  Putting the full chain together 17
  • 18. Stefan Esser • iOS 678 Security - A Study In Fail • March 2015 •  Apple “trying” to fix evasi0n • launchd.conf no longer loaded • __restrict in AMFID stops DYLD_INSERT_LIBRARIES • apply patch to fix incomplete code signing bypass (patient ALPHA) • fix kernel info leak and memory corruption 18
  • 19. Stefan Esser • iOS 678 Security - A Study In Fail • March 2015 •  evad3rs needed new tricks • patch of incomplete code signing trick (patient ALPHA) required new incomplete code signing trick ➡ evad3rs unnecessarily burned a new vulnerability some gave to them • __restrict in AMFID required new way to replace/inject library ➡ just use dyld feature enable-dylibs-to-override-cache
 (makes dyld load a replacement library instead of original one) 19
  • 20. Stefan Esser • iOS 678 Security - A Study In Fail • March 2015 •  evad3rs needed new tricks (II) • removal of launchd.conf required trick to inject launch daemons beside launch daemon codesigning • just use previous two also load a malicious xpcd_cache.dylib • kernel bugs required to be replaced • they just used some new bugs (because there are plenty) 20
  • 21. Stefan Esser • iOS 678 Security - A Study In Fail • March 2015 •  New chain for evasi0n 7 21
  • 22. Stefan Esser • iOS 678 Security - A Study In Fail • March 2015 •  Apple fixing evasi0n7 *LESS AGGRESSIVE* • new incomplete codesigning bypass trick fixed • kernel bugs are fixed • rest of chain is left completely untouched 22
  • 23. Stefan Esser • iOS 678 Security - A Study In Fail • March 2015 •  Pangu7 Jailbreak • Pangu realised that original bug Patient ALPHA was fixed incorrectly • used new kernel bugs 23 DejaVu
  • 24. Stefan Esser • iOS 678 Security - A Study In Fail • March 2015 •  Apple “trying to fix” Pangu7 • they try to fix their broken fix for the codesigning • kernel bugs are claimed fixed • rest of chain is still completely untouched 24 DejaVu
  • 25. Stefan Esser • iOS 678 Security - A Study In Fail • March 2015 •  Pangu8 Jailbreak • Pangu realised that fix for fix for Patient ALPHA is still incorrect • also their kernel bugs were apparently not patched correctly 25 DejaVu
  • 26. Stefan Esser • iOS 678 Security - A Study In Fail • March 2015 •  Apple “trying to fix” Pangu8 • they try to fix their broken fix for the broken fix for the codesigning • kernel bugs are claimed fixed again • rest of chain is still completely untouched 26 DejaVu
  • 27. Stefan Esser • iOS 678 Security - A Study In Fail • March 2015 •  TaiG Jailbreak • Pangu TaiG realised that fix for fix for fix for Patient ALPHA is still incorrect • used other kernel bugs 27 DejaVu
  • 28. Stefan Esser • iOS 678 Security - A Study In Fail • March 2015 •  enable-dylibs-to-override-cache 28
  • 29. Stefan Esser • iOS 678 Security - A Study In Fail • March 2015 •  enable-dylibs-to-override-cache • a flag file in /System/Library/Caches/com.apple.dyld • when present libraries on disk will be loaded instead of a cached copy • used by jailbreaks to trick dyld into loading • malicious libmis.dylib into AMFID • malicious list of launchd daemons xpcd_cache.dylib into launchctl 29
  • 30. Stefan Esser • iOS 678 Security - A Study In Fail • March 2015 •  enable-dylibs-to-override-cache • see how enable-dylibs-to-override-cache is in center of everything? • without this element the whole chain would have been destroyed 30
  • 31. Stefan Esser • iOS 678 Security - A Study In Fail • March 2015 •  enable-dylibs-to-override-cache • first abused in iOS 7.0 jailbreak by evad3rs (December 2013) • without it the whole exploit chains of all jailbreaks since then would have fallen apart • after 14 months still unfixed • from a strategic standpoint it is unbelievable that Apple did not fix this • by not fixing this for 14 months Apple made persistence on device easier • fixing this bug would have made iOS far more secure than the 
 security by obscurity patches that Apple implemented to stop
 the root filesystem from being writable or the team identifier hack 31
  • 32. Stefan Esser • iOS 678 Security - A Study In Fail • March 2015 •  Patient Alpha (incomplete codesigning) 32
  • 33. Stefan Esser • iOS 678 Security - A Study In Fail • March 2015 •  Incomplete Codesigning • simplified: • if a page is not executable a missing code sig is not a problem • if a page is executable there must be a code sig on first access • prior to iOS 5 therefore jailbreaks would use ALL DATA dylibs to exploit dyld via various meta-data structures • around the end of iOS 4 Apple added checks to dyld to enforce load commands are in an executable segment • therefore while header parsing (first access) code sig is required 33
  • 34. Stefan Esser • iOS 678 Security - A Study In Fail • March 2015 •  mach-o dynamic library loading • mach-o dynamic libraries loaded by dyld • load commands describe i.a. layout of segments in memory • virtual address and 
 virtual size of segments • file position and 
 file size of segment 34
  • 35. Stefan Esser • iOS 678 Security - A Study In Fail • March 2015 •  Ohhh really? • actually it is not that simple • mach-o header is first loaded into stack • initial LC parse is performed to collect info • this info is used to map the file into memory • segments are touched to enforce code sig • another LC parse is performed to make dyld use the mach-o header from paged memory • more and more parsing 35
  • 36. Stefan Esser • iOS 678 Security - A Study In Fail • March 2015 •  evad3rs come along • and then the evad3rs came along • for evasi0n (iOS 6) they used a 
 TOCTOU trick to bypass the checks • attack logic between sniffLoadCommands and crashIfInvalidCodesignature • just trick mapSegments 36
  • 37. Stefan Esser • iOS 678 Security - A Study In Fail • March 2015 •  mapSegments • mapSegments uses mmap() • mmap allows to override previous mappings • just have two mappings at same virtual address • 1st contains LC and is R+X • 2nd contains fake LC and is R / RW • therefore at time of later access to page it will not require a code signature 37
  • 38. Stefan Esser • iOS 678 Security - A Study In Fail • March 2015 •  Apple’s first fix • Apple added a detection for 
 overlapping segments • code tests LC segment against all others so that it does not get overlapped by other segment • test uses virtual address and virtual size 38
  • 39. Stefan Esser • iOS 678 Security - A Study In Fail • March 2015 •  Problem with Apple’s first fix • the security check by Apple did not account for integer wraps • a segment with vmaddr at end of address space and wrapping around is not detected as overlapping • in reality the mapping is not wrapping around the address space due to being slid for ASLR 39
  • 40. Stefan Esser • iOS 678 Security - A Study In Fail • March 2015 •  Apple’s second fix • Apple added a detection for LC segment wrapping around • such a setup will be detected and disallowed 40
  • 41. Stefan Esser • iOS 678 Security - A Study In Fail • March 2015 •  Problem with Apple’s second fix • the integer wrap check was only done on the 
 LC segment • just doing the same trick again but letting the other segment wrap around would still do the trick • what was Apple thinking? 41
  • 42. Stefan Esser • iOS 678 Security - A Study In Fail • March 2015 •  Apple’s third fix • Apple added a detection for other segments wrapping around • such a setup will now also be detected and disallowed 42
  • 43. Stefan Esser • iOS 678 Security - A Study In Fail • March 2015 •  Problem with Apple’s third fix • all these battles by Apple security with Chinese jailbreakers were for nothing • the security checks by Apple all did detect overlaps by checking vmaddr + vmsize • however mapSegments never used vmsize • mapping into memory uses filesize • filesize could be a lot larger than vmsize • overlapping would never be detected 43
  • 44. Stefan Esser • iOS 678 Security - A Study In Fail • March 2015 •  Apple’s fourth fix • Apple now detects when filesize is bigger than vmsize • such segments are now forbidden • they now added a number of other checks that also killed another bypass by accident (will be disclosed in my blog) • it took Apple only 2 years to realise this ;-) 44 • DISCLAIMER: I am absolutely NOT claiming that this is the end
  • 45. Stefan Esser • iOS 678 Security - A Study In Fail • March 2015 •  mach_port_kobject 45
  • 46. Stefan Esser • iOS 678 Security - A Study In Fail • March 2015 •  mach_port_kobject • debugging Mach API call • returns kobject associated with a mach port • kobject filled with different values depending on type of port • IOKit object ports: a kernel heap address containing a function table • Host ports: address of realhost variable in kernel • other ports: something else • SECURITY PROBLEM: leaked addresses very useful for exploitation 46 *typep = (unsigned int) ip_kotype(port); kaddr = (mach_vm_address_t)port->ip_kobject; ip_unlock(port); if (0 != kaddr && is_ipc_kobject(*typep)) *addrp = kaddr; else *addrp = 0;
  • 47. Stefan Esser • iOS 678 Security - A Study In Fail • March 2015 •  Fix 1 47
  • 48. Stefan Esser • iOS 678 Security - A Study In Fail • March 2015 •  mach_port_kobject in iOS 6.0 • Apple added kernel address obfuscation • random 32 / 64 bit secret vm_kernel_addrperm • added to all returned addresses • should stop leakage of valid kernel pointers 48 *typep = (unsigned int) ip_kotype(port); kaddr = (mach_vm_address_t)port->ip_kobject; ip_unlock(port); if (0 != kaddr && is_ipc_kobject(*typep)) *addrp = VM_KERNEL_ADDRPERM(VM_KERNEL_UNSLIDE(kaddr)); else *addrp = 0;
  • 49. Stefan Esser • iOS 678 Security - A Study In Fail • March 2015 •  Weakness of ADD Obfuscation • all returned addresses are obfuscated with the same secret summand • ADDR + SECRET = OBFUSCATED_ADDR • a single pair of ADDR and its OBFUSCATED_ADDR break the security • if SECRET is known all obfuscated addresses can be easily decrypted 49
  • 50. Stefan Esser • iOS 678 Security - A Study In Fail • March 2015 •  Houston we have a problem … • Remember this? • kobject filled with different values depending on type of port • IOKit object ports: a kernel heap address containing a function table • Host ports: address of realhost variable in kernel • other ports: something else • SECURITY PROBLEM: 
 we know realhost’s address and can break obfuscation 50 we know plain address of this variable therefore we can break obfuscation
  • 51. Stefan Esser • iOS 678 Security - A Study In Fail • March 2015 •  Fix 2 51
  • 52. Stefan Esser • iOS 678 Security - A Study In Fail • March 2015 •  mach_port_kobject in iOS 8.0 • Apple now detects pointers inside kernel and does not obfuscate • stops attack via e.g. host ports 52 *typep = (unsigned int) ip_kotype(port); kaddr = (mach_vm_address_t)port->ip_kobject; ip_unlock(port); if (0 != kaddr && is_ipc_kobject(*typep)) *addrp = VM_KERNEL_UNSLIDE_OR_PERM(kaddr); else *addrp = 0;
  • 53. Stefan Esser • iOS 678 Security - A Study In Fail • March 2015 •  Houston we have a problem … • Remember this? • kobject filled with different values depending on type of port • IOKit object ports: a kernel heap address containing a function table • Host ports: address of realhost variable in kernel • other ports: something else • master ports: the value of kobject is 1 • SECURITY PROBLEM:
 Obfuscation secret is mach_port_kobject(master)-1 53
  • 54. Stefan Esser • iOS 678 Security - A Study In Fail • March 2015 •  Fun Fact • master port attack was taught to Pangu in SektionEins’ iOS training • Pangu used it in their jailbreak in June 2014 • This means this attack was used in public 3 MONTHS before iOS 8.0 release* • TaiG reused this trick in November 2014 for their jailbreak 54 * this means when fix 2 was released to public this was already known to be insufficient
  • 55. Stefan Esser • iOS 678 Security - A Study In Fail • March 2015 •  Fix 3 55
  • 56. Stefan Esser • iOS 678 Security - A Study In Fail • March 2015 •  mach_port_kobject in iOS 8.1.3 • Apple released iOS 8.1.3 at end of January • they fixed the problem the Apple’s wayTM • they just removed the function altogether • removing the function took them ONLY 7 MONTHS • This bug was assigned CVE-2014-4496 and Apple wrongly credits TaiG for it 56
  • 57. Stefan Esser • iOS 678 Security - A Study In Fail • March 2015 •  kext_request 57
  • 58. Stefan Esser • iOS 678 Security - A Study In Fail • March 2015 •  kext_request() • Mach API call • allows applications to request information about kernel modules • active operations are locked down (load, unload, start, stop, …) • passive operations partially working from even within the sandbox • Apple fixed it to unslide load addresses to protect against KASLR leaks 58
  • 59. Stefan Esser • iOS 678 Security - A Study In Fail • March 2015 •  kext_request() - Get Loaded Kext Info • of special interest is a sub request called • Get Loaded Kext Info • returns a serialised dictionary with information about all loaded Kext • information contained includes the mach-o headers • Apple even modifies those headers to protect KASLR 59
  • 60. Stefan Esser • iOS 678 Security - A Study In Fail • March 2015 •  kext_request() - Get Loaded Kext Info 60 mach_msg_type_number_t reqlen, resplen = 0, loglen = 0; char *request, *response = NULL, *log = NULL; kern_return_t kr; request = "<dict><key>Kext Request Predicate</key><string>Get Loaded Kext Info</string></dict>"; reqlen = strlen(request) + 1; kext_request(mach_host_self(), 0, request, reqlen, &response, &resplen, &log, &loglen, &kr);
  • 61. Stefan Esser • iOS 678 Security - A Study In Fail • March 2015 •  kext_request() - iPhone 6plus / iOS 8.0.2 61 <dict ID="0"><key>__kernel__</key><dict ID="1"><key>OSBundleMachOHeaders</key><data ID="2">z/rt/gwAAAEAAAAAAgAAAA 8AAABACwAAAQAgAAAAAAAZAAAAOAEAAF9fVEVYVAAAAAAAAAAAAAAAIAACgP///wAgSAAAAAAAAAAAAAAAAAAAIEgAAAAAAAUAAAAFA AAAAwAAAAAAAABfX3RleHQAAAAAAAAAAAAAX19URVhUAAAAAAAAAAAAAAAwAAKA////rCJCAAAAAAAAEAAADAAAAAAAAAAAAAAAAAQAgAAAAAA AAAAAAAAAAF9fY29uc3QAAAAAAAAAAABfX1RFWFQAAAAAAAAAAAAAwFJCAoD///9oYAIAAAAAAMAyQgAFAAAAAAAAAAAAA AAA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er size="32" ID="3">0x100000c</integer><key>OSBundleCPUSubtype</key><integer size="32" ID="4">0x0</ integer><key>CFBundleIdentifier</key><string ID="5">__kernel__</string><key>CFBundleVersion</key><string ID="6">14.0.0</string><key>OSBundleUUID</key><data ID="7">+R7yB/YrOkmVu6NCggIKNw==</data><key>OSKernelResource</ key><true/><key>OSBundleIsInterface</key><false/><key>OSBundlePrelinked</key><false/><key>OSBundleStarted</key><true/ ><key>OSBundleLoadTag</key><integer size="32" ID="8">0x0</integer><key>OSBundleLoadAddress</key><integer size="64" ID="9">0xffffff8002002000</integer><key>OSBundleLoadSize</key>
  • 62. Stefan Esser • iOS 678 Security - A Study In Fail • March 2015 •  kext_request() vs. Mark Dowd • so in October 2012 Mark Dowd disclosed that Apple forgot to unslide addresses in mach-o section defintion • Apple released a fix in iOS 6.0.1 • so KASLR was easy to defeat in iOS 6.0 • at this point everyone was auditing this function 62 I was informed by Mark Dowd that disclosure of bug was actually done by Tarjei Mandt. So I am sorry for crediting it to the wrong person :)
  • 63. Stefan Esser • iOS 678 Security - A Study In Fail • March 2015 •  However … • however there were ADDITIONAL bugs • macro Apple used did only unslide main kernel and pre-loaded kernel extensions • but there are parts in the kernelcache that were in between and therefore not unslid • leaks KASLR slide once again => KASLR broken 63 #define VM_KERNEL_UNSLIDE(_v) ((VM_KERNEL_IS_SLID(_v) || VM_KERNEL_IS_KEXT(_v)) ? (vm_offset_t)(_v) - vm_kernel_slide : (vm_offset_t)(_v)) #define VM_KERNEL_IS_SLID(_o) (((vm_offset_t)(_o) >= vm_kernel_base) && ((vm_offset_t)(_o) < vm_kernel_top)) #define VM_KERNEL_IS_KEXT(_o) (((vm_offset_t)(_o) >= vm_kext_base) && ((vm_offset_t)(_o) < vm_kext_top))
  • 64. Stefan Esser • iOS 678 Security - A Study In Fail • March 2015 •  Apple Releases a Fix • end of January 2015 Apple releases iOS 8.1.3 to fix this • fixed it the Apple way: they remove the OSBundleMachOHeaders altogether • but they lie about it in the release announcement (claim it was fixed/not removed) • took them only more than 2 years to realize this 2nd vulnerability • and only 7 months from it being publicly used in a jailbreak • people in training saw this within 10 min when checking out fix for Dowd’s 2012 bug 64 Tarjei Mandt's
  • 65. Stefan Esser • iOS 678 Security - A Study In Fail • March 2015 •  one more thing 65
  • 66. Stefan Esser • iOS 678 Security - A Study In Fail • March 2015 •  one more thing • Of course all of these bugs also apply to OS X • so no surprise that Apple fixed kext_request() in OS X 10.10.2 • but for 10.10.2 they keep the OSBundleMachOHeaders and try to do it correctly 66
  • 67. Stefan Esser • iOS 678 Security - A Study In Fail • March 2015 •  one more thing • at this point it might not surprise the audience anymore • kext_request KASLR info leak is still not fully fixed in Mac OS X 10.10.2 • the slide still leaks through the contained OSBundleMachOHeaders • reason is that they use < instead of <= in the code • therefore __LAST::__last (the last kernel symbol) is not unslid 67 #define VM_KERNEL_UNSLIDE(_v) ((VM_KERNEL_IS_SLID(_v) || VM_KERNEL_IS_KEXT(_v)) ? (vm_offset_t)(_v) - vm_kernel_slide : (vm_offset_t)(_v)) #define VM_KERNEL_IS_SLID(_o) (((vm_offset_t)(_o) >= vm_kernel_base) && ((vm_offset_t)(_o) < vm_kernel_top)) #define VM_KERNEL_IS_KEXT(_o) (((vm_offset_t)(_o) >= vm_kext_base) && ((vm_offset_t)(_o) < vm_kext_top))
  • 68. Stefan Esser • iOS 678 Security - A Study In Fail • March 2015 •  Jailbreak made in China 68
  • 69. Stefan Esser • iOS 678 Security - A Study In Fail • March 2015 •  Jailbreak made in China • there has been a change in guard • recent Jailbreaks are no longer developed by “Westeners” • now Chinese teams seem to rule the scene • but why? 69
  • 70. Stefan Esser • iOS 678 Security - A Study In Fail • March 2015 •  Jailbreak made in China - Why? • “Western” Jailbreak developers • shared a lot of tools and techniques • now have to deal with exploit export control regulations • worked hard for nearly nothing (few donations) • while information security companies made millions of their work • on top of that had to deal with greedy JB community 70
  • 71. Stefan Esser • iOS 678 Security - A Study In Fail • March 2015 •  Jailbreak made in China - Why? • “Chinese” Jailbreak developers • are paid by Chinese companies with app stores ( e.g. 1 Mio USD ) • use money to buy vulnerabilities / exploits ( from the west ) • use questionable methods like stolen enterprise certificates • use public & non public code ignoring software licenses / copyright 71 at the moment I have no permission to disclose identity of jailbreaker who wrote this if you can offer 100.000 USD for buying a vulnerability / exploit this means you must get a lot for the end product
  • 72. Stefan Esser • iOS 678 Security - A Study In Fail • March 2015 •  Jailbreak made in China - and Apple • so far “Chinese” Jailbreakers • had a lucky time because of Apple security’s total lack of QA • have mostly relied on techniques invented by westerners • could reuse the same vulnerabilities over and over 72
  • 73. Stefan Esser • iOS 678 Security - A Study In Fail • March 2015 •  Jailbreak made in China - Community • so far “Chinese” Jailbreakers have • not released any code to advance the iOS research community • instead have heavily obfuscated their jailbreaks • intentionally removed patches to hinder work of other researchers • have destructive kernel patches that overwrite part of kernel binary • they are in it for the money and don’t want competition 73
  • 74. Stefan Esser • iOS 678 Security - A Study In Fail • March 2015 •  Conclusion 74
  • 75. Stefan Esser • iOS 678 Security - A Study In Fail • March 2015 •  Conclusion • looking at how Apple security fails over and over again shows they are not taking it seriously and have no QA on their security fixes AT ALL. • Basically Apple Security’s failed patches made the Chinese jb possible • IMHO the fact that media is celebrating Jailbreaks instead of taking them as what they are: exploits for vulnerabilities is partly the reason why Apple does not take fixing them seriously • media should stress the fact that every unfixed jailbreak makes it CHEAP for state sponsored attackers to spy on people • actually it has been shown that several iOS surveillance tools fully rely on release of public jailbreaks 75
  • 76. Stefan Esser • iOS 678 Security - A Study In Fail • March 2015 •  Questions ? 76