Potential Execution of rc.local Script

This rule detects the potential execution of the /etc/rc.local script through the already_running event action created by the rc-local.service systemd service. The /etc/rc.local script is a legacy initialization script that is executed at the end of the boot process. The /etc/rc.local script is not enabled by default on most Linux distributions. The /etc/rc.local script can be used by attackers to persistently execute malicious commands or scripts on a compromised system at reboot. As the rc.local file is executed prior to the initialization of Elastic Defend, the execution event is not ingested, and therefore the already_running event is leveraged to provide insight into the potential execution of rc.local.

Elastic rule (View on GitHub)

 1[metadata]
 2creation_date = "2024/06/21"
 3integration = ["endpoint"]
 4maturity = "production"
 5updated_date = "2024/06/21"
 6
 7[rule]
 8author = ["Elastic"]
 9description = """
10This rule detects the potential execution of the `/etc/rc.local` script through the `already_running` event action
11created by the `rc-local.service` systemd service. The `/etc/rc.local` script is a legacy initialization script that is
12executed at the end of the boot process. The `/etc/rc.local` script is not enabled by default on most Linux
13distributions. The `/etc/rc.local` script can be used by attackers to persistently execute malicious commands or scripts
14on a compromised system at reboot. As the rc.local file is executed prior to the initialization of Elastic Defend, the
15execution event is not ingested, and therefore the `already_running` event is leveraged to provide insight into the
16potential execution of `rc.local`.
17"""
18from = "now-9m"
19index = ["logs-endpoint.events.process*"]
20language = "eql"
21license = "Elastic License v2"
22name = "Potential Execution of rc.local Script"
23references = [
24    "https://www.intezer.com/blog/malware-analysis/hiddenwasp-malware-targeting-linux-systems/",
25    "https://pberba.github.io/security/2022/02/06/linux-threat-hunting-for-persistence-initialization-scripts-and-shell-configuration/#8-boot-or-logon-initialization-scripts-rc-scripts",
26    "https://www.cyberciti.biz/faq/how-to-enable-rc-local-shell-script-on-systemd-while-booting-linux-system/",
27]
28risk_score = 47
29rule_id = "7318affb-bfe8-4d50-a425-f617833be160"
30setup = """## Setup
31
32This rule requires data coming in from Elastic Defend.
33
34### Elastic Defend Integration Setup
35Elastic 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.
36
37#### Prerequisite Requirements:
38- Fleet is required for Elastic Defend.
39- To configure Fleet Server refer to the [documentation](https://www.elastic.co/guide/en/fleet/current/fleet-server.html).
40
41#### The following steps should be executed in order to add the Elastic Defend integration on a Linux System:
42- Go to the Kibana home page and click "Add integrations".
43- In the query bar, search for "Elastic Defend" and select the integration to see more details about it.
44- Click "Add Elastic Defend".
45- Configure the integration name and optionally add a description.
46- Select the type of environment you want to protect, either "Traditional Endpoints" or "Cloud Workloads".
47- 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).
48- We suggest selecting "Complete EDR (Endpoint Detection and Response)" as a configuration setting, that provides "All events; all preventions"
49- 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.
50For more details on Elastic Agent configuration settings, refer to the [helper guide](https://www.elastic.co/guide/en/fleet/8.10/agent-policy.html).
51- Click "Save and Continue".
52- 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.
53For more details on Elastic Defend refer to the [helper guide](https://www.elastic.co/guide/en/security/current/install-endpoint.html).
54"""
55severity = "medium"
56tags = [
57    "Domain: Endpoint",
58    "OS: Linux",
59    "Use Case: Threat Detection",
60    "Tactic: Persistence",
61    "Data Source: Elastic Defend"
62]
63timestamp_override = "event.ingested"
64type = "eql"
65query = '''
66process where host.os.type == "linux" and event.type == "info" and event.action == "already_running" and 
67process.parent.args == "/etc/rc.local" and process.parent.args == "start"
68'''
69
70[[rule.threat]]
71framework = "MITRE ATT&CK"
72
73[[rule.threat.technique]]
74id = "T1037"
75name = "Boot or Logon Initialization Scripts"
76reference = "https://attack.mitre.org/techniques/T1037/"
77
78[[rule.threat.technique.subtechnique]]
79id = "T1037.004"
80name = "RC Scripts"
81reference = "https://attack.mitre.org/techniques/T1037/004/"
82
83[rule.threat.tactic]
84id = "TA0003"
85name = "Persistence"
86reference = "https://attack.mitre.org/tactics/TA0003/"

References

Related rules

to-top