Detection rules › Elastic
Suspicious Unload of Elastic Agent via Launchctl
Detects the abnormal unload of the Elastic Agent plist via the launchctl system binary. This activity can indicate an attempt to disable or destroy the agent's ability to continuously monitor system activity and may indicate a threat actors attempt to evade defenses and remain undetected or not be recorded while performing actions on their objective.
MITRE ATT&CK coverage
| Tactic | Techniques |
|---|---|
| Defense Impairment |
Rule body
[rule]
description = """
Detects the abnormal unload of the Elastic Agent plist via the launchctl system binary. This activity can indicate an
attempt to disable or destroy the agent's ability to continuously monitor system activity and may indicate a threat
actors attempt to evade defenses and remain undetected or not be recorded while performing actions on their objective.
"""
id = "4abdbb10-6653-4a3b-8e7a-9c4f9382f03b"
license = "Elastic License v2"
name = "Suspicious Unload of Elastic Agent via Launchctl"
os_list = ["macos"]
version = "1.0.24"
query = '''
process where event.type == "start" and
(
(
process.name == "launchctl" and
process.args : "unload" and
process.args like~ "*co.elastic.elastic-agent.plist"
) or
(
(process.name in ("sh", "zsh", "bash", "dash", "csh", "tcsh", "ksh", "tclsh", "fish") or process.name like "tclsh*") and
process.args == "-c" and
process.command_line like~ "*unload*co.elastic.elastic-agent.plist*"
)
) and not
process.parent.name == "elastic-agent" and not
process.parent.executable like~ ("/sbin/launchd",
"/Library/PrivilegedHelperTools/*",
"/Library/Application Support/Mosyle/MosyleMDM.app/Contents/MacOS/MosyleMDM",
"/usr/local/jamf/bin/jamf",
"/usr/bin/sudo") and not
process.Ext.effective_parent.executable like~ ("/System/Applications/Utilities/Terminal.app/Contents/MacOS/Terminal",
"/usr/local/jamf/bin/jamf",
"/usr/libexec/xpcproxy",
"/Library/Kandji/Kandji Agent.app/Contents/Helpers/Kandji Library Manager.app/Contents/MacOS/kandji-library-manager",
"/Library/PrivilegedHelperTools/com.todyl.SGNCoreHelper",
"/Library/Application Support/JAMF/Jamf.app/Contents/MacOS/JamfManagementService.app/Contents/MacOS/JamfManagementService",
"/Library/Elastic/Agent/data/elastic-agent*/elastic-agent.app/Contents/MacOS/elastic-agent",
"/Library/Application Support/JAMF/Jamf.app/Contents/MacOS/JamfDaemon.app/Contents/MacOS/JamfDaemon",
"/opt/jc/bin/jumpcloud-agent",
"/Library/Elastic/Agent/*",
"/Library/PrivilegedHelperTools/com.todyl.SGNCoreHelper",
"/Applications/NinjaRMMAgent/programfiles/ninjarmm-macagent",
"/Library/Intune/Microsoft Intune Agent.app/Contents/MacOS/IntuneMdmDaemon",
"/Library/Endgame/esensor",
"/Library/Application Support/Mosyle/MosyleMDM.app/Contents/MacOS/MosyleMDM",
"/Applications/iTerm.app/Contents/MacOS/iTerm2")
'''
min_endpoint_version = "8.11.0"
optional_actions = []
[[actions]]
action = "kill_process"
field = "process.entity_id"
state = 0
[[actions]]
action = "kill_process"
field = "process.parent.entity_id"
state = 0
[[threat]]
framework = "MITRE ATT&CK"
[[threat.technique]]
id = "T1562"
name = "Impair Defenses"
reference = "https://attack.mitre.org/techniques/T1562/"
[[threat.technique.subtechnique]]
id = "T1562.001"
name = "Disable or Modify Tools"
reference = "https://attack.mitre.org/techniques/T1562/001/"
[threat.tactic]
id = "TA0005"
name = "Defense Evasion"
reference = "https://attack.mitre.org/tactics/TA0005/"
[internal]
min_endpoint_version = "8.11.0"
Stages and Predicates
Stage 1: process
process where event.type == "start" and
(
(
process.name == "launchctl" and
process.args : "unload" and
process.args like~ "*co.elastic.elastic-agent.plist"
) or
(
(process.name in ("sh", "zsh", "bash", "dash", "csh", "tcsh", "ksh", "tclsh", "fish") or process.name like "tclsh*") and
process.args == "-c" and
process.command_line like~ "*unload*co.elastic.elastic-agent.plist*"
)
) and not
process.parent.name == "elastic-agent" and not
process.parent.executable like~ ("/sbin/launchd",
"/Library/PrivilegedHelperTools/*",
"/Library/Application Support/Mosyle/MosyleMDM.app/Contents/MacOS/MosyleMDM",
"/usr/local/jamf/bin/jamf",
"/usr/bin/sudo") and not
process.Ext.effective_parent.executable like~ ("/System/Applications/Utilities/Terminal.app/Contents/MacOS/Terminal",
"/usr/local/jamf/bin/jamf",
"/usr/libexec/xpcproxy",
"/Library/Kandji/Kandji Agent.app/Contents/Helpers/Kandji Library Manager.app/Contents/MacOS/kandji-library-manager",
"/Library/PrivilegedHelperTools/com.todyl.SGNCoreHelper",
"/Library/Application Support/JAMF/Jamf.app/Contents/MacOS/JamfManagementService.app/Contents/MacOS/JamfManagementService",
"/Library/Elastic/Agent/data/elastic-agent*/elastic-agent.app/Contents/MacOS/elastic-agent",
"/Library/Application Support/JAMF/Jamf.app/Contents/MacOS/JamfDaemon.app/Contents/MacOS/JamfDaemon",
"/opt/jc/bin/jumpcloud-agent",
"/Library/Elastic/Agent/*",
"/Library/PrivilegedHelperTools/com.todyl.SGNCoreHelper",
"/Applications/NinjaRMMAgent/programfiles/ninjarmm-macagent",
"/Library/Intune/Microsoft Intune Agent.app/Contents/MacOS/IntuneMdmDaemon",
"/Library/Endgame/esensor",
"/Library/Application Support/Mosyle/MosyleMDM.app/Contents/MacOS/MosyleMDM",
"/Applications/iTerm.app/Contents/MacOS/iTerm2")
Exclusions
The rule actively suppresses these predicates.
| Field | Kind | Excluded values | Search |
|---|---|---|---|
process.Ext.effective_parent.executable | wildcard | /System/Applications/Utilities/Terminal.app/Contents/MacOS/Terminal, /usr/local/jamf/bin/jamf, /usr/libexec/xpcproxy, /Library/Kandji/Kandji Agent.app/Contents/Helpers/Kandji Library Manager.app/Contents/MacOS/kandji-library-manager, /Library/PrivilegedHelperTools/com.todyl.SGNCoreHelper, /Library/Application Support/JAMF/Jamf.app/Contents/MacOS/JamfManagementService.app/Contents/MacOS/JamfManagementService, /Library/Elastic/Agent/data/elastic-agent*/elastic-agent.app/Contents/MacOS/elastic-agent, /Library/Application Support/JAMF/Jamf.app/Contents/MacOS/JamfDaemon.app/Contents/MacOS/JamfDaemon, /opt/jc/bin/jumpcloud-agent, /Library/Elastic/Agent/*, /Library/PrivilegedHelperTools/com.todyl.SGNCoreHelper, /Applications/NinjaRMMAgent/programfiles/ninjarmm-macagent, /Library/Intune/Microsoft Intune Agent.app/Contents/MacOS/IntuneMdmDaemon, /Library/Endgame/esensor, /Library/Application Support/Mosyle/MosyleMDM.app/Contents/MacOS/MosyleMDM, /Applications/iTerm.app/Contents/MacOS/iTerm2 | excludes:process.Ext.effective_parent.executable |
process.parent.executable | wildcard | /sbin/launchd, /Library/PrivilegedHelperTools/*, /Library/Application Support/Mosyle/MosyleMDM.app/Contents/MacOS/MosyleMDM, /usr/local/jamf/bin/jamf, /usr/bin/sudo | excludes:process.parent.executable |
process.parent.name | eq | elastic-agent | excludes:process.parent.name field:"process.parent.name" value:"elastic-agent" |
Indicators
These rows show field, operator, and value matches.
| Field | Kind | Values | Search |
|---|---|---|---|
event.type | eq |
| field:"event.type" kind:eq value:"start" |
process.args | eq |
| field:"process.args" kind:eq value:"-c" |
process.args | wildcard |
| field:"process.args" kind:wildcard |
process.command_line | wildcard |
| field:"CommandLine" kind:wildcard value:"*unload*co.elastic.elastic-agent.plist*" |
process.name | eq |
| field:"process_name" kind:eq value:"launchctl" |
process.name | in |
| field:"process_name" kind:in |
process.name | wildcard |
| field:"process_name" kind:wildcard value:"tclsh*" |