Detection rules › Elastic

Suspicious Codesign Execution via Osacompile

Source
github.com/elastic/protections-artifacts

Detects the abnormal execution of the codesign binary via Osacompile to forcefully sign all contents of a bundle. Threat actors may use this technique to bypass code signing requirements.

MITRE ATT&CK coverage

Telemetry coverage

Rule body

[rule]
description = """
Detects the abnormal execution of the codesign binary via Osacompile to forcefully sign all contents of a bundle. Threat
actors may use this technique to bypass code signing requirements.
"""
id = "7d2a993e-967f-4abd-b53e-ac14fdd66ddb"
license = "Elastic License v2"
name = "Suspicious Codesign Execution via Osacompile"
os_list = ["macos"]
version = "1.0.9"

query = '''
process where event.type == "start" and event.action == "exec" and 
 process.name == "codesign" and
 process.args in ("--sign", "-s") and
 process.args in ("--force", "-f") and
 process.args in ("--deep") and
 ((process.parent.name == "osacompile") or (process.parent.name in ("bash", "sh", "zsh") and process.Ext.effective_parent.name like~ ("terminal", "codesign"))) and
 not process.Ext.effective_parent.executable like~ "/Volumes/PostgreSQL*/postgresql*.app/Contents/MacOS/PostgreSQL"
'''

min_endpoint_version = "8.16.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 = "T1059"
name = "Command and Scripting Interpreter"
reference = "https://attack.mitre.org/techniques/T1059/"
[[threat.technique.subtechnique]]
id = "T1059.004"
name = "Unix Shell"
reference = "https://attack.mitre.org/techniques/T1059/004/"



[threat.tactic]
id = "TA0002"
name = "Execution"
reference = "https://attack.mitre.org/tactics/TA0002/"

[internal]
min_endpoint_version = "8.16.0"

Stages and Predicates

Stage 1: process

process where event.type == "start" and event.action == "exec" and 
 process.name == "codesign" and
 process.args in ("--sign", "-s") and
 process.args in ("--force", "-f") and
 process.args in ("--deep") and
 ((process.parent.name == "osacompile") or (process.parent.name in ("bash", "sh", "zsh") and process.Ext.effective_parent.name like~ ("terminal", "codesign"))) and
 not process.Ext.effective_parent.executable like~ "/Volumes/PostgreSQL*/postgresql*.app/Contents/MacOS/PostgreSQL"

Exclusions

The rule actively suppresses these predicates.

FieldKindExcluded valuesSearch
process.Ext.effective_parent.executablewildcard/Volumes/PostgreSQL*/postgresql*.app/Contents/MacOS/PostgreSQLexcludes:process.Ext.effective_parent.executable field:"process.Ext.effective_parent.executable" value:"/Volumes/PostgreSQL*/postgresql*.app/Contents/MacOS/PostgreSQL"

Indicators

These rows show field, operator, and value matches.