Git Hook Child Process
This rule detects child processes spawned by Git hooks. Git hooks are scripts that Git executes before or after events such as commit, push, and receive. The rule identifies child processes spawned by Git hooks that are not typically spawned by the Git process itself. This behavior may indicate an attacker attempting to hide malicious activity by leveraging the legitimate Git process to execute unauthorized commands.
Elastic rule (View on GitHub)
1[metadata]
2creation_date = "2024/06/26"
3integration = ["endpoint"]
4maturity = "production"
5updated_date = "2024/09/23"
6
7[rule]
8author = ["Elastic"]
9description = """
10This rule detects child processes spawned by Git hooks. Git hooks are scripts that Git executes before or after events
11such as commit, push, and receive. The rule identifies child processes spawned by Git hooks that are not typically
12spawned by the Git process itself. This behavior may indicate an attacker attempting to hide malicious activity by
13leveraging the legitimate Git process to execute unauthorized commands.
14"""
15from = "now-9m"
16index = ["logs-endpoint.events.process*"]
17language = "eql"
18license = "Elastic License v2"
19name = "Git Hook Child Process"
20references = [
21 "https://git-scm.com/docs/githooks/2.26.0",
22 "https://www.elastic.co/security-labs/sequel-on-persistence-mechanisms",
23]
24risk_score = 21
25rule_id = "7ce5e1c7-6a49-45e6-a101-0720d185667f"
26setup = """## Setup
27
28This rule requires data coming in from Elastic Defend.
29
30### Elastic Defend Integration Setup
31Elastic 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.
32
33#### Prerequisite Requirements:
34- Fleet is required for Elastic Defend.
35- To configure Fleet Server refer to the [documentation](https://www.elastic.co/guide/en/fleet/current/fleet-server.html).
36
37#### The following steps should be executed in order to add the Elastic Defend integration on a Linux System:
38- Go to the Kibana home page and click "Add integrations".
39- In the query bar, search for "Elastic Defend" and select the integration to see more details about it.
40- Click "Add Elastic Defend".
41- Configure the integration name and optionally add a description.
42- Select the type of environment you want to protect, either "Traditional Endpoints" or "Cloud Workloads".
43- 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).
44- We suggest selecting "Complete EDR (Endpoint Detection and Response)" as a configuration setting, that provides "All events; all preventions"
45- 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.
46For more details on Elastic Agent configuration settings, refer to the [helper guide](https://www.elastic.co/guide/en/fleet/8.10/agent-policy.html).
47- Click "Save and Continue".
48- 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.
49For more details on Elastic Defend refer to the [helper guide](https://www.elastic.co/guide/en/security/current/install-endpoint.html).
50"""
51severity = "low"
52tags = [
53 "Domain: Endpoint",
54 "OS: Linux",
55 "Use Case: Threat Detection",
56 "Tactic: Persistence",
57 "Tactic: Execution",
58 "Tactic: Defense Evasion",
59 "Data Source: Elastic Defend",
60]
61timestamp_override = "event.ingested"
62type = "eql"
63
64query = '''
65process where host.os.type == "linux" and event.type == "start" and event.action == "exec" and process.parent.name in (
66 "applypatch-msg", "commit-msg", "fsmonitor-watchman", "post-update", "post-checkout", "post-commit",
67 "pre-applypatch", "pre-commit", "pre-merge-commit", "prepare-commit-msg", "pre-push", "pre-rebase", "pre-receive",
68 "push-to-checkout", "update", "post-receive", "pre-auto-gc", "post-rewrite", "sendemail-validate", "p4-pre-submit",
69 "post-index-change", "post-merge", "post-applypatch"
70) and (
71 process.name in ("nohup", "setsid", "disown", "bash", "dash", "sh", "tcsh", "csh", "zsh", "ksh", "fish") or
72 process.name : ("php*", "perl*", "ruby*", "lua*") or
73 process.executable : (
74 "/boot/*", "/dev/shm/*", "/etc/cron.*/*", "/etc/init.d/*", "/etc/update-motd.d/*",
75 "/run/*", "/srv/*", "/tmp/*", "/var/tmp/*", "/var/log/*"
76 )
77) and not process.name in ("git", "dirname")
78'''
79
80
81[[rule.threat]]
82framework = "MITRE ATT&CK"
83[[rule.threat.technique]]
84id = "T1543"
85name = "Create or Modify System Process"
86reference = "https://attack.mitre.org/techniques/T1543/"
87
88[[rule.threat.technique]]
89id = "T1574"
90name = "Hijack Execution Flow"
91reference = "https://attack.mitre.org/techniques/T1574/"
92
93
94[rule.threat.tactic]
95id = "TA0003"
96name = "Persistence"
97reference = "https://attack.mitre.org/tactics/TA0003/"
98[[rule.threat]]
99framework = "MITRE ATT&CK"
100[[rule.threat.technique]]
101id = "T1059"
102name = "Command and Scripting Interpreter"
103reference = "https://attack.mitre.org/techniques/T1059/"
104[[rule.threat.technique.subtechnique]]
105id = "T1059.004"
106name = "Unix Shell"
107reference = "https://attack.mitre.org/techniques/T1059/004/"
108
109
110
111[rule.threat.tactic]
112id = "TA0002"
113name = "Execution"
114reference = "https://attack.mitre.org/tactics/TA0002/"
115[[rule.threat]]
116framework = "MITRE ATT&CK"
117
118[rule.threat.tactic]
119id = "TA0005"
120name = "Defense Evasion"
121reference = "https://attack.mitre.org/tactics/TA0005/"
References
Related rules
- Git Hook Command Execution
- Git Hook Egress Network Connection
- Suspicious APT Package Manager Execution
- At Job Created or Modified
- DNF Package Manager Plugin File Creation