Kernel Unpacking Activity

This rule detects kernel unpacking activity through several built-in Linux utilities. Attackers may use these utilities to unpack kernel images and modules to search for vulnerabilities or to modify the kernel.

Elastic rule (View on GitHub)

  1[metadata]
  2creation_date = "2025/01/07"
  3integration = ["endpoint"]
  4maturity = "production"
  5updated_date = "2025/01/22"
  6
  7[rule]
  8author = ["Elastic"]
  9description = """
 10This rule detects kernel unpacking activity through several built-in Linux utilities. Attackers may use these utilities
 11to unpack kernel images and modules to search for vulnerabilities or to modify the kernel.
 12"""
 13from = "now-9m"
 14index = ["logs-endpoint.events.*"]
 15language = "eql"
 16license = "Elastic License v2"
 17name = "Kernel Unpacking Activity"
 18references = ["https://www.elastic.co/security-labs/declawing-pumakit"]
 19risk_score = 21
 20rule_id = "4f725dc5-ae44-46c1-9ac5-99f6f7a70d8a"
 21setup = """## Setup
 22
 23This rule requires data coming in from Elastic Defend.
 24
 25### Elastic Defend Integration Setup
 26Elastic 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.
 27
 28#### Prerequisite Requirements:
 29- Fleet is required for Elastic Defend.
 30- To configure Fleet Server refer to the [documentation](https://www.elastic.co/guide/en/fleet/current/fleet-server.html).
 31
 32#### The following steps should be executed in order to add the Elastic Defend integration on a Linux System:
 33- Go to the Kibana home page and click "Add integrations".
 34- In the query bar, search for "Elastic Defend" and select the integration to see more details about it.
 35- Click "Add Elastic Defend".
 36- Configure the integration name and optionally add a description.
 37- Select the type of environment you want to protect, either "Traditional Endpoints" or "Cloud Workloads".
 38- 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).
 39- We suggest selecting "Complete EDR (Endpoint Detection and Response)" as a configuration setting, that provides "All events; all preventions"
 40- 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.
 41For more details on Elastic Agent configuration settings, refer to the [helper guide](https://www.elastic.co/guide/en/fleet/8.10/agent-policy.html).
 42- Click "Save and Continue".
 43- 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.
 44For more details on Elastic Defend refer to the [helper guide](https://www.elastic.co/guide/en/security/current/install-endpoint.html).
 45"""
 46severity = "low"
 47tags = [
 48    "Domain: Endpoint",
 49    "OS: Linux",
 50    "Use Case: Threat Detection",
 51    "Tactic: Discovery",
 52    "Tactic: Defense Evasion",
 53    "Data Source: Elastic Defend",
 54    "Resources: Investigation Guide",
 55]
 56timestamp_override = "event.ingested"
 57type = "eql"
 58query = '''
 59process where host.os.type == "linux" and event.type == "start" and event.action == "exec" and
 60(process.parent.args like "/boot/*" or process.args like "/boot/*") and (
 61  (process.name in ("file", "unlzma", "gunzip", "unxz", "bunzip2", "unzstd", "unzip", "tar")) or
 62  (process.name == "grep" and process.args == "ELF") or
 63  (process.name in ("lzop", "lz4") and process.args in ("-d", "--decode"))
 64) and
 65not process.parent.name == "mkinitramfs"
 66'''
 67note = """## Triage and analysis
 68
 69> **Disclaimer**:
 70> 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.
 71
 72### Investigating Kernel Unpacking Activity
 73
 74Kernel unpacking involves using utilities to extract or inspect kernel images and modules, often for legitimate maintenance or updates. However, adversaries exploit this to identify vulnerabilities or alter the kernel for malicious purposes. The detection rule identifies suspicious unpacking by monitoring specific Linux utilities and command patterns, excluding benign processes like system updates, to flag potential threats.
 75
 76### Possible investigation steps
 77
 78- Review the process details to identify the specific utility used for unpacking, such as "file", "unlzma", "gunzip", etc., and verify if the usage aligns with typical system maintenance activities.
 79- Examine the parent process name and arguments, especially those involving "/boot/*", to determine if the unpacking activity is part of a legitimate system operation or an unauthorized action.
 80- Check the user account associated with the process to assess if the activity was initiated by a legitimate user or an unauthorized entity.
 81- Investigate the timing of the event to see if it coincides with scheduled maintenance or updates, which might explain the unpacking activity.
 82- Look for any related alerts or logs that might indicate further suspicious behavior, such as attempts to modify kernel modules or other system files following the unpacking activity.
 83- Cross-reference the event with recent system updates or patches to rule out false positives related to legitimate system operations.
 84
 85### False positive analysis
 86
 87- System updates and maintenance activities can trigger this rule when legitimate processes unpack kernel images. To manage this, exclude processes initiated by known update utilities like "mkinitramfs" from triggering alerts.
 88- Custom scripts or administrative tasks that involve unpacking kernel images for legitimate purposes may also cause false positives. Identify and whitelist these scripts or processes by their specific command patterns or parent process names.
 89- Backup or recovery operations that involve accessing or unpacking kernel files might be flagged. Review these operations and exclude them by specifying the responsible process names or arguments in the detection rule.
 90- Automated security tools that scan or analyze kernel images for compliance or vulnerability assessments can be mistaken for malicious activity. Exclude these tools by adding their process names to the exception list.
 91
 92### Response and remediation
 93
 94- Isolate the affected system from the network to prevent potential lateral movement or further exploitation by the adversary.
 95- Terminate any suspicious processes identified by the detection rule, especially those involving the unpacking of kernel images or modules.
 96- Conduct a thorough review of the system's kernel and module integrity using trusted tools to ensure no unauthorized modifications have been made.
 97- Restore the system from a known good backup if any unauthorized changes to the kernel or system files are detected.
 98- Update the system's kernel and all related packages to the latest versions to mitigate any known vulnerabilities that could be exploited.
 99- Monitor the system for any recurring suspicious activity, focusing on the use of utilities and command patterns identified in the detection rule.
100- Escalate the incident to the security operations team for further investigation and to assess the potential impact on other systems within the network."""
101
102[[rule.threat]]
103framework = "MITRE ATT&CK"
104
105[[rule.threat.technique]]
106id = "T1082"
107name = "System Information Discovery"
108reference = "https://attack.mitre.org/techniques/T1082/"
109
110[rule.threat.tactic]
111id = "TA0007"
112name = "Discovery"
113reference = "https://attack.mitre.org/tactics/TA0007/"
114
115[[rule.threat]]
116framework = "MITRE ATT&CK"
117
118[[rule.threat.technique]]
119id = "T1014"
120name = "Rootkit"
121reference = "https://attack.mitre.org/techniques/T1014/"
122
123[rule.threat.tactic]
124id = "TA0005"
125name = "Defense Evasion"
126reference = "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 Kernel Unpacking Activity

Kernel unpacking involves using utilities to extract or inspect kernel images and modules, often for legitimate maintenance or updates. However, adversaries exploit this to identify vulnerabilities or alter the kernel for malicious purposes. The detection rule identifies suspicious unpacking by monitoring specific Linux utilities and command patterns, excluding benign processes like system updates, to flag potential threats.

Possible investigation steps

  • Review the process details to identify the specific utility used for unpacking, such as "file", "unlzma", "gunzip", etc., and verify if the usage aligns with typical system maintenance activities.
  • Examine the parent process name and arguments, especially those involving "/boot/*", to determine if the unpacking activity is part of a legitimate system operation or an unauthorized action.
  • Check the user account associated with the process to assess if the activity was initiated by a legitimate user or an unauthorized entity.
  • Investigate the timing of the event to see if it coincides with scheduled maintenance or updates, which might explain the unpacking activity.
  • Look for any related alerts or logs that might indicate further suspicious behavior, such as attempts to modify kernel modules or other system files following the unpacking activity.
  • Cross-reference the event with recent system updates or patches to rule out false positives related to legitimate system operations.

False positive analysis

  • System updates and maintenance activities can trigger this rule when legitimate processes unpack kernel images. To manage this, exclude processes initiated by known update utilities like "mkinitramfs" from triggering alerts.
  • Custom scripts or administrative tasks that involve unpacking kernel images for legitimate purposes may also cause false positives. Identify and whitelist these scripts or processes by their specific command patterns or parent process names.
  • Backup or recovery operations that involve accessing or unpacking kernel files might be flagged. Review these operations and exclude them by specifying the responsible process names or arguments in the detection rule.
  • Automated security tools that scan or analyze kernel images for compliance or vulnerability assessments can be mistaken for malicious activity. Exclude these tools by adding their process names to the exception list.

Response and remediation

  • Isolate the affected system from the network to prevent potential lateral movement or further exploitation by the adversary.
  • Terminate any suspicious processes identified by the detection rule, especially those involving the unpacking of kernel images or modules.
  • Conduct a thorough review of the system's kernel and module integrity using trusted tools to ensure no unauthorized modifications have been made.
  • Restore the system from a known good backup if any unauthorized changes to the kernel or system files are detected.
  • Update the system's kernel and all related packages to the latest versions to mitigate any known vulnerabilities that could be exploited.
  • Monitor the system for any recurring suspicious activity, focusing on the use of utilities and command patterns identified in the detection rule.
  • Escalate the incident to the security operations team for further investigation and to assess the potential impact on other systems within the network.

References

Related rules

to-top