Return value from the function is
not ES_RETURN_SUCCESS.
I tried filtering console logs by endpointsecurityd. There are no additional logs when mute fails.
I can reproduce this as follows. I have to leave it running and keep on launching processes. e.g. I launch Simulator (launch Safari inside it) from Xcode which seems to launch a lot of processes.
Code Block //subscribed to only ES_EVENT_TYPE_AUTH_OPEN |
es_new_client(&client, ^(es_client_t *, const es_message_t * message) { |
es_message_t *msg = es_copy_message(message); |
dispatch_async(dispatch_get_main_queue(), ^{ |
uint32_t fflags = 0xffffffff; |
es_respond_flags_result(client, msg, fflags, true); |
es_return_t res = es_mute_process(client, &msg->process->audit_token); |
if (res != ES_RETURN_SUCCESS) |
std::cout << "mute failed " << res << std::endl; |
es_free_message(msg); |
}); |
With following I was not able to reproduce the issue but the issue is intermittent so can't say for sure that it doesn't.
In a simple program I tried listing all processes and muted all (close to 400). There I don't see the error.
Ran this periodically at 1 sec interval, still no error.
Most processes for which I see error (some listed below) seem to be short lived.
So I also tried a simple program where
in open callback check if process is, say, Safari
copy its audit token from message
kill the process
in async dispatch block wait for 2 sec then mute the process
Even this succeeds.
Some of the processes for which I see mute failure, there are many more
/bin/bash
/usr/bin/su
/usr/bin/security
/usr/bin/dscl
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/usr/libexec/nsurlstoraged
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/PrivateFrameworks/TCC.framework/tccd
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/Frameworks/Security.framework/CircleJoinRequested/CircleJoinRequested