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", "auditd_manager", "crowdstrike", "sentinel_one_cloud_funnel"]
  4maturity = "production"
  5min_stack_version = "8.13.0"
  6min_stack_comments = "Breaking change at 8.13.0 for SentinelOne Integration."
  7updated_date = "2025/01/22"
  8
  9[rule]
 10author = ["Elastic"]
 11description = """
 12This rule detects the process of copying or moving files from or to the `/boot` directory on Linux systems. The
 13`/boot` directory contains files that are essential for the system to boot, such as the kernel and initramfs
 14images. Attackers may copy or move files to the `/boot` directory to modify the boot process, which can be
 15leveraged to maintain access to the system.
 16"""
 17from = "now-9m"
 18index = [
 19    "logs-endpoint.events.process*",
 20    "endgame-*",
 21    "auditbeat-*",
 22    "logs-auditd_manager.auditd-*",
 23    "logs-crowdstrike.fdr*",
 24    "logs-sentinel_one_cloud_funnel.*"
 25]
 26language = "eql"
 27license = "Elastic License v2"
 28name = "Boot File Copy"
 29risk_score = 21
 30rule_id = "5bda8597-69a6-4b9e-87a2-69a7c963ea83"
 31setup = """## Setup
 32This rule requires data coming in from Elastic Defend.
 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#### Prerequisite Requirements:
 36- Fleet is required for Elastic Defend.
 37- To configure Fleet Server refer to the [documentation](https://www.elastic.co/guide/en/fleet/current/fleet-server.html).
 38#### The following steps should be executed in order to add the Elastic Defend integration on a Linux System:
 39- Go to the Kibana home page and click "Add integrations".
 40- In the query bar, search for "Elastic Defend" and select the integration to see more details about it.
 41- Click "Add Elastic Defend".
 42- Configure the integration name and optionally add a description.
 43- Select the type of environment you want to protect, either "Traditional Endpoints" or "Cloud Workloads".
 44- 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).
 45- We suggest selecting "Complete EDR (Endpoint Detection and Response)" as a configuration setting, that provides "All events; all preventions"
 46- 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.
 47For more details on Elastic Agent configuration settings, refer to the [helper guide](https://www.elastic.co/guide/en/fleet/8.10/agent-policy.html).
 48- Click "Save and Continue".
 49- 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.
 50For more details on Elastic Defend refer to the [helper guide](https://www.elastic.co/guide/en/security/current/install-endpoint.html).
 51"""
 52severity = "low"
 53tags = [
 54    "Domain: Endpoint",
 55    "OS: Linux",
 56    "Use Case: Threat Detection",
 57    "Tactic: Persistence",
 58    "Data Source: Elastic Endgame",
 59    "Data Source: Elastic Defend",
 60    "Data Source: Auditd Manager",
 61    "Data Source: Crowdstrike",
 62    "Data Source: SentinelOne",
 63    "Resources: Investigation Guide",
 64]
 65timestamp_override = "event.ingested"
 66type = "eql"
 67query = '''
 68process where host.os.type == "linux" and event.type == "start" and
 69event.action in ("exec", "exec_event", "start", "ProcessRollup2", "executed") and
 70process.name in ("cp", "mv") and process.parent.executable != null and process.args like~ "/boot/*" and not (
 71  process.parent.name in ("update-initramfs", "dracut", "grub-mkconfig", "shim-install", "sudo", "activate-theme") or
 72  process.parent.executable like~ ("/usr/lib/kernel/install.d/*", "/tmp/newroot/*", "/var/lib/dpkg/info/*") or
 73  process.parent.args like~ ("/usr/bin/mkinitcpio", "/var/tmp/rpm-tmp.*")
 74)
 75'''
 76note = """## Triage and analysis
 77
 78> **Disclaimer**:
 79> 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.
 80
 81### Investigating Boot File Copy
 82The `/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.
 83
 84### Possible investigation steps
 85
 86- 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/*'.
 87- 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'.
 88- 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.
 89- 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.
 90- 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.
 91- 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.
 92
 93### False positive analysis
 94
 95- 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.
 96- 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.
 97- 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.
 98- Temporary system recovery or installation processes might use directories like /tmp/newroot. Exclude these paths to avoid unnecessary alerts during legitimate recovery operations.
 99
100### Response and remediation
101
102- Immediately isolate the affected system from the network to prevent further unauthorized access or potential lateral movement by the adversary.
103- Terminate any suspicious processes identified by the detection rule, specifically those involving unauthorized 'cp' or 'mv' operations in the /boot directory.
104- 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.
105- Check for any unauthorized changes to boot configuration files, such as GRUB or LILO, and restore them to their original state.
106- Escalate the incident to the security operations team for further investigation and to determine if additional systems are affected.
107- Implement additional monitoring on the affected system and similar systems to detect any further unauthorized access attempts or modifications.
108- Review and update access controls and permissions for the /boot directory to ensure only authorized processes and users can make changes."""
109
110[[rule.threat]]
111framework = "MITRE ATT&CK"
112
113[[rule.threat.technique]]
114id = "T1542"
115name = "Pre-OS Boot"
116reference = "https://attack.mitre.org/techniques/T1542/"
117
118[[rule.threat.technique]]
119id = "T1543"
120name = "Create or Modify System Process"
121reference = "https://attack.mitre.org/techniques/T1543/"
122
123[[rule.threat.technique]]
124id = "T1574"
125name = "Hijack Execution Flow"
126reference = "https://attack.mitre.org/techniques/T1574/"
127
128[rule.threat.tactic]
129id = "TA0003"
130name = "Persistence"
131reference = "https://attack.mitre.org/tactics/TA0003/"
132
133[[rule.threat]]
134framework = "MITRE ATT&CK"
135
136[[rule.threat.technique]]
137id = "T1059"
138name = "Command and Scripting Interpreter"
139reference = "https://attack.mitre.org/techniques/T1059/"
140
141[[rule.threat.technique.subtechnique]]
142id = "T1059.004"
143name = "Unix Shell"
144reference = "https://attack.mitre.org/techniques/T1059/004/"
145
146[rule.threat.tactic]
147id = "TA0002"
148name = "Execution"
149reference = "https://attack.mitre.org/tactics/TA0002/"
150
151[[rule.threat]]
152framework = "MITRE ATT&CK"
153
154[rule.threat.tactic]
155id = "TA0005"
156name = "Defense Evasion"
157reference = "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

to-top