Unusual Execution from Kernel Thread (kthreadd) Parent
This rule detects suspicious child process from the kernel thread (kthreadd) parent process. Attackers may execute payloads from kernel space via kthreadd to perform actions on the host and evade detection. Through the usage of the new_terms rule type, this rule can identify uncommon child processes that may indicate the presence of a malicious process.
Elastic rule (View on GitHub)
1[metadata]
2creation_date = "2025/04/30"
3integration = ["endpoint"]
4maturity = "production"
5updated_date = "2025/07/07"
6
7[rule]
8author = ["Elastic"]
9description = """
10This rule detects suspicious child process from the kernel thread (kthreadd) parent process. Attackers may execute payloads from
11kernel space via kthreadd to perform actions on the host and evade detection. Through the usage of the new_terms rule type, this
12rule can identify uncommon child processes that may indicate the presence of a malicious process.
13"""
14from = "now-9m"
15index = ["logs-endpoint.events.process*"]
16language = "kuery"
17license = "Elastic License v2"
18name = "Unusual Execution from Kernel Thread (kthreadd) Parent"
19note = """ ## Triage and analysis
20
21> **Disclaimer**:
22> 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.
23
24### Investigating Unusual Execution from Kernel Thread (kthreadd) Parent
25
26The kernel thread (kthreadd) is a fundamental component in Linux systems responsible for managing kernel-level processes. Adversaries may exploit kthreadd to execute payloads from kernel space, thereby evading detection due to its trusted status. The detection rule identifies suspicious child processes initiated by kthreadd, focusing on unusual executable paths and command lines indicative of malicious activity, while filtering out known benign processes.
27
28### Possible investigation steps
29
30- Review the alert details to identify the specific child process name and executable path that triggered the rule. Focus on paths like /dev/shm, /tmp, /var/tmp, and /var/www, which are commonly used for storing temporary or potentially malicious files.
31- Examine the command line arguments associated with the suspicious process. Look for indicators of compromise such as references to sensitive files or directories like /etc/shadow, /etc/sudoers, or ~/.ssh, as well as suspicious commands like base64 or cron.
32- Check the parent process details to confirm it is indeed kthreadd. Investigate any unusual behavior or anomalies in the parent process that might suggest exploitation or manipulation.
33- Investigate the network activity of the host to identify any connections to suspicious IP addresses or domains, especially if the command line includes references to /dev/tcp or other network-related paths.
34- Analyze the system logs and historical data to determine if similar alerts have been triggered in the past, which might indicate a persistent threat or repeated exploitation attempts.
35- Assess the risk and impact of the detected activity by correlating it with other security events or alerts on the host, considering the medium severity and risk score of 47 associated with this rule.
36
37### False positive analysis
38
39- Legitimate system maintenance tasks may trigger this rule, such as automated scripts running from temporary directories. Users can create exceptions for specific scripts or processes that are verified as safe.
40- Development or testing environments often use temporary directories for executing scripts. Exclude known development tools or scripts from these environments to reduce noise.
41- Some monitoring or backup tools might use command lines or executables that match the rule's criteria. Identify these tools and add them to the exclusion list to prevent false alerts.
42- Custom administrative scripts that perform routine checks or updates might inadvertently match the rule. Review these scripts and exclude them if they are part of regular operations.
43- If certain processes are consistently flagged but are known to be benign, consider adjusting the rule to exclude these specific processes or command lines to improve detection accuracy.
44
45### Response and remediation
46
47- Isolate the affected host immediately to prevent further malicious activity and lateral movement within the network.
48- Terminate any suspicious processes identified as child processes of kthreadd that match the alert criteria, ensuring to log the process details for further analysis.
49- Conduct a thorough review of the file paths and command lines flagged in the alert to identify any unauthorized or malicious files or scripts. Remove or quarantine these files as necessary.
50- Check for unauthorized modifications in critical system files and directories such as /etc/init.d, /etc/ssh, and /root/.ssh. Restore any altered files from a known good backup.
51- Escalate the incident to the security operations team for a deeper forensic investigation to determine the root cause and entry point of the threat.
52- Implement additional monitoring on the affected host and similar systems to detect any recurrence of the threat, focusing on the specific indicators identified in the alert.
53- Update and patch the affected system to the latest security standards to mitigate vulnerabilities that may have been exploited by the adversary.
54"""
55risk_score = 47
56rule_id = "656739a8-2786-402b-8ee1-22e0762b63ba"
57setup = """## Setup
58
59This rule requires data coming in from Elastic Defend.
60
61### Elastic Defend Integration Setup
62Elastic 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.
63
64#### Prerequisite Requirements:
65- Fleet is required for Elastic Defend.
66- To configure Fleet Server refer to the [documentation](https://www.elastic.co/guide/en/fleet/current/fleet-server.html).
67
68#### The following steps should be executed in order to add the Elastic Defend integration on a Linux System:
69- Go to the Kibana home page and click "Add integrations".
70- In the query bar, search for "Elastic Defend" and select the integration to see more details about it.
71- Click "Add Elastic Defend".
72- Configure the integration name and optionally add a description.
73- Select the type of environment you want to protect, either "Traditional Endpoints" or "Cloud Workloads".
74- 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).
75- We suggest selecting "Complete EDR (Endpoint Detection and Response)" as a configuration setting, that provides "All events; all preventions"
76- 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.
77
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 = "medium"
84tags = [
85 "Domain: Endpoint",
86 "OS: Linux",
87 "Use Case: Threat Detection",
88 "Tactic: Execution",
89 "Data Source: Elastic Defend",
90 "Resources: Investigation Guide",
91]
92timestamp_override = "event.ingested"
93type = "new_terms"
94query = '''
95host.os.type:linux and event.category:process and event.type:start and event.action:exec and process.parent.name:kthreadd and (
96 process.executable:(/dev/shm/* or /tmp/* or /var/tmp/* or /var/www/*) or
97 process.name:(bash or csh or curl or dash or fish or id or ksh or nohup or setsid or sh or tcsh or wget or whoami or zsh)
98) and
99process.command_line:(
100 */dev/shm/* or */dev/tcp/* or */etc/init.d* or */etc/ld.so* or */etc/profile* or */etc/rc.local* or */etc/shadow* or */etc/ssh* or
101 */etc/sudoers* or */home/*/.ssh/* or */root/.ssh* or */tmp/* or */var/log/* or */var/run/* or */var/tmp/* or */var/www/* or
102 *base64* or *cron* or *xxd* or *~/.ssh/*
103) and not (
104 process.name:(true or cifs.upcall or dpkg or flock or gdbus or getopt or grep or mount or touch or umount or uname) or
105 process.command_line:(
106 "sh -c /bin/true" or */bin/ps* or */usr/bin/find* or */usr/bin/grep* or *ds_agent* or *gitlabrunner* or *nagios* or
107 *omsagent* or *pgrep*
108 ) or
109 process.executable:(
110 /lib/systemd/systemd-cgroups-agent or /proc/self/exe or /usr/local/axs-haproxy-monitoring/haproxy_stats.sh or /tmp/newroot/* or
111 /var/lib/docker/overlay2/* or /vz/root/*
112 )
113)
114'''
115
116[[rule.threat]]
117framework = "MITRE ATT&CK"
118
119 [rule.threat.tactic]
120 name = "Execution"
121 id = "TA0002"
122 reference = "https://attack.mitre.org/tactics/TA0002/"
123
124 [[rule.threat.technique]]
125 id = "T1059"
126 name = "Command and Scripting Interpreter"
127 reference = "https://attack.mitre.org/techniques/T1059/"
128
129 [[rule.threat.technique.subtechnique]]
130 name = "Unix Shell"
131 id = "T1059.004"
132 reference = "https://attack.mitre.org/techniques/T1059/004/"
133
134[rule.new_terms]
135field = "new_terms_fields"
136value = ["process.name", "host.id"]
137
138[[rule.new_terms.history_window_start]]
139field = "history_window_start"
140value = "now-14d"
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 Unusual Execution from Kernel Thread (kthreadd) Parent
The kernel thread (kthreadd) is a fundamental component in Linux systems responsible for managing kernel-level processes. Adversaries may exploit kthreadd to execute payloads from kernel space, thereby evading detection due to its trusted status. The detection rule identifies suspicious child processes initiated by kthreadd, focusing on unusual executable paths and command lines indicative of malicious activity, while filtering out known benign processes.
Possible investigation steps
- Review the alert details to identify the specific child process name and executable path that triggered the rule. Focus on paths like /dev/shm, /tmp, /var/tmp, and /var/www, which are commonly used for storing temporary or potentially malicious files.
- Examine the command line arguments associated with the suspicious process. Look for indicators of compromise such as references to sensitive files or directories like /etc/shadow, /etc/sudoers, or ~/.ssh, as well as suspicious commands like base64 or cron.
- Check the parent process details to confirm it is indeed kthreadd. Investigate any unusual behavior or anomalies in the parent process that might suggest exploitation or manipulation.
- Investigate the network activity of the host to identify any connections to suspicious IP addresses or domains, especially if the command line includes references to /dev/tcp or other network-related paths.
- Analyze the system logs and historical data to determine if similar alerts have been triggered in the past, which might indicate a persistent threat or repeated exploitation attempts.
- Assess the risk and impact of the detected activity by correlating it with other security events or alerts on the host, considering the medium severity and risk score of 47 associated with this rule.
False positive analysis
- Legitimate system maintenance tasks may trigger this rule, such as automated scripts running from temporary directories. Users can create exceptions for specific scripts or processes that are verified as safe.
- Development or testing environments often use temporary directories for executing scripts. Exclude known development tools or scripts from these environments to reduce noise.
- Some monitoring or backup tools might use command lines or executables that match the rule's criteria. Identify these tools and add them to the exclusion list to prevent false alerts.
- Custom administrative scripts that perform routine checks or updates might inadvertently match the rule. Review these scripts and exclude them if they are part of regular operations.
- If certain processes are consistently flagged but are known to be benign, consider adjusting the rule to exclude these specific processes or command lines to improve detection accuracy.
Response and remediation
- Isolate the affected host immediately to prevent further malicious activity and lateral movement within the network.
- Terminate any suspicious processes identified as child processes of kthreadd that match the alert criteria, ensuring to log the process details for further analysis.
- Conduct a thorough review of the file paths and command lines flagged in the alert to identify any unauthorized or malicious files or scripts. Remove or quarantine these files as necessary.
- Check for unauthorized modifications in critical system files and directories such as /etc/init.d, /etc/ssh, and /root/.ssh. Restore any altered files from a known good backup.
- Escalate the incident to the security operations team for a deeper forensic investigation to determine the root cause and entry point of the threat.
- Implement additional monitoring on the affected host and similar systems to detect any recurrence of the threat, focusing on the specific indicators identified in the alert.
- Update and patch the affected system to the latest security standards to mitigate vulnerabilities that may have been exploited by the adversary.
Related rules
- Kubectl Apply Pod from URL
- Kubernetes Direct API Request via Curl or Wget
- Potential Hex Payload Execution via Command-Line
- Suspicious Named Pipe Creation
- File Creation in /var/log via Suspicious Process