This is the exploit code that has been played at Pwn2Own Vancouver 2023 (https://youtu.be/c0cS4R0ja-I?t=180).
This code exploits CVE-2023-32413 to gain root rights on any vulnerable macOS. The vulnerability is a logic TOCTOU that can be used to overwrite any file that can be read. The exploit is fast, 100% reliable, give a root shell AND display an animated ascii art (🥷🔪🍎).
The vulnerability has been patched in may 2023 but the associated (partial) SIP bypass was still present (CVE-2023-42914), this other bug has been fixed in december 2023.
More details can be found in the "Finding and Exploiting an Old XNU Logic Bug" presentation made at Hexacon 2023: https://www.synacktiv.ninja/sites/default/files/2024-11/finding_and_exploiting_an_old_xnu_logic_bug.pdf / https://www.youtube.com/watch?v=J2QR58JAO7Q