macOS Frida Setup
On an M1 Mac, Frida needs some extra steps to be able to attach to system processes. Mainly writing this down here because it was spread across multiple GitHub issues. Hope it helps some of you who are working with Frida on M1 Macs :)
Versions
- macOS Ventura 13.0.1
- Frida 16.0.2
- Apple M1 Pro
Setup
- Disable System Integrity Protection (SIP). Power off Mac, power on with very long press to get the advanced boot options, open the Terminal from the Utilities, enter
# csrutil disable
... and confirm that this bricks your system's security. - Disable some dialogues popping up and asking for permissions, further reducing the security of your system with
# sudo security authorizationdb write system.privilege.taskport allow
... this might be optional but needed if you use Frida via SSH. - Change boot arguments as follows:
sudo nvram boot-args=-arm64e_preview_abi
... and reboot.
Now you should be able to attach to system services, e.g., run:
# frida identityservicesd
Update: macOS 14.4 and higher
Since the introduction of macOS 14.4, there are new mitigations that prevent Frida from attaching to macOS processes, even on SIP disabled systems. Following two tweets from CodeColorist and patch1t, here are further NVRAM arguments that need to be set:
# nvram boot-args="-arm64e_preview_abi amfi_get_out_of_my_way=1 thid_should_crash=0 tss_should_crash=0"
Without these boot arguments, the target process will crash with an error similar to this:
Crashed Thread: 1 frida-helper-main-loop
Exception Type: EXC_GUARD (SIGKILL)
Exception Codes: GUARD_TYPE_MACH_PORT
Exception Codes: 0x0000000000000000, 0x0000000000000000
Termination Reason: Namespace GUARD, Code 2305843030688530432
External Modification Warnings:
Process used task_for_pid().
Debugging
The first two steps are currently also described on the Frida website. Without the adjusted boot arguments, Frida quits with the following error message - apparently on M1 Macs only:
Failed to attach: unexpected error while starting thread (set_thread_state returned '(os/kern) protection failure')
Looking for frida in the Console app, there are three matching messages. The first is the command I ran, the next one is a sandbox error for _frida.abi3.so, and the last one is the one that hints towards the missing boot argument, as it complains about the arm64e preview abi.