Skip to content

Commit 1704924

Browse files
terrancedejesusDefSecSentinelbrokensound77
authored
[New Rule] Abnormal Process ID File Creation (elastic#1964)
* adding rule detection * changed Rule ID * Update rules/linux/execution_abnormal_process_id_file_created.toml Adding reboot extension as well. Reference: https://exatrack.com/public/Tricephalic_Hellkeeper.pdf * Update rules/linux/execution_abnormal_process_id_file_created.toml Adding reboot to description. Reference: https://exatrack.com/public/Tricephalic_Hellkeeper.pdf * Update rules/linux/execution_abnormal_process_id_file_created.toml Added additional reference to similar threat. * Update rules/linux/execution_abnormal_process_id_file_created.toml Co-authored-by: Justin Ibarra <[email protected]> * Update rules/linux/execution_abnormal_process_id_file_created.toml Co-authored-by: Justin Ibarra <[email protected]> * added rule for a process starting where the executable's name represented a PID file * Adjusted user.id value from integer to string * Added simple investigation notes and osquery coverage * TOML linting * Updated date to reflect recent changes Co-authored-by: Colson Wilhoit <[email protected]> Co-authored-by: Justin Ibarra <[email protected]>
1 parent 19ff825 commit 1704924

File tree

2 files changed

+142
-0
lines changed

2 files changed

+142
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
[metadata]
2+
creation_date = "2022/05/11"
3+
maturity = "production"
4+
updated_date = "2022/05/12"
5+
6+
[rule]
7+
author = ["Elastic"]
8+
description = """
9+
Identifies the creation of a Process ID (PID), lock or reboot file created in temporary file storage paradigm (tmpfs)
10+
directory /var/run. On Linux, the PID files typically hold the process ID to track previous copies running and manage
11+
other tasks. Certain Linux malware use the /var/run directory for holding data, executables and other tasks, disguising
12+
itself or these files as legitimate PID files.
13+
"""
14+
false_positives = [
15+
"""
16+
False-Positives (FP) can appear if the PID file is legitimate and holding a process ID as intended. To
17+
differentiate, if the PID file is an executable or larger than 10 bytes, it should be ruled suspicious.
18+
""",
19+
]
20+
from = "now-9m"
21+
index = ["logs-endpoint.events.*"]
22+
language = "eql"
23+
license = "Elastic License v2"
24+
name = "Abnormal Process ID or Lock File Created"
25+
note = """## Triage and analysis
26+
27+
### Investigating Abnormal Process ID or Lock File Created
28+
Detection alerts from this rule indicate that an unusual PID file was created and could potentially have alternate purposes during an intrusion. Here are some possible avenues of investigation:
29+
- Run the following in Osquery to quickly identify unsual PID file size: "SELECT f.size, f.uid, f.type, f.path from file f WHERE path like '/var/run/%pid';"
30+
- Examine the history of this file creation and from which process it was created by using the "lsof" command.
31+
- Examine the contents of the PID file itself, simply by running the "cat" command to determine if the expected process ID integer exists and if not, the PID file is not legitimate.
32+
- Examine the reputation of the SHA256 hash from the PID file in a database like VirusTotal to identify additional pivots and artifacts for investigation."""
33+
references = [
34+
"https://www.sandflysecurity.com/blog/linux-file-masquerading-and-malicious-pids-sandfly-1-2-6-update/",
35+
"https://twitter.com/GossiTheDog/status/1522964028284411907",
36+
"https://exatrack.com/public/Tricephalic_Hellkeeper.pdf",
37+
]
38+
risk_score = 43
39+
rule_id = "cac91072-d165-11ec-a764-f661ea17fbce"
40+
severity = "medium"
41+
tags = ["Elastic", "Host", "Linux", "Threat Detection", "Execution", "BPFDoor"]
42+
timestamp_override = "event.ingested"
43+
type = "eql"
44+
45+
query = '''
46+
/* add file size filters when data is available */
47+
file where event.type == "creation" and user.id == "0" and
48+
file.path regex~ """/var/run/\w+\.(pid|lock|reboot)""" and file.extension in ("pid","lock","reboot") and
49+
50+
/* handle common legitimate files */
51+
52+
not file.name in (
53+
"auditd.pid",
54+
"python*",
55+
"apport.pid",
56+
"apport.lock",
57+
"kworker*",
58+
"gdm3.pid",
59+
"sshd.pid",
60+
"acpid.pid",
61+
"unattended-upgrades.lock",
62+
"unattended-upgrades.pid",
63+
"cmd.pid",
64+
"cron*.pid"
65+
)
66+
'''
67+
68+
69+
[[rule.threat]]
70+
framework = "MITRE ATT&CK"
71+
[[rule.threat.technique]]
72+
id = "T1106"
73+
name = "Native API"
74+
reference = "https://attack.mitre.org/techniques/T1106/"
75+
76+
77+
[rule.threat.tactic]
78+
id = "TA0002"
79+
name = "Execution"
80+
reference = "https://attack.mitre.org/tactics/TA0002/"
81+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
[metadata]
2+
creation_date = "2022/05/11"
3+
maturity = "production"
4+
updated_date = "2022/05/12"
5+
6+
[rule]
7+
author = ["Elastic"]
8+
description = """
9+
Identifies a new process starting from a process ID (PID), lock or reboot file within the temporary file storage
10+
paradigm (tmpfs) directory /var/run directory. On Linux, the PID files typically hold the process ID to track previous
11+
copies running and manage other tasks. Certain Linux malware use the /var/run directory for holding data, executables
12+
and other tasks, disguising itself or these files as legitimate PID files.
13+
"""
14+
false_positives = [
15+
"""
16+
False-Positives (FP) should be at a minimum with this detection as PID files are meant to hold process IDs, not
17+
inherently be executables that spawn processes.
18+
""",
19+
]
20+
from = "now-9m"
21+
index = ["logs-endpoint.events.*"]
22+
language = "eql"
23+
license = "Elastic License v2"
24+
name = "Process Started from Process ID (PID) File"
25+
note = """## Triage and analysis
26+
27+
### Investigating Process Started from Process ID (PID) File
28+
Detection alerts from this rule indicate a process spawned from an executable masqueraded as a legitimate PID file which is very unusual and should not occur. Here are some possible avenues of investigation:
29+
- Examine parent and child process relationships of the new process to determine if other processes are running.
30+
- Examine the /var/run directory using Osquery to determine other potential PID files with unsually large file sizes, indicative of it being an executable: "SELECT f.size, f.uid, f.type, f.path from file f WHERE path like '/var/run/%%';"
31+
- Examine the reputation of the SHA256 hash from the PID file in a database like VirusTotal to identify additional pivots and artifacts for investigation."""
32+
references = [
33+
"https://www.sandflysecurity.com/blog/linux-file-masquerading-and-malicious-pids-sandfly-1-2-6-update/",
34+
"https://twitter.com/GossiTheDog/status/1522964028284411907",
35+
"https://exatrack.com/public/Tricephalic_Hellkeeper.pdf",
36+
]
37+
risk_score = 73
38+
rule_id = "3688577a-d196-11ec-90b0-f661ea17fbce"
39+
severity = "high"
40+
tags = ["Elastic", "Host", "Linux", "Threat Detection", "Execution", "BPFDoor"]
41+
timestamp_override = "event.ingested"
42+
type = "eql"
43+
44+
query = '''
45+
process where event.type == "start" and user.id == "0" and process.executable regex~ """/var/run/\w+\.(pid|lock|reboot)"""
46+
'''
47+
48+
49+
[[rule.threat]]
50+
framework = "MITRE ATT&CK"
51+
[[rule.threat.technique]]
52+
id = "T1059"
53+
name = "Command and Scripting Interpreter"
54+
reference = "https://attack.mitre.org/techniques/T1059/"
55+
56+
57+
[rule.threat.tactic]
58+
id = "TA0002"
59+
name = "Execution"
60+
reference = "https://attack.mitre.org/tactics/TA0002/"
61+

0 commit comments

Comments
 (0)