Untrusted or Unsigned Binary Executed via Launch Service
Description
Detects when a Launch Agent or Launch Daemon is created in a common way by moving the plist into one of the two directories using the native cp or mv binaries and the plist arguments contain a common application path followed immediately by the execution of an untrusted or unsigned binary from that path. Threat actors will regularly get users to install untrusted or unsigned applications, usually impersonating a valid application, in a normal system location and the application will install a launch services persistence that looks generic and won't generally raise suspicion.
Query · eql
sequence with maxspan=30s
[persistence where event.action == "launch_daemon" and (process.name in ("cp", "mv", "sed") or (process.code_signature.trusted == false or process.code_signature.exists == false)) and
Persistence.args like~ ("/Library/Application Support/*", "/Applications/*", "/Users/*/Library/Application Support/*") and
not Effective_process.executable like "/Library/Kandji/Kandji Agent.app/Contents/Helpers/Kandji Library Manager.app/Contents/MacOS/kandji-library-manager"] as event0
[process where event.type == "start" and event.action == "exec" and startswith~(event0.Persistence.args, process.executable) and
(process.code_signature.exists == false or process.code_signature.trusted == false) and
not (process.parent.code_signature.team_id == "5C3VHX9RG5" and process.parent.code_signature.trusted == true) and
not process.Ext.effective_parent.executable like "/Library/Kandji/Kandji Agent.app/Contents/Helpers/Kandji Library Manager.app/Contents/MacOS/kandji-library-manager"]