Introduction
A couple of months ago, I have found Local Privilege Escalation vulnerability inside of CatoNetworks macOS application which is fixed in the version 5.4.0. We will see how to exploit the simple race condition in order to achieve escalation of privileges to root user.
Analysis
After examining ~/Library/LaunchDaemons/com.catonetworks.mac.CatoClient.helper.plist
we can see that the Mach service name is com.catonetworks.mac.client.daemon
and
the binary it runs is /Library/Application Support/CatoNetworks/com.catonetworks.mac.CatoClient.helper
. We will take a note of the Mach service name because we will need
it to communicate with the XPC service.
After we have obtained some limited information, we need to load the main binary in Hopper to analyze what is happening and to check whether there are any vulnerabilities.
Searching for listener:shouldAcceptNewConnection
revealed that the exported protocol is _TtP38com_catonetworks_mac_CatoClient_helper15CommandProtocol_
.
Running class dump showed that this protocol contains a single method - (void)installPackageAtPath:(NSString *)arg1 withCompletion:(void (^)(BOOL))arg2;
.
Based on the name, we can conclude that we need to provide the path to the .pkg
file and we can check whether we have succeeded or not based on the reply block.
If we now search for implementation of this method, we can see that it calls function sub_100002b7c
.