Detection rules › Elastic
Suspicious Codesign Execution via Osacompile
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
| Tactic | Techniques |
|---|---|
| Execution |
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.
| Field | Kind | Excluded values | Search |
|---|---|---|---|
process.Ext.effective_parent.executable | wildcard | /Volumes/PostgreSQL*/postgresql*.app/Contents/MacOS/PostgreSQL | excludes: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.
| Field | Kind | Values | Search |
|---|---|---|---|
event.action | eq |
| field:"EventType" kind:eq value:"exec" |
event.type | eq |
| field:"event.type" kind:eq value:"start" |
process.Ext.effective_parent.name | wildcard |
| field:"process.Ext.effective_parent.name" kind:wildcard |
process.args | in |
| field:"process.args" kind:in |
process.name | eq |
| field:"process_name" kind:eq value:"codesign" |
process.parent.name | eq |
| field:"parent_process_name" kind:eq value:"osacompile" |
process.parent.name | in |
| field:"parent_process_name" kind:in |