Executable Bit Set for rc.local/rc.common

This rule monitors for the addition of an executable bit of the /etc/rc.local or /etc/rc.common files. These files are used to start custom applications, services, scripts or commands during start-up. They require executable permissions to be executed on boot. An alert of this rule is an indicator that this method is being set up within your environment. This method has mostly been replaced by Systemd. However, through the systemd-rc-local-generator, these files can be converted to services that run at boot. Adversaries may alter these files to execute malicious code at start-up, and gain persistence onto the system.

Elastic rule (View on GitHub)

 1[metadata]
 2creation_date = "2024/06/03"
 3integration = ["endpoint"]
 4maturity = "production"
 5updated_date = "2024/06/03"
 6
 7[rule]
 8author = ["Elastic"]
 9description = """
10This rule monitors for the addition of an executable bit of the `/etc/rc.local` or `/etc/rc.common` files. These files
11are used to start custom applications, services, scripts or commands during start-up. They require executable
12permissions to be executed on boot. An alert of this rule is an indicator that this method is being set up within
13your environment. This method has mostly been replaced by Systemd. However, through the `systemd-rc-local-generator`,
14these files can be converted to services that run at boot. Adversaries may alter these files to execute malicious code
15at start-up, and gain persistence onto the system.
16"""
17from = "now-9m"
18index = ["logs-endpoint.events.process*", "endgame-*"]
19language = "eql"
20license = "Elastic License v2"
21name = "Executable Bit Set for rc.local/rc.common"
22references = [
23    "https://www.intezer.com/blog/malware-analysis/hiddenwasp-malware-targeting-linux-systems/",
24    "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",
25    "https://www.cyberciti.biz/faq/how-to-enable-rc-local-shell-script-on-systemd-while-booting-linux-system/",
26]
27risk_score = 47
28rule_id = "94418745-529f-4259-8d25-a713a6feb6ae"
29setup = """## Setup
30
31This rule requires data coming in from Elastic Defend.
32
33### Elastic Defend Integration Setup
34Elastic 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.
35
36#### Prerequisite Requirements:
37- Fleet is required for Elastic Defend.
38- To configure Fleet Server refer to the [documentation](https://www.elastic.co/guide/en/fleet/current/fleet-server.html).
39
40#### The following steps should be executed in order to add the Elastic Defend integration on a Linux System:
41- Go to the Kibana home page and click "Add integrations".
42- In the query bar, search for "Elastic Defend" and select the integration to see more details about it.
43- Click "Add Elastic Defend".
44- Configure the integration name and optionally add a description.
45- Select the type of environment you want to protect, either "Traditional Endpoints" or "Cloud Workloads".
46- 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).
47- We suggest selecting "Complete EDR (Endpoint Detection and Response)" as a configuration setting, that provides "All events; all preventions"
48- 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.
49For more details on Elastic Agent configuration settings, refer to the [helper guide](https://www.elastic.co/guide/en/fleet/8.10/agent-policy.html).
50- Click "Save and Continue".
51- 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.
52For more details on Elastic Defend refer to the [helper guide](https://www.elastic.co/guide/en/security/current/install-endpoint.html).
53"""
54severity = "medium"
55tags = [
56    "Domain: Endpoint",
57    "OS: Linux",
58    "Use Case: Threat Detection",
59    "Tactic: Persistence",
60    "Data Source: Elastic Endgame",
61    "Data Source: Elastic Defend"
62]
63timestamp_override = "event.ingested"
64type = "eql"
65
66query = '''
67process where host.os.type == "linux" and event.type == "start" and event.action in ("exec", "exec_event") and
68process.args in ("/etc/rc.local", "/etc/rc.common") and (
69  (process.name == "chmod" and process.args : ("*+x*", "1*", "3*", "5*", "7*")) or
70  (process.name == "install" and process.args : "-m*" and process.args : ("*7*", "*5*", "*3*", "*1*"))
71)
72'''
73
74[[rule.threat]]
75framework = "MITRE ATT&CK"
76
77[[rule.threat.technique]]
78id = "T1037"
79name = "Boot or Logon Initialization Scripts"
80reference = "https://attack.mitre.org/techniques/T1037/"
81
82[[rule.threat.technique.subtechnique]]
83id = "T1037.004"
84name = "RC Scripts"
85reference = "https://attack.mitre.org/techniques/T1037/004/"
86
87[rule.threat.tactic]
88id = "TA0003"
89name = "Persistence"
90reference = "https://attack.mitre.org/tactics/TA0003/"

References

Related rules

to-top