Detection rules › Elastic

Curl Execution via Application Shell Script

Time window
30s
Sequence by
process.parent.entity_id
Source
github.com/elastic/protections-artifacts

Detects the abnormal spawning of curl or nscurl by a shell script within an applications directory structure. Threat actors have executed and abused shell scripts within a benign applications directory structures in order to evade detection and download a second stage payload. This specific activity has been observed when the shell script creates a new shell child process ,via a fork, which is then used to execute curl or nscurl. The use of shell scripts within a macOS application to execute curl is highly abnormal espcially in this specific manner.

MITRE ATT&CK coverage

TacticTechniques
Command & Control

Telemetry coverage

Rule body

[rule]
description = """
Detects the abnormal spawning of curl or nscurl by a shell script within an applications directory structure. Threat
actors have executed and abused shell scripts within a benign applications directory structures in order to evade
detection and download a second stage payload. This specific activity has been observed when the shell script creates a
new shell child process ,via a fork, which is then used to execute curl or nscurl. The use of shell scripts within a
macOS application to execute curl is highly abnormal espcially in this specific manner.
"""
id = "fce1ba4a-596c-445c-938d-3ffd73152bf2"
license = "Elastic License v2"
name = "Curl Execution via Application Shell Script"
os_list = ["macos"]
reference = [
    "https://www.sentinelone.com/blog/from-the-front-lines-new-macos-covid-malware-masquerades-as-apple-wears-face-of-apt/",
    "https://github.com/D00MFist/Mystikal/blob/main/Modules/DMG.py",
]
version = "1.0.11"

query = '''
sequence by process.parent.entity_id with maxspan=30s
[process where event.type == "start" and event.action == "fork" and process.name like~ ("bash", "sh", "zsh", "tclsh*") and
  process.args_count == 2 and process.args like~ ("/Applications/*", "/Volumes/*", "/Users/*/Applications/*") and 
  process.parent.name like~ ("bash", "sh", "zsh", "tclsh*")]
[process where event.type == "start" and event.action == "exec" and process.name in ("curl", "nscurl") and
  process.args in ("-o", "--output", "-O", "--remote-name") and
  not process.args like~
              ("https://github.com/*",
               "http://localhost:*",
               "https://localhost:*",
               "https://download.elastic.co/cloud/elastic-cloud-enterprise.sh") and
  not process.args == "-X" and
  not process.args == "-H" and
  not process.args == "-d"]
'''

min_endpoint_version = "8.7.0"
optional_actions = []
[[actions]]
action = "kill_process"
field = "process.entity_id"
state = 1

[[actions]]
action = "kill_process"
field = "process.parent.entity_id"
state = 0

[[threat]]
framework = "MITRE ATT&CK"
[[threat.technique]]
id = "T1105"
name = "Ingress Tool Transfer"
reference = "https://attack.mitre.org/techniques/T1105/"


[threat.tactic]
id = "TA0011"
name = "Command and Control"
reference = "https://attack.mitre.org/tactics/TA0011/"

[internal]
min_endpoint_version = "8.7.0"

Stages and Predicates

Ordered sequence: each step below must occur in order within 30s, correlated by process.parent.entity_id.

Stage 1: process

[process where event.type == "start" and event.action == "fork" and process.name like~ ("bash", "sh", "zsh", "tclsh*") and
  process.args_count == 2 and process.args like~ ("/Applications/*", "/Volumes/*", "/Users/*/Applications/*") and 
  process.parent.name like~ ("bash", "sh", "zsh", "tclsh*")]

Stage 2: process

[process where event.type == "start" and event.action == "exec" and process.name in ("curl", "nscurl") and
  process.args in ("-o", "--output", "-O", "--remote-name") and
  not process.args like~
              ("https://github.com/*",
               "http://localhost:*",
               "https://localhost:*",
               "https://download.elastic.co/cloud/elastic-cloud-enterprise.sh") and
  not process.args == "-X" and
  not process.args == "-H" and
  not process.args == "-d"]

Exclusions

The rule actively suppresses these predicates.

FieldKindExcluded valuesSearch
process.argseq-Hexcludes:process.args field:"process.args" value:"-H"
process.argseq-Xexcludes:process.args field:"process.args" value:"-X"
process.argseq-dexcludes:process.args field:"process.args" value:"-d"
process.argswildcardhttps://github.com/*, http://localhost:*, https://localhost:*, https://download.elastic.co/cloud/elastic-cloud-enterprise.shexcludes:process.args

Indicators

These rows show field, operator, and value matches.