Um ein iPhone zu infizieren, genügte es, eine manipulierte Webseite zu besuchen.
Freitag, 30. August 2019
Unbemerkt beim Surfen
Googles Sicherheitsforscher finden heraus, dass iPhones jahrelang über manipulierte Webseiten gehackt und ausspioniert werden konnten. Die Angreifer hatten dabei praktisch volle Kontrolle über die Geräte und konnten nach Belieben Dateien, Fotos, Chats oder Zugangsdaten abgreifen.
Googles Project Zero hat Anfang des Jahres mehrere manipulierte Webseiten gefunden, über die es möglich war, iPhones mit Malware zu infizieren. Über sogenannte Implants war es den Angreifern nicht nur möglich, Daten oder Fotos zu kopieren und den Standort abzurufen. Sie hatten vollen Zugriff auf alle Bereiche der Geräte und konnten auch Nachrichten von Ende-zu-Ende-verschlüsselten Messengern wie iMessage, Whatsapp oder Telegram aus dem Code auslesen. Auch E-Mail-Apps waren für die Angreifer offene Bücher, und sie konnten sogar gespeicherte Zugangsdaten und Anmelde-Tokens aus dem iCloud-Schlüsselbund stehlen.
Kompliziert und teuer
Insgesamt machten die Sicherheitsforscher 14 Schwachstellen aus, die die Hacker für fünf Angriffsketten ausnutzten. Da die sogenannten Exploits ziemlich kompliziert sind und bei iPhones auf dem Schwarzmarkt sehr teuer gehandelt werden, vermutet das Project-Zero-Team, dass sie möglicherweise Geheimdiensten dazu dienten, bestimmte Bevölkerungsgruppen auszuspionieren. Dabei genügte es, die manipulierten Webseiten zu besuchen, eine weitere Aktion seitens der Opfer war nicht nötig, um das Implant zu platzieren.
Die Forscher gehen davon aus, dass die Kampagne mindestens zwei Jahre lang lief und Apples Betriebssystem von iOS 10 bis zu iOS 12 verwundbar war. Google informierte Apple am 1. Februar mit einer siebentägigen Frist, bis die Problematik öffentlich gemacht worden wäre. Apple veröffentlichte daraufhin am 7. Februar das Update auf iOS 12.1.4, um die Schwachstellen zu schließen. Die Forscher weisen darauf hin, dass mindestens eine der fünf Angriffsketten am Tag der Entdeckung noch nicht gepatched war, also ein sogenannter Zero-Day-Exploit war.
Gefahr nicht gebannt
Projektleiter Ian Peer schreibt, die Angreifer könnten immer noch großen Schaden anrichten, da sie ja immer noch im Besitz der erbeuteten Zugangsdaten und -Tokens seien. Außerdem sollte man sich im Klaren darüber sein, dass es mit großer Wahrscheinlichkeit noch ähnliche Hacker-Kampagnen gäbe, die bisher noch nicht entdeckt worden seien. Schutzmaßnahmen seien niemals ausreichend, wenn man zum Ziel erklärt wurde, schreibt Beer. Es könne genügen, einfach nur in einer bestimmten Region zu leben oder einer bestimmten ethnischen Gruppe anzugehören.
Dies sollte man immer im Hinterkopf behalten und sich entsprechend verhalten, rät Peer. Wenn Nutzer ihre Smartphones in ihr Leben integrierten und ihnen alles anvertrauten, könnten diese Informationen unter Umständen in einer Datenbank landen und gegen sie verwendet werden. Im konkreten Fall konnten Nutzer eines gekaperten iPhone die Spione ganz simpel durch einen Neustart loswerden. Das wird nicht immer so einfach sein.
Quelle: n-tv.de, kwe
from: https://www.n-tv.de/technik/iPhones-konnten-jahrelang-gehackt-werden-article21241759.html
***
Thursday, August 29, 2019
Implant Teardown
Posted by Ian Beer, Project Zero
In the earlier posts we examined how the attackers gained unsandboxed code execution as root on iPhones. At the end of each chain we saw the attackers calling posix_spawn, passing the path to their implant binary which they dropped in /tmp. This starts the implant running in the background as root. There is no visual indicator on the device that the implant is running. There’s no way for a user on iOS to view a process listing, so the implant binary makes no attempt to hide its execution from the system.
The implant is primarily focused on stealing files and uploading live location data. The implant requests commands from a command and control server every 60 seconds.
Before diving into the code let’s take a look at some sample data from a test phone running the implant and communicating with a custom command and control server I developed. To be clear, I created this test specifically for the purposes of demonstrating what the implant enabled the attacker to do and the screenshots are from my device. The device here is an iPhone 8 running iOS 12.
The implant has access to all the database files (on the victim’s phone) used by popular end-to-end encryption apps like Whatsapp, Telegram and iMessage. We can see here screenshots of the apps on the left, and on the right the contents of the database files stolen by the implant which contain the unencrypted, plain-text of the messages sent and received using the apps:
Whatsapp:
Telegram:
iMessage:
Hangouts:
Gmail:
Contacts:
The implant also takes copies of the user’s complete contacts database:
Photos:
And takes copies of all their photos:
Real-time GPS tracking:
The implant can also upload the user’s location in real time, up to once per minute, if the device is online. Here’s a real sample of live location data collected by the implant when I took a trip to Amsterdam with the implant running on a phone in my pocket:
The implant uploads the device’s keychain, which contains a huge number of credentials and certificates used on and by the device. For example, the SSIDs and passwords for all saved wifi access points:
The v_Data field is the plain-text password, stored as base64:
The keychain also contains the long-lived tokens used by services such as Google’s iOS Single-Sign-On to enable Google apps to access the user’s account. These will be uploaded to the attackers and can then be used to maintain access to the user’s Google account, even once the implant is no longer running. Here’s an example using the Google OAuth token stored as com.google.sso.optional.1.accessToken in the keychain being used to log in to the Gmail web interface on a separate machine:
Analysis
From our analysis of the exploits, we know that the fake kernel task port (which gives kernel memory read and write) is always destroyed at the end of the kernel exploit. The implant runs completely in userspace, albeit unsandboxed and as root with entitlements chosen by the attacker to ensure they can still access all the private data they are interested in.
Using jtool we can view the entitlements the implant has. Remember, the attackers have complete control over these as they used the kernel exploit to add the hash of the implant binary’s code signature to the kernel trust cache.
Many system services on iOS will try to check the entitlements of clients talking to them, and only allow clients with particular entitlements to perform certain actions. This is why, even though the implant is running as root and unsandboxed, it still requires a valid entitlements blob. They’re assigning themselves three relevant entitlements:
keychain-access-groups is used to restrict access to secrets stored in the keychain; they’ve given themselves a wildcard value here.
com.apple.locationd.preauthorized enables the use of CoreLocation without explicit user consent, as long as Location Services is enabled.
com.apple.coretelephony.Identity.get allows retrieval of the device’s phone number.
Reversing
Structure
The implant starts by creating an instance of the Service class and calling the start selector before getting a handle to the current runloop and running it.
[Service startTimer] will ensure that the Service instance’s timerHandle method is invoked every 60 seconds:
timer_handle is the main function responsible for handling the command and control communication. Before the device goes in to the timer_handle loop however it first does an initial upload:
This performs an initial bulk upload of data from the device. Let’s take a look at how these are implemented:
Note the call to NSLog is really there in the production implant. If you connect the iPhone via a lightning cable to a Mac and open Console.app you can see these log messages as the implant runs.
Here’s the output which gets sent to the server when the implant is run on one of my test devices:
This method collects a myriad of identifiers from the device:
- the iPhone model
- the iPhone name (“Ian’s iPhone”)
- the ICCID of the SIM card, which uniquely identifies the SIM
- the iPhone serial number
- the current phone number
- the iOS version
- total and free disk space
- the currently active network interface (wifi or cellular)
Let’s take a look at how that file will get off the device and up to the attacker’s server.
[Service uploadDevice] passes the returned @{@”device.plist”: path} dictionary to [Service postFiles]:
The IP address of the server to upload content to is hardcoded in the implant binary. This function uses that address to make an HTTP POST request, passing the contents of the files provided in the files argument as a multipart/form-data payload (with the hardcoded boundary string “9ff7172192b7” delimiting the fields in the body data.)
Let’s take a quick look at buildBodyDataWithParams:
This is just building a typical HTTP POST request body, embedding the contents of each file as form data.
There’s something thus far which is conspicuous only by its absence: is any of this encrypted? The short answer is no: they really do POST everything via HTTP (not HTTPS) and there is no asymmetric (or even symmetric) encryption applied to the data which is uploaded. Everything is in the clear. If you’re connected to an unencrypted WiFi network this information is being broadcast to everyone around you, to your network operator and any intermediate network hops to the command and control server.
This means that not only is the end-point of the end-to-end encryption offered by messaging apps compromised; the attackers then send all the contents of the end-to-end encrypted messages in plain text over the network to their server.
The command loop
NSTimer will ensure that the [Service timer_handle] method is called every 60 seconds:
[Service status] uses the SystemConfiguration framework to determine whether the device is currently connected via WiFi or mobile data network.
[Service cmds] calls [Service remotelist]:
This method makes an HTTP request to the /list endpoint on the command and control server and expects to receive a JSON-encoded object in the response. It parses that object using the system JSON library (NSJSONSerialization), expecting the JSON to be in the following form:
Each of the enclosed commands are passed in turn to [Service doCommand]:
This method takes a dictionary with a command and an optional data argument. Here’s a list of the supported commands:
Each command is responsible for uploading its results to the server. After each command is complete a GET request is made to the /list/suc?name=X endpoint, where X is the name of the command which completed. A cookie containing the device serial number is sent along with the GET request.
The majority of these commands work by creating tar archives of fixed lists of directories based on the desired information and the version of iOS which is running. Here, for example, is the implementation of the systemmail command:
This uses the [Util tarWithSplit] method to archive the contents of the /private/var/mobile/Library/Mail folder, which contains the contents of all locally-stored email sent and received with the built-in Apple Mail.app.
Here’s another example of a command, locate, which uses CoreLocation to request a geolocation fix for the device. Because the implant has the com.apple.locationd.preauthorized entitlement set to true this will not prompt the user for permission to access their location.
Here’s the response to the location command, which can be sent up to every 60 seconds (note: I have changed the location to be the peak of the Matterhorn in Switzerland):
App contents
These container directories are where most iOS apps store all their data; for example, this is where end-to-end encryption apps store unencrypted copies of all sent and received messages.
Here’s the pre-populated list of bundle identifiers for third-party apps, which will always have their container directories uploaded if the apps are installed:
If the attackers were interested in other apps installed on the device they could use a combination of the applist and app commands to get a listing of all installed app ids, then upload a particular app’s container directory by id. The allapp command will upload all the container directories for all apps on the device.
Impact
from: https://googleprojectzero.blogspot.com/2019/08/implant-teardown.html
You must be logged in to post a comment.