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/09/23"
 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    "https://www.elastic.co/security-labs/sequel-on-persistence-mechanisms",
28]
29risk_score = 47
30rule_id = "7318affb-bfe8-4d50-a425-f617833be160"
31setup = """## Setup
32
33This rule requires data coming in from Elastic Defend.
34
35### Elastic Defend Integration Setup
36Elastic 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.
37
38#### Prerequisite Requirements:
39- Fleet is required for Elastic Defend.
40- To configure Fleet Server refer to the [documentation](https://www.elastic.co/guide/en/fleet/current/fleet-server.html).
41
42#### The following steps should be executed in order to add the Elastic Defend integration on a Linux System:
43- Go to the Kibana home page and click "Add integrations".
44- In the query bar, search for "Elastic Defend" and select the integration to see more details about it.
45- Click "Add Elastic Defend".
46- Configure the integration name and optionally add a description.
47- Select the type of environment you want to protect, either "Traditional Endpoints" or "Cloud Workloads".
48- 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).
49- We suggest selecting "Complete EDR (Endpoint Detection and Response)" as a configuration setting, that provides "All events; all preventions"
50- 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.
51For more details on Elastic Agent configuration settings, refer to the [helper guide](https://www.elastic.co/guide/en/fleet/8.10/agent-policy.html).
52- Click "Save and Continue".
53- 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.
54For more details on Elastic Defend refer to the [helper guide](https://www.elastic.co/guide/en/security/current/install-endpoint.html).
55"""
56severity = "medium"
57tags = [
58    "Domain: Endpoint",
59    "OS: Linux",
60    "Use Case: Threat Detection",
61    "Tactic: Persistence",
62    "Data Source: Elastic Defend",
63]
64timestamp_override = "event.ingested"
65type = "eql"
66
67query = '''
68process where host.os.type == "linux" and event.type == "info" and event.action == "already_running" and 
69process.parent.args == "/etc/rc.local" and process.parent.args == "start"
70'''
71
72
73[[rule.threat]]
74framework = "MITRE ATT&CK"
75[[rule.threat.technique]]
76id = "T1037"
77name = "Boot or Logon Initialization Scripts"
78reference = "https://attack.mitre.org/techniques/T1037/"
79[[rule.threat.technique.subtechnique]]
80id = "T1037.004"
81name = "RC Scripts"
82reference = "https://attack.mitre.org/techniques/T1037/004/"
83
84
85
86[rule.threat.tactic]
87id = "TA0003"
88name = "Persistence"
89reference = "https://attack.mitre.org/tactics/TA0003/"

References

Related rules

to-top