MacOS Installer Package Spawns Network Event

Detects the execution of a MacOS installer package with an abnormal child process (e.g bash) followed immediately by a network connection via a suspicious process (e.g curl). Threat actors will build and distribute malicious MacOS installer packages, which have a .pkg extension, many times imitating valid software in order to persuade and infect their victims often using the package files (e.g pre/post install scripts etc.) to download additional tools or malicious software. If this rule fires it should indicate the installation of a malicious or suspicious package.

Elastic rule (View on GitHub)

  1[metadata]
  2creation_date = "2021/02/23"
  3integration = ["endpoint"]
  4maturity = "production"
  5updated_date = "2024/05/21"
  6
  7[rule]
  8author = ["Elastic"]
  9description = """
 10Detects the execution of a MacOS installer package with an abnormal child process (e.g bash) followed immediately by a
 11network connection via a suspicious process (e.g curl). Threat actors will build and distribute malicious MacOS
 12installer packages, which have a .pkg extension, many times imitating valid software in order to persuade and infect
 13their victims often using the package files (e.g pre/post install scripts etc.) to download additional tools or
 14malicious software. If this rule fires it should indicate the installation of a malicious or suspicious package.
 15"""
 16false_positives = [
 17    """
 18    Custom organization-specific macOS packages that use .pkg files to run cURL could trigger this rule. If known
 19    behavior is causing false positives, it can be excluded from the rule.
 20    """,
 21]
 22from = "now-9m"
 23index = ["logs-endpoint.events.*"]
 24language = "eql"
 25license = "Elastic License v2"
 26name = "MacOS Installer Package Spawns Network Event"
 27references = [
 28    "https://redcanary.com/blog/clipping-silver-sparrows-wings",
 29    "https://posts.specterops.io/introducing-mystikal-4fbd2f7ae520",
 30    "https://github.com/D00MFist/Mystikal",
 31]
 32risk_score = 47
 33rule_id = "99239e7d-b0d4-46e3-8609-acafcf99f68c"
 34setup = """## Setup
 35
 36This rule requires data coming in from Elastic Defend.
 37
 38### Elastic Defend Integration Setup
 39Elastic Defend is integrated into the Elastic Agent using Fleet. Upon configuration, the integration allows the Elastic Agent to monitor events on your host and send data to the Elastic Security app.
 40
 41#### Prerequisite Requirements:
 42- Fleet is required for Elastic Defend.
 43- To configure Fleet Server refer to the [documentation](https://www.elastic.co/guide/en/fleet/current/fleet-server.html).
 44
 45#### The following steps should be executed in order to add the Elastic Defend integration on a macOS System:
 46- Go to the Kibana home page and click "Add integrations".
 47- In the query bar, search for "Elastic Defend" and select the integration to see more details about it.
 48- Click "Add Elastic Defend".
 49- Configure the integration name and optionally add a description.
 50- Select the type of environment you want to protect, for MacOS it is recommended to select "Traditional Endpoints".
 51- Select a configuration preset. Each preset comes with different default settings for Elastic Agent, you can further customize these later by configuring the Elastic Defend integration policy. [Helper guide](https://www.elastic.co/guide/en/security/current/configure-endpoint-integration-policy.html).
 52- We suggest selecting "Complete EDR (Endpoint Detection and Response)" as a configuration setting, that provides "All events; all preventions"
 53- Enter a name for the agent policy in "New agent policy name". If other agent policies already exist, you can click the "Existing hosts" tab and select an existing policy instead.
 54For more details on Elastic Agent configuration settings, refer to the [helper guide](https://www.elastic.co/guide/en/fleet/current/agent-policy.html).
 55- Click "Save and Continue".
 56- To complete the integration, select "Add Elastic Agent to your hosts" and continue to the next section to install the Elastic Agent on your hosts.
 57For more details on Elastic Defend refer to the [helper guide](https://www.elastic.co/guide/en/security/current/install-endpoint.html).
 58"""
 59severity = "medium"
 60tags = [
 61    "Domain: Endpoint",
 62    "OS: macOS",
 63    "Use Case: Threat Detection",
 64    "Tactic: Execution",
 65    "Tactic: Command and Control",
 66    "Data Source: Elastic Defend",
 67]
 68type = "eql"
 69
 70query = '''
 71sequence by host.id with maxspan=15s
 72[process where host.os.type == "macos" and event.type == "start" and event.action == "exec" and process.parent.name : ("installer", "package_script_service") and process.name : ("bash", "sh", "zsh", "python", "osascript", "tclsh*")] by process.entity_id
 73[network where host.os.type == "macos" and event.type == "start" and process.name : ("curl", "osascript", "wget", "python", "java", "ruby", "node")] by process.parent.entity_id
 74'''
 75
 76
 77[[rule.threat]]
 78framework = "MITRE ATT&CK"
 79[[rule.threat.technique]]
 80id = "T1059"
 81name = "Command and Scripting Interpreter"
 82reference = "https://attack.mitre.org/techniques/T1059/"
 83[[rule.threat.technique.subtechnique]]
 84id = "T1059.007"
 85name = "JavaScript"
 86reference = "https://attack.mitre.org/techniques/T1059/007/"
 87
 88
 89
 90[rule.threat.tactic]
 91id = "TA0002"
 92name = "Execution"
 93reference = "https://attack.mitre.org/tactics/TA0002/"
 94[[rule.threat]]
 95framework = "MITRE ATT&CK"
 96[[rule.threat.technique]]
 97id = "T1071"
 98name = "Application Layer Protocol"
 99reference = "https://attack.mitre.org/techniques/T1071/"
100[[rule.threat.technique.subtechnique]]
101id = "T1071.001"
102name = "Web Protocols"
103reference = "https://attack.mitre.org/techniques/T1071/001/"
104
105
106
107[rule.threat.tactic]
108id = "TA0011"
109name = "Command and Control"
110reference = "https://attack.mitre.org/tactics/TA0011/"

References

Related rules

to-top