Initramfs Unpacking via unmkinitramfs

This rule detects the unpacking of an initramfs image using the unmkinitramfs command on Linux systems. The unmkinitramfs command is used to extract the contents of an initramfs image, which is used to boot the system. Attackers may use unmkinitramfs to unpack an initramfs image and modify its contents to include malicious code or backdoors, allowing them to maintain persistence on 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"
  5updated_date = "2025/03/20"
  6
  7[rule]
  8author = ["Elastic"]
  9description = """
 10This rule detects the unpacking of an initramfs image using the `unmkinitramfs` command on Linux systems. The
 11`unmkinitramfs` command is used to extract the contents of an initramfs image, which is used to boot the system.
 12Attackers may use `unmkinitramfs` to unpack an initramfs image and modify its contents to include malicious code or
 13backdoors, allowing them to maintain persistence on the system.
 14"""
 15from = "now-9m"
 16index = [
 17    "logs-endpoint.events.process*",
 18    "endgame-*",
 19    "auditbeat-*",
 20    "logs-auditd_manager.auditd-*",
 21    "logs-crowdstrike.fdr*",
 22    "logs-sentinel_one_cloud_funnel.*",
 23]
 24language = "eql"
 25license = "Elastic License v2"
 26name = "Initramfs Unpacking via unmkinitramfs"
 27note = """## Triage and analysis
 28
 29> **Disclaimer**:
 30> 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.
 31
 32### Investigating Initramfs Unpacking via unmkinitramfs
 33
 34Initramfs is a crucial component in Linux boot processes, containing essential drivers and scripts. The `unmkinitramfs` tool extracts its contents, which attackers might exploit to insert malicious code, ensuring persistence. The detection rule identifies the execution of `unmkinitramfs`, flagging potential unauthorized modifications by monitoring process initiation events on Linux systems.
 35
 36### Possible investigation steps
 37
 38- Review the process execution details to confirm the presence of the unmkinitramfs command, focusing on the process.name field to ensure it matches "unmkinitramfs".
 39- Check the user context under which the unmkinitramfs command was executed to determine if it aligns with expected administrative activities or if it was run by an unauthorized user.
 40- Investigate the parent process of the unmkinitramfs execution to understand how the command was initiated and if it was part of a legitimate script or an unexpected process chain.
 41- Examine recent system logs and audit logs for any other suspicious activities or anomalies around the time of the unmkinitramfs execution, such as unauthorized access attempts or changes to critical system files.
 42- Assess the integrity of the initramfs image by comparing it with a known good version, if available, to identify any unauthorized modifications or inclusions of malicious code.
 43
 44### False positive analysis
 45
 46- Routine system maintenance or updates may trigger the rule when legitimate processes unpack initramfs for kernel updates. Users can create exceptions for known maintenance scripts or processes that regularly perform these actions.
 47- Automated backup or recovery solutions might use unmkinitramfs to verify or restore system images. Identify and exclude these processes if they are part of trusted backup operations.
 48- Developers or system administrators testing or customizing initramfs images for legitimate purposes could trigger the rule. Establish a whitelist for specific user accounts or scripts that are authorized to perform these tasks.
 49- Security tools or monitoring solutions that analyze initramfs contents for integrity checks might inadvertently trigger the rule. Ensure these tools are recognized and excluded from detection to prevent unnecessary alerts.
 50
 51### Response and remediation
 52
 53- Immediately isolate the affected system from the network to prevent potential lateral movement or data exfiltration by the attacker.
 54- Terminate any suspicious processes related to `unmkinitramfs` to halt any ongoing malicious activity.
 55- Conduct a thorough review of the initramfs image and its contents to identify and remove any unauthorized modifications or malicious code.
 56- Restore the initramfs image from a known good backup to ensure system integrity and remove any potential backdoors.
 57- Monitor the system for any further attempts to execute `unmkinitramfs` and investigate any such occurrences to determine if they are legitimate or part of an ongoing attack.
 58- Escalate the incident to the security operations team for further analysis and to determine if additional systems may be affected.
 59- Implement additional logging and monitoring for process execution events on Linux systems to enhance detection capabilities for similar threats in the future."""
 60risk_score = 21
 61rule_id = "c5fc788c-7576-4a02-b3d6-d2c016eb85a6"
 62setup = """## Setup
 63This rule requires data coming in from Elastic Defend.
 64### Elastic Defend Integration Setup
 65Elastic 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.
 66#### Prerequisite Requirements:
 67- Fleet is required for Elastic Defend.
 68- To configure Fleet Server refer to the [documentation](https://www.elastic.co/guide/en/fleet/current/fleet-server.html).
 69#### The following steps should be executed in order to add the Elastic Defend integration on a Linux System:
 70- Go to the Kibana home page and click "Add integrations".
 71- In the query bar, search for "Elastic Defend" and select the integration to see more details about it.
 72- Click "Add Elastic Defend".
 73- Configure the integration name and optionally add a description.
 74- Select the type of environment you want to protect, either "Traditional Endpoints" or "Cloud Workloads".
 75- 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).
 76- We suggest selecting "Complete EDR (Endpoint Detection and Response)" as a configuration setting, that provides "All events; all preventions"
 77- 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.
 78For more details on Elastic Agent configuration settings, refer to the [helper guide](https://www.elastic.co/guide/en/fleet/8.10/agent-policy.html).
 79- Click "Save and Continue".
 80- 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.
 81For more details on Elastic Defend refer to the [helper guide](https://www.elastic.co/guide/en/security/current/install-endpoint.html).
 82"""
 83severity = "low"
 84tags = [
 85    "Domain: Endpoint",
 86    "OS: Linux",
 87    "Use Case: Threat Detection",
 88    "Tactic: Persistence",
 89    "Data Source: Elastic Endgame",
 90    "Data Source: Elastic Defend",
 91    "Data Source: Auditd Manager",
 92    "Data Source: Crowdstrike",
 93    "Data Source: SentinelOne",
 94    "Resources: Investigation Guide",
 95]
 96timestamp_override = "event.ingested"
 97type = "eql"
 98
 99query = '''
100process where host.os.type == "linux" and event.type == "start" and
101event.action in ("exec", "exec_event", "start", "ProcessRollup2", "executed") and
102process.name == "unmkinitramfs"
103'''
104
105
106[[rule.threat]]
107framework = "MITRE ATT&CK"
108[[rule.threat.technique]]
109id = "T1542"
110name = "Pre-OS Boot"
111reference = "https://attack.mitre.org/techniques/T1542/"
112
113[[rule.threat.technique]]
114id = "T1543"
115name = "Create or Modify System Process"
116reference = "https://attack.mitre.org/techniques/T1543/"
117
118[[rule.threat.technique]]
119id = "T1574"
120name = "Hijack Execution Flow"
121reference = "https://attack.mitre.org/techniques/T1574/"
122
123
124[rule.threat.tactic]
125id = "TA0003"
126name = "Persistence"
127reference = "https://attack.mitre.org/tactics/TA0003/"
128[[rule.threat]]
129framework = "MITRE ATT&CK"
130[[rule.threat.technique]]
131id = "T1059"
132name = "Command and Scripting Interpreter"
133reference = "https://attack.mitre.org/techniques/T1059/"
134[[rule.threat.technique.subtechnique]]
135id = "T1059.004"
136name = "Unix Shell"
137reference = "https://attack.mitre.org/techniques/T1059/004/"
138
139
140
141[rule.threat.tactic]
142id = "TA0002"
143name = "Execution"
144reference = "https://attack.mitre.org/tactics/TA0002/"
145[[rule.threat]]
146framework = "MITRE ATT&CK"
147
148[rule.threat.tactic]
149id = "TA0005"
150name = "Defense Evasion"
151reference = "https://attack.mitre.org/tactics/TA0005/"
...
toml

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.

Initramfs is a crucial component in Linux boot processes, containing essential drivers and scripts. The unmkinitramfs tool extracts its contents, which attackers might exploit to insert malicious code, ensuring persistence. The detection rule identifies the execution of unmkinitramfs, flagging potential unauthorized modifications by monitoring process initiation events on Linux systems.

  • Review the process execution details to confirm the presence of the unmkinitramfs command, focusing on the process.name field to ensure it matches "unmkinitramfs".
  • Check the user context under which the unmkinitramfs command was executed to determine if it aligns with expected administrative activities or if it was run by an unauthorized user.
  • Investigate the parent process of the unmkinitramfs execution to understand how the command was initiated and if it was part of a legitimate script or an unexpected process chain.
  • Examine recent system logs and audit logs for any other suspicious activities or anomalies around the time of the unmkinitramfs execution, such as unauthorized access attempts or changes to critical system files.
  • Assess the integrity of the initramfs image by comparing it with a known good version, if available, to identify any unauthorized modifications or inclusions of malicious code.
  • Routine system maintenance or updates may trigger the rule when legitimate processes unpack initramfs for kernel updates. Users can create exceptions for known maintenance scripts or processes that regularly perform these actions.
  • Automated backup or recovery solutions might use unmkinitramfs to verify or restore system images. Identify and exclude these processes if they are part of trusted backup operations.
  • Developers or system administrators testing or customizing initramfs images for legitimate purposes could trigger the rule. Establish a whitelist for specific user accounts or scripts that are authorized to perform these tasks.
  • Security tools or monitoring solutions that analyze initramfs contents for integrity checks might inadvertently trigger the rule. Ensure these tools are recognized and excluded from detection to prevent unnecessary alerts.
  • Immediately isolate the affected system from the network to prevent potential lateral movement or data exfiltration by the attacker.
  • Terminate any suspicious processes related to unmkinitramfs to halt any ongoing malicious activity.
  • Conduct a thorough review of the initramfs image and its contents to identify and remove any unauthorized modifications or malicious code.
  • Restore the initramfs image from a known good backup to ensure system integrity and remove any potential backdoors.
  • Monitor the system for any further attempts to execute unmkinitramfs and investigate any such occurrences to determine if they are legitimate or part of an ongoing attack.
  • Escalate the incident to the security operations team for further analysis and to determine if additional systems may be affected.
  • Implement additional logging and monitoring for process execution events on Linux systems to enhance detection capabilities for similar threats in the future.

Related rules

to-top