[CVE-2016-1824] Apple IOHIDFamily kernel race condition as root
Some weeks ago I found another race condition inside the extremely troubled IOHIDFamily kext module, which is one of the few modules that are actually opensource. You can grab a (outdated) version of the code here.
Today I reported it to Apple, and while waiting for a response, I tought it would be nice to write a post about it.
Background
As you may know, recently the XNU kernel and some IOKIT modules have been plagued by race condition issues. You can check out one also in our CanSecWest 16 presentation about Apple Graphics drivers, and some of them are present in the Project Zero issues tracker.
Basically the root cause of those issues is the lack of locking mechanisms, or wrong locks, in code that expects only well behaved, not concurrent access.
The bug
You can follow the vulnerable code here to have more informations than the snippets pasted here.
This action can be triggered from a usermode program if it has root privileges.
We will race this 2 statements:
If another thread access kernelQueue before the other one set it to NULL, bad things can happen, checkout Ian Beer’s similar issue for exploitability.
Crash PoC
To run it:
Timeline:
2016/4/10 The issue is reported to Apple via email at product-security@apple.com with 90 days responsible disclosure policy.
Sometimes vendors just fix the immediate problem and bug, and don’t investigate carefully about the root cause and search for additional bugs that share the same pattern.