Suspicious Dylib Load from Temporary Directory
Description
Detects when a dylib is loaded from a temporary directory by a binary that is not located in the temporary directory as well. Dylibs on macOS are loaded from within the applications directory structure itself or the system frameworks or system libraries path. Loading a dylib from a place like /tmp is highly suspicious and should be considered a sign of malicious activity.
Query · eql
library where event.action == "load" and dll.path like ("/tmp/*", "/private/tmp/*") and
(dll.code_signature.exists == false or dll.code_signature.trusted == false) and
(process.code_signature.trusted == false or process.code_signature.exists == false) and
(process.executable like~ ("/Users/Shared/*",
"/private/var/root/*",
"/var/tmp/*",
"/var/lib/*",
"/var/root/*",
"/Library/WebServer/*",
"/Library/Graphics/*",
"/Library/Fonts/*") or
process.name like "com.apple.*")