gxpc: Coresymbolication Sandbox / Jetsam Crash
Some of the symbol lookups are using the DebugSymbol Frida API. In most cases, this works well 😃
From script.js:
const __CFBinaryPlistCreate15 = DebugSymbol.fromName('__CFBinaryPlistCreate15').address;
const _xpc_connection_call_event_handler = DebugSymbol.fromName("_xpc_connection_call_event_handler").address;
This is necessary since the two non-exported symbols cannot be looked up using Module.getBaseAddress(). However, some hardened daemons like imagent don’t allow using the DebugSymbol API. This in turn crashes the daemon like this:
default 22:56:23.233756+0100 imagent [0xc68bb1930] activating connection: mach=true listener=false peer=false name=com.apple.coresymbolicationd
error 22:56:23.234062+0100 kernel Sandbox: imagent(441) deny(1) mach-lookup com.apple.coresymbolicationd
default 22:56:23.234492+0100 imagent [0xc68bb1930] failed to do a bootstrap look-up: xpc_error=[159: Unknown error: 159]
default 22:56:23.234539+0100 imagent [0xc68bb1930] invalidated after a failed init
error 22:56:23.234616+0100 imagent Invalid connection: com.apple.coresymbolicationd
default 22:56:30.745460+0100 kernel EXC_RESOURCE -> imagent[441] exceeded mem limit: InactiveHard 500 MB (fatal)
default 22:56:30.745614+0100 kernel memorystatus: killing process 441 [imagent] in high band ? (140) - memorystatus_available_pages: 78501
default 22:56:30.745631+0100 kernel imagent[441] Corpse allowed 1 of 5
Increasing the process memory limit does not help, this is just a follow-up error by Frida.
I haven’t found an elegant workaround yet 😦 What I did to get gxpc working again was to first attach to a process that allows lookups (like bluetoothd), use Frida for the lookup and then add this back to the script like so:
frida -U bluetoothd
[iPad::bluetoothd ]-> ptr(DebugSymbol.fromName("_xpc_connection_call_event_handler").address - Module.getBaseAddress('libxpc.dylib'))
"0xf98c"
[iPad::bluetoothd ]-> ptr(DebugSymbol.fromName("__CFBinaryPlistCreate15").address - Module.getBaseAddress('CoreFoundation'))
"0x7dbf4"
And then replace it for that particular iOS/iPadOS version within script.js:
const __CFBinaryPlistCreate15 = Module.getBaseAddress('CoreFoundation').add(0x7dbf4);
const _xpc_connection_call_event_handler = Module.getBaseAddress('libxpc.dylib').add(0xf98c);
Maybe this is useful for anyone who gets similar crashes 😃 And maybe there’s a more elegant workaround?
About this issue
- Original URL
- State: open
- Created 2 years ago
- Reactions: 1
- Comments: 17 (17 by maintainers)
Commits related to this issue
- fix: correct check of existing offsets #20 — committed to ReverseApple/gxpc by NSEcho 2 years ago
Since the speed is a major factor of course and this would speed work later, this is really great idea and because the logic for config file is there, I could easily extend it to make it save automatically.
Awesome, works for me!
I belive I have implemented it, let me know if everything is working okay.
The first step is to generate a config file calling
gxpc --initthat will creategxpc.conffile inside of user’s home directory, optionally you can pass--configor-cflag to pass custom location.Then simply obtain offset values using the method you provided in the first place by attaching to non-hardened service:
And populate the config file accordingly. You don’t need to worry about config file anymore because it will be read each time gxpc is run and it will check whether there are offsets defined for current os and machine.
Either that or maybe a configuration file. I could imagine two possibilities here:
I think that most people don’t use that many different jailbroken iOS versions, especially since downgrading is an issue.
Here is an example that I’m using now for some of my devices. Note that attaching to a daemon is now much faster, as most of the time of attaching to a process was the symbol lookup 🚀
AFAIK the DYLD shared cache has similar offsets for arm64 devices, and then another set of offsets for arm64e devices. However, I haven’t verified that, so maybe the safest option is to just provide one offset per device and build version.