Boot File Copy
This rule detects the process of copying or moving files from or to the "/boot" directory on Linux systems. The "/boot" directory contains files that are essential for the system to boot, such as the kernel and initramfs images. Attackers may copy or move files to the "/boot" directory to modify the boot process, which can be leveraged to maintain access to the system.
Elastic rule (View on GitHub)
1[metadata]
2creation_date = "2025/01/16"
3integration = ["endpoint", "sentinel_one_cloud_funnel"]
4maturity = "production"
5updated_date = "2025/12/22"
6
7[rule]
8author = ["Elastic"]
9description = """
10This rule detects the process of copying or moving files from or to the "/boot" directory on Linux systems. The "/boot"
11directory contains files that are essential for the system to boot, such as the kernel and initramfs images. Attackers
12may copy or move files to the "/boot" directory to modify the boot process, which can be leveraged to maintain access to
13the system.
14"""
15from = "now-9m"
16index = [
17 "logs-endpoint.events.process*",
18 "logs-sentinel_one_cloud_funnel.*",
19]
20language = "eql"
21license = "Elastic License v2"
22name = "Boot File Copy"
23note = """## Triage and analysis
24
25> **Disclaimer**:
26> This investigation guide was created using generative AI technology and has been reviewed to improve its accuracy and relevance. While every effort has been made to ensure its quality, we recommend validating the content and adapting it to suit your specific environment and operational needs.
27
28### Investigating Boot File Copy
29The `/boot` directory in Linux systems is crucial for storing files necessary for booting, such as the kernel. Adversaries may exploit this by copying or moving files to alter the boot process, potentially gaining persistent access. The 'Boot File Copy' detection rule identifies suspicious file operations in this directory, excluding legitimate processes, to flag potential unauthorized modifications.
30
31### Possible investigation steps
32
33- Review the process details to identify the specific file operation by examining the process name and arguments, particularly focusing on the use of 'cp' or 'mv' commands with paths involving '/boot/*'.
34- Investigate the parent process executable and name to determine if the operation was initiated by a known legitimate process or script, ensuring it is not one of the excluded processes like 'update-initramfs' or 'grub-mkconfig'.
35- Check the user account associated with the process to assess whether it is a privileged account and if the activity aligns with typical user behavior.
36- Analyze recent system logs and audit records for any other suspicious activities or anomalies around the time of the alert to identify potential patterns or related events.
37- Verify the integrity and authenticity of the files in the /boot directory to ensure no unauthorized modifications have been made, focusing on critical files like the kernel and initramfs images.
38- If possible, correlate the alert with other data sources such as Elastic Endgame or Crowdstrike to gather additional context and confirm whether this is part of a broader attack pattern.
39
40### False positive analysis
41
42- System updates and maintenance tasks often involve legitimate processes that interact with the /boot directory. Processes like update-initramfs, dracut, and grub-mkconfig are common during these operations. Users can exclude these processes by adding them to the exception list in the detection rule.
43- Custom scripts or administrative tasks that require copying or moving files to the /boot directory may trigger false positives. Identify these scripts and add their parent process names or paths to the exclusion criteria.
44- Package management operations, such as those involving dpkg or rpm, may also interact with the /boot directory. Exclude paths like /var/lib/dpkg/info/* and /var/tmp/rpm-tmp.* to prevent these from being flagged.
45- Temporary system recovery or installation processes might use directories like /tmp/newroot. Exclude these paths to avoid unnecessary alerts during legitimate recovery operations.
46
47### Response and remediation
48
49- Immediately isolate the affected system from the network to prevent further unauthorized access or potential lateral movement by the adversary.
50- Terminate any suspicious processes identified by the detection rule, specifically those involving unauthorized 'cp' or 'mv' operations in the /boot directory.
51- Conduct a thorough review of the /boot directory to identify and remove any unauthorized files or modifications. Restore any altered files from a known good backup if necessary.
52- Check for any unauthorized changes to boot configuration files, such as GRUB or LILO, and restore them to their original state.
53- Escalate the incident to the security operations team for further investigation and to determine if additional systems are affected.
54- Implement additional monitoring on the affected system and similar systems to detect any further unauthorized access attempts or modifications.
55- Review and update access controls and permissions for the /boot directory to ensure only authorized processes and users can make changes."""
56risk_score = 21
57rule_id = "5bda8597-69a6-4b9e-87a2-69a7c963ea83"
58setup = """## Setup
59This rule requires data coming in from Elastic Defend.
60### Elastic Defend Integration Setup
61Elastic 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.
62#### Prerequisite Requirements:
63- Fleet is required for Elastic Defend.
64- To configure Fleet Server refer to the [documentation](https://www.elastic.co/guide/en/fleet/current/fleet-server.html).
65#### The following steps should be executed in order to add the Elastic Defend integration on a Linux System:
66- Go to the Kibana home page and click "Add integrations".
67- In the query bar, search for "Elastic Defend" and select the integration to see more details about it.
68- Click "Add Elastic Defend".
69- Configure the integration name and optionally add a description.
70- Select the type of environment you want to protect, either "Traditional Endpoints" or "Cloud Workloads".
71- 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).
72- We suggest selecting "Complete EDR (Endpoint Detection and Response)" as a configuration setting, that provides "All events; all preventions"
73- 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.
74For more details on Elastic Agent configuration settings, refer to the [helper guide](https://www.elastic.co/guide/en/fleet/8.10/agent-policy.html).
75- Click "Save and Continue".
76- 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.
77For more details on Elastic Defend refer to the [helper guide](https://www.elastic.co/guide/en/security/current/install-endpoint.html).
78"""
79severity = "low"
80tags = [
81 "Domain: Endpoint",
82 "OS: Linux",
83 "Use Case: Threat Detection",
84 "Tactic: Persistence",
85 "Data Source: Elastic Defend",
86 "Data Source: SentinelOne",
87 "Resources: Investigation Guide",
88]
89timestamp_override = "event.ingested"
90type = "eql"
91query = '''
92process where host.os.type == "linux" and event.type == "start" and event.action in ("exec", "start") and
93process.name in ("cp", "mv") and process.parent.executable != null and process.args like~ "/boot/*" and not (
94 process.parent.name in ("update-initramfs", "dracut", "grub-mkconfig", "shim-install", "sudo", "activate-theme", "update-grub-gfxpayload", "grub-pc.postinst") or
95 process.parent.executable like~ ("/usr/lib/kernel/install.d/*", "/tmp/newroot/*", "/var/lib/dpkg/info/*") or
96 process.parent.args like~ ("/usr/bin/mkinitcpio", "/var/tmp/rpm-tmp.*", "/var/lib/dpkg/info/*") or
97 process.parent.executable in (
98 "/var/lib/aws-replication-agent/migration_scripts/suse_to_aws.bash", "/usr/sbin/flash-kernel", "/usr/sbin/weak-modules",
99 "/etc/cron.hourly/check_mau", "/usr/bin/update-microcode-initrd", "/bin/run-parts", "/usr/sbin/mkinitramfs", "/usr/sbin/grub2-mkconfig",
100 "/usr/bin/supermin5", "/sbin/weak-modules", "/usr/sbin/nv-update-initrd", "/usr/libexec/platform-python", "/bin/kernel-install",
101 "/usr/bin/oracle-database-preinstall-19c-verify", "/usr/libexec/grubby/prune_debug"
102 ) or
103 process.command_line == "/bin/cp /usr/local/ASR/Vx/scripts/vCon//Configuration.info /boot/" or
104 ?process.working_directory in ("/var/lib/aws-replication-agent", "/opt/sentinelone/bin", "/tmp/MobilityAgentAutoUpgrade/package") or
105 (
106 process.name == "cp" and
107 process.parent.args in (
108 "/etc/kernel/postrm.d/zz-proxmox-boot", "/etc/kernel/postinst.d/zz-proxmox-boot", "/usr/lib/kernel/install.d/20-grub.install",
109 "/usr/bin/dracut", "/bin/dracut", "/usr/sbin/shim-install", "/sbin/dracut", "/opt/McAfee/ens/esp/scripts/modversion-check.sh",
110 "//opt/McAfee/ens/esp/scripts//modversion-check.sh", "/usr/sbin/update-grub-legacy-ec2", "/usr/bin/foreman-generate-bootloaders",
111 "/usr/share/grub2/themes/SLE/activate-theme", "/usr/sbin/dracut", "/usr/sbin/flash-kernel", "/usr/lib/kernel/install.d/20-grubby.install"
112 )
113 ) or
114 (process.name == "mv" and process.args == "-f" and process.parent.args == "/usr/sbin/update-initramfs") or
115 (
116 process.name == "mv" and
117 process.parent.args in (
118 "/usr/sbin/flash-kernel", "/usr/bin/update-microcode-initrd", "/usr/sbin/update-grub-gfxpayload",
119 "/usr/sbin/weak-modules", "/usr/bin/dracut"
120 )
121 )
122)
123'''
124
125[[rule.threat]]
126framework = "MITRE ATT&CK"
127
128[[rule.threat.technique]]
129id = "T1542"
130name = "Pre-OS Boot"
131reference = "https://attack.mitre.org/techniques/T1542/"
132
133[[rule.threat.technique]]
134id = "T1543"
135name = "Create or Modify System Process"
136reference = "https://attack.mitre.org/techniques/T1543/"
137
138[[rule.threat.technique]]
139id = "T1574"
140name = "Hijack Execution Flow"
141reference = "https://attack.mitre.org/techniques/T1574/"
142
143[rule.threat.tactic]
144id = "TA0003"
145name = "Persistence"
146reference = "https://attack.mitre.org/tactics/TA0003/"
147
148[[rule.threat]]
149framework = "MITRE ATT&CK"
150
151[[rule.threat.technique]]
152id = "T1059"
153name = "Command and Scripting Interpreter"
154reference = "https://attack.mitre.org/techniques/T1059/"
155
156[[rule.threat.technique.subtechnique]]
157id = "T1059.004"
158name = "Unix Shell"
159reference = "https://attack.mitre.org/techniques/T1059/004/"
160
161[rule.threat.tactic]
162id = "TA0002"
163name = "Execution"
164reference = "https://attack.mitre.org/tactics/TA0002/"
165
166[[rule.threat]]
167framework = "MITRE ATT&CK"
168
169[rule.threat.tactic]
170id = "TA0005"
171name = "Defense Evasion"
172reference = "https://attack.mitre.org/tactics/TA0005/"
Triage and analysis
Disclaimer: This investigation guide was created using generative AI technology and has been reviewed to improve its accuracy and relevance. While every effort has been made to ensure its quality, we recommend validating the content and adapting it to suit your specific environment and operational needs.
Investigating Boot File Copy
The /boot directory in Linux systems is crucial for storing files necessary for booting, such as the kernel. Adversaries may exploit this by copying or moving files to alter the boot process, potentially gaining persistent access. The 'Boot File Copy' detection rule identifies suspicious file operations in this directory, excluding legitimate processes, to flag potential unauthorized modifications.
Possible investigation steps
- Review the process details to identify the specific file operation by examining the process name and arguments, particularly focusing on the use of 'cp' or 'mv' commands with paths involving '/boot/*'.
- Investigate the parent process executable and name to determine if the operation was initiated by a known legitimate process or script, ensuring it is not one of the excluded processes like 'update-initramfs' or 'grub-mkconfig'.
- Check the user account associated with the process to assess whether it is a privileged account and if the activity aligns with typical user behavior.
- Analyze recent system logs and audit records for any other suspicious activities or anomalies around the time of the alert to identify potential patterns or related events.
- Verify the integrity and authenticity of the files in the /boot directory to ensure no unauthorized modifications have been made, focusing on critical files like the kernel and initramfs images.
- If possible, correlate the alert with other data sources such as Elastic Endgame or Crowdstrike to gather additional context and confirm whether this is part of a broader attack pattern.
False positive analysis
- System updates and maintenance tasks often involve legitimate processes that interact with the /boot directory. Processes like update-initramfs, dracut, and grub-mkconfig are common during these operations. Users can exclude these processes by adding them to the exception list in the detection rule.
- Custom scripts or administrative tasks that require copying or moving files to the /boot directory may trigger false positives. Identify these scripts and add their parent process names or paths to the exclusion criteria.
- Package management operations, such as those involving dpkg or rpm, may also interact with the /boot directory. Exclude paths like /var/lib/dpkg/info/* and /var/tmp/rpm-tmp.* to prevent these from being flagged.
- Temporary system recovery or installation processes might use directories like /tmp/newroot. Exclude these paths to avoid unnecessary alerts during legitimate recovery operations.
Response and remediation
- Immediately isolate the affected system from the network to prevent further unauthorized access or potential lateral movement by the adversary.
- Terminate any suspicious processes identified by the detection rule, specifically those involving unauthorized 'cp' or 'mv' operations in the /boot directory.
- Conduct a thorough review of the /boot directory to identify and remove any unauthorized files or modifications. Restore any altered files from a known good backup if necessary.
- Check for any unauthorized changes to boot configuration files, such as GRUB or LILO, and restore them to their original state.
- Escalate the incident to the security operations team for further investigation and to determine if additional systems are affected.
- Implement additional monitoring on the affected system and similar systems to detect any further unauthorized access attempts or modifications.
- Review and update access controls and permissions for the /boot directory to ensure only authorized processes and users can make changes.
Related rules
- Chkconfig Service Add
- D-Bus Service Created
- DNF Package Manager Plugin File Creation
- Dracut Module Creation
- Dynamic Linker Copy