Hacking The iPhone, iPod, And iPad With A Web Page

What Does Jailbreakme Do?

TH: So if jailbreakme.com didn’t provide a progress bar, could this have been done without the user’s awareness?

Charlie: Certainly. The jailbreakme Web site does not try to hide its actions. It is performing a service for the user. A malicious site would run this code in the background and you wouldn't know it.

TH: And if the payload was smaller, say sending passwords or personal information, it could have happened almost instantaneously?

Charlie: Yes. Making permanent changes to the phone, like jailbreaking, is time consuming. But stealing information like contacts, SMS messages, and emails would happen in less than a second.

TH: Let me put a black hat on for a second. How do we know that this vulnerability, which exists in previous versions of iOS, hasn’t been exploited in a targeted fashion somewhere? In June, we had the leak of over 100,000 iPad owners' email addresses, including CEOs and government officials. Could someone have sent one of them a link to a malicious site, which then installed spyware or other malicious code?

Charlie: There is no way to know whether this vulnerability has been exploited in the past.  

TH: Scary stuff. How can we be sure that no existing application available through the App Store does not somehow install a rootkit? We’ve seen SOCKS proxies sneak through the official App store in the past, and there’s the whole story of the Android Wallpaper App stealing private info?

Charlie: So…an App Store app could theoretically use the same privilege escalation exploit to break out of the sandbox and install malware. As a professional reverse engineer and code auditor, I can say that it would be impossible for Apple to audit all the applications that pass through the App Store. They can only do their best and try to restrict the API’s used by the applications, but this can be bypassed. Recently, someone included an application in the Android Marketplace that included a local privilege escalation exploit and rooted the phone.

TH: So it’s possible that an app could do this?

Charlie: It is possible that an app could do this, although as far as I know, no app in the App Store has ever done it.

TH: Why doesn’t the ARM XN-bit, also known as NX-bit or XD-bit, prevent overflows like this?

Charlie: Before Data Execution Prevention (DEP), buffer overflows would redirect execution of the process into user-injected code or shellcode. However, DEP forbids this, as the processor knows that the injected code is data, which is not supposed to be executed. As a way around this, exploits use what is known as return oriented programming (ROP). Here, instead of jumping to user-injected code, the exploit jumps to code from the actual process. In this case, code within MobileSafari and the libraries it needs. By reusing little bits of code from the process, the exploit is able to perform the actions necessary to do general purpose actions.  

TH: So, to understand this correctly, iOS does have some form of DEP, and this prevents arbitrary injection of user code. But the way around it is to use bits and pieces of legitimate code--the equivalent of a ransom note made out of cut up newspaper letters?

Charlie: Yes, the iOS implementation of DEP is very good. The ransom note analogy is a perfect analogy, originally attributed to rapper @drraid’s girlfriend. You take pieces of existing code and glue them together in a way that suits you, but wasn’t intended by the designer.

TH: What about technologies like ASLR and stack randomization? Would that have been a solution?

Charlie: Yes, in general, ASLR defeats return oriented programming by randomizing the location of the resident code, which the exploit would like to reuse. If the exploit cannot find the code to reuse, it cannot use ROP. iPhone does not have any ASLR; all addresses are completely known by an attacker if you know the firmware version of the device.

  • apache_lives
    Im more interested in Android being installed on the iPhone - looking quite interesting
  • who said apple is unbreakable? charlie miller is the man who can kick jobs ball just as easy everytime we visit his website. since I got the iphone4 I found that I had being holding my phone wrong the past 7 years. I have to learn the new way from apple the right way holding my phone but it drops often and hunts my hand too. 2 weeks ago I heard people telling me that my ipad got heatup problem in japan. I believe steve jobs trying to tell everyone in japan that they are holding their mp3 player wrong too after all.
  • orionite
    Very interesting article. I take content like this over "Man uses iPhone to cure cancer"-nonsense, any day.
  • victorintelr
    Charlie Miller never held it wrong.
  • randomizer
    See, real men use Macs.
  • rd350
    now if only this worked for a mac :P
  • Ragnar-Kon
    randomizerSee, real men use Macs.Oh you are going to get marked down... beware of the windoz trolls.

    Great interview by the way. I had always wondered how he did it, as I had always ran into a dead end when I realized Safari was not run as root. Turns out I was right and it required two exploits. Brilliant.
  • kelemvor4
    randomizerSee, real men use Macs.Real men often do what is trendy rather than what makes sense.
  • jakthebomb
    George Hotz was the first to hack the iPhone.
  • jecastej
    Great interview,

    I think Apple should use its big capital to hire and pay for more engineers to solve all kind of situations. It is not about problems surfacing everywhere or anytime as there are no warranties in real life. And I don't say this just to complain. Now that Apple has the "resources" it should use it on its "own" benefit and, of course, for the benefit of all its users.