Get root on macOS 12.3.1: proof-of-concepts for Linus Henze's CoreTrust and DriverKit bugs (CVE-2022-26766, CVE-2022-26763)
CoreTrust on macOS 12.3.1 never checked the root certificate of a code signature when no custom root was supplied, so anyone could sign an app with a self-made root and have it treated as a genuine Apple platform binary. A separate DriverKit bug let a driver pass an unchecked offset to a PCI memory write, causing a kernel panic. The author used the first to spawn a root shell with SIP enabled.
Published on worthdoingbadly.com
Here are two proof-of-concepts for CVE-2022-26766 (CoreTrust allows any root certificate) and CVE-2022-26763 (IOPCIDevice::MemoryAccess not checking bounds at all), two issues discovered by @LinusHenze and patched in macOS 12.4 / iOS 15.5.
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.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the root-certificate validation branch in X509ChainCheckPathWithOptions only ran when a custom root was supplied, leaving the production path with no check that the chain ends at an Apple root.
Impact
On macOS 12.3.1 an attacker could get a root shell with SIP still enabled by signing an app with a self-made certificate; the DriverKit bug only produced a kernel panic in the author's setup, which required SIP disabled and the built-in Bluetooth driver removed, and neither bug was shown to work on iOS.
What the attacker needed
MacOS 12.3.1 target; ability to run a signed app; for DriverKit: SIP disabled; for DriverKit: custom kernel cache
The fix
macOS 12.4 was fixed by adding a check that the root certificate is an authentic Apple root, and the PCI memory access functions were changed to bounds-check the offset and length.
How it was found
- Extract the real certificate chain from a signed system binary with codesign.
- Generate a three-certificate chain with OpenSSL, giving each certificate the Apple platform extension.
- Sign the demo app with the fake certificate and the chosen entitlement.
- Run the app on macOS 12.3.1 and observe a root shell.
- For the DriverKit bug, disable SIP and build a custom kernel cache without the Bluetooth drivers.
- Load the unsigned DriverKit driver, approve it, and invoke it to trigger the out-of-bounds PCI memory write and panic.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
When macOS launches an app it checks a digital signature, a bit like a wax seal that proves Apple made it. The checking code forgot to confirm that the top-level seal really belonged to Apple, so a forger could make their own seal and macOS believed it. The second bug is in a driver interface that writes to hardware memory without checking how far along it is writing, so a driver can scribble past the end and crash the machine.
What is Crypto?
Encryption, signatures, randomness or certificate checks that do not protect what they claim to.