Skip to content

Commit 356523d

Browse files
Update latest docs (#6008)
1 parent 853c6a9 commit 356523d

File tree

276 files changed

+17310
-469
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

276 files changed

+17310
-469
lines changed
Lines changed: 183 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,183 @@
1+
[[prebuilt-rule-8-12-26-abnormal-process-id-or-lock-file-created]]
2+
=== Abnormal Process ID or Lock File Created
3+
4+
Identifies the creation of a Process ID (PID), lock or reboot file created in temporary file storage paradigm (tmpfs) directory /var/run. On Linux, the PID files typically hold the process ID to track previous copies running and manage other tasks. Certain Linux malware use the /var/run directory for holding data, executables and other tasks, disguising itself or these files as legitimate PID files.
5+
6+
*Rule type*: new_terms
7+
8+
*Rule indices*:
9+
10+
* logs-endpoint.events.*
11+
* endgame-*
12+
13+
*Severity*: medium
14+
15+
*Risk score*: 47
16+
17+
*Runs every*: 5m
18+
19+
*Searches indices from*: now-9m ({ref}/common-options.html#date-math[Date Math format], see also <<rule-schedule, `Additional look-back time`>>)
20+
21+
*Maximum alerts per execution*: 100
22+
23+
*References*:
24+
25+
* https://www.sandflysecurity.com/blog/linux-file-masquerading-and-malicious-pids-sandfly-1-2-6-update/
26+
* https://twitter.com/GossiTheDog/status/1522964028284411907
27+
* https://exatrack.com/public/Tricephalic_Hellkeeper.pdf
28+
* https://www.elastic.co/security-labs/a-peek-behind-the-bpfdoor
29+
30+
*Tags*:
31+
32+
* Domain: Endpoint
33+
* OS: Linux
34+
* Use Case: Threat Detection
35+
* Tactic: Execution
36+
* Threat: BPFDoor
37+
* Resources: Investigation Guide
38+
* Data Source: Elastic Defend
39+
* Data Source: Elastic Endgame
40+
41+
*Version*: 214
42+
43+
*Rule authors*:
44+
45+
* Elastic
46+
47+
*Rule license*: Elastic License v2
48+
49+
50+
==== Investigation guide
51+
52+
53+
54+
*Triage and analysis*
55+
56+
57+
58+
*Investigating Abnormal Process ID or Lock File Created*
59+
60+
61+
Linux applications may need to save their process identification number (PID) for various purposes: from signaling that a program is running to serving as a signal that a previous instance of an application didn't exit successfully. PID files contain its creator process PID in an integer value.
62+
63+
Linux lock files are used to coordinate operations in files so that conflicts and race conditions are prevented.
64+
65+
This rule identifies the creation of PID, lock, or reboot files in the /var/run/ directory. Attackers can masquerade malware, payloads, staged data for exfiltration, and more as legitimate PID files.
66+
67+
68+
*Possible investigation steps*
69+
70+
71+
- Retrieve the file and determine if it is malicious:
72+
- Check the contents of the PID files. They should only contain integer strings.
73+
- Check the file type of the lock and PID files to determine if they are executables. This is only observed in malicious files.
74+
- Check the size of the subject file. Legitimate PID files should be under 10 bytes.
75+
- Check if the lock or PID file has high entropy. This typically indicates an encrypted payload.
76+
- Analysts can use tools like `ent` to measure entropy.
77+
- Examine the reputation of the SHA-256 hash in the PID file. Use a database like VirusTotal to identify additional pivots and artifacts for investigation.
78+
- Trace the file's creation to ensure it came from a legitimate or authorized process.
79+
- Investigate other alerts associated with the user/host during the past 48 hours.
80+
- Investigate any abnormal account behavior, such as command executions, file creations or modifications, and network connections.
81+
- Investigate any abnormal behavior by the subject process such as network connections, file modifications, and any spawned child processes.
82+
83+
84+
*False positive analysis*
85+
86+
87+
- False positives can appear if the PID file is legitimate and holding a process ID as intended. If the PID file is an executable or has a file size that's larger than 10 bytes, it should be ruled suspicious.
88+
- If this activity is expected and noisy in your environment, consider adding exceptions — preferably with a combination of file name and process executable conditions.
89+
90+
91+
*Response and remediation*
92+
93+
94+
- Initiate the incident response process based on the outcome of the triage.
95+
- Isolate the involved host to prevent further post-compromise behavior.
96+
- Investigate credential exposure on systems compromised or used by the attacker to ensure all compromised accounts are identified. Reset passwords for these accounts and other potentially compromised credentials, such as email, business systems, and web services.
97+
- Block the identified indicators of compromise (IoCs).
98+
- Take actions to terminate processes and connections used by the attacker.
99+
- Run a full antimalware scan. This may reveal additional artifacts left in the system, persistence mechanisms, and malware components.
100+
- Determine the initial vector abused by the attacker and take action to prevent reinfection through the same vector.
101+
- Using the incident response data, update logging and audit policies to improve the mean time to detect (MTTD) and the mean time to respond (MTTR).
102+
103+
104+
==== Setup
105+
106+
107+
108+
*Setup*
109+
110+
111+
This rule requires data coming in from Elastic Defend.
112+
113+
114+
*Elastic Defend Integration Setup*
115+
116+
Elastic 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.
117+
118+
119+
*Prerequisite Requirements:*
120+
121+
- Fleet is required for Elastic Defend.
122+
- To configure Fleet Server refer to the https://www.elastic.co/guide/en/fleet/current/fleet-server.html[documentation].
123+
124+
125+
*The following steps should be executed in order to add the Elastic Defend integration on a Linux System:*
126+
127+
- Go to the Kibana home page and click "Add integrations".
128+
- In the query bar, search for "Elastic Defend" and select the integration to see more details about it.
129+
- Click "Add Elastic Defend".
130+
- Configure the integration name and optionally add a description.
131+
- Select the type of environment you want to protect, either "Traditional Endpoints" or "Cloud Workloads".
132+
- 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. https://www.elastic.co/guide/en/security/current/configure-endpoint-integration-policy.html[Helper guide].
133+
- We suggest selecting "Complete EDR (Endpoint Detection and Response)" as a configuration setting, that provides "All events; all preventions"
134+
- 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.
135+
For more details on Elastic Agent configuration settings, refer to the https://www.elastic.co/guide/en/fleet/8.10/agent-policy.html[helper guide].
136+
- Click "Save and Continue".
137+
- 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.
138+
For more details on Elastic Defend refer to the https://www.elastic.co/guide/en/security/current/install-endpoint.html[helper guide].
139+
140+
141+
==== Rule query
142+
143+
144+
[source, js]
145+
----------------------------------
146+
host.os.type:linux and event.category:file and event.action:(creation or file_create_event) and
147+
file.extension:(pid or lock or reboot) and file.path:(/var/run/* or /run/*) and (
148+
(process.name : (
149+
bash or dash or sh or tcsh or csh or zsh or ksh or fish or ash or touch or nano or vim or vi or editor or mv or cp)
150+
) or (
151+
process.executable : (
152+
./* or /tmp/* or /var/tmp/* or /dev/shm/* or /var/run/* or /boot/* or /srv/* or /run/*
153+
))
154+
) and not (
155+
process.executable : (
156+
/tmp/newroot/* or /run/containerd/* or /run/k3s/containerd/* or /run/k0s/container* or /snap/* or /vz/* or
157+
/var/lib/docker/* or /etc/*/universal-hooks/pkgs/mysql-community-server/* or /var/lib/snapd/* or /etc/rubrik/* or
158+
/run/udev/data/*
159+
) or
160+
process.name : (
161+
go or git or containerd* or snap-confine or cron or crond or sshd or unattended-upgrade or vzctl or ifup or
162+
rpcbind or runc or gitlab-runner-helper or elastic-agent or metricbeat or redis-server or
163+
s6-ipcserver-socketbinder or xinetd
164+
) or
165+
file.name : (
166+
jem.*.pid or lynis.pid or redis.pid or yum.pid or MFS.pid or jenkins.pid or nvmupdate.pid or openlitespeed.pid or
167+
rhnsd.pid
168+
) or
169+
file.path : (/run/containerd/* or /var/run/docker/containerd/* or /var/run/jem*.pid)
170+
)
171+
172+
----------------------------------
173+
174+
*Framework*: MITRE ATT&CK^TM^
175+
176+
* Tactic:
177+
** Name: Execution
178+
** ID: TA0002
179+
** Reference URL: https://attack.mitre.org/tactics/TA0002/
180+
* Technique:
181+
** Name: Native API
182+
** ID: T1106
183+
** Reference URL: https://attack.mitre.org/techniques/T1106/
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
[[prebuilt-rule-8-12-26-access-control-list-modification-via-setfacl]]
2+
=== Access Control List Modification via setfacl
3+
4+
This rule detects Linux Access Control List (ACL) modification via the setfacl command.
5+
6+
*Rule type*: eql
7+
8+
*Rule indices*:
9+
10+
* logs-endpoint.events.*
11+
* endgame-*
12+
* auditbeat-*
13+
* logs-auditd_manager.auditd-*
14+
15+
*Severity*: low
16+
17+
*Risk score*: 21
18+
19+
*Runs every*: 5m
20+
21+
*Searches indices from*: now-9m ({ref}/common-options.html#date-math[Date Math format], see also <<rule-schedule, `Additional look-back time`>>)
22+
23+
*Maximum alerts per execution*: 100
24+
25+
*References*:
26+
27+
* https://www.uptycs.com/blog/threat-research-report-team/evasive-techniques-used-by-malicious-linux-shell-scripts
28+
29+
*Tags*:
30+
31+
* Domain: Endpoint
32+
* OS: Linux
33+
* Use Case: Threat Detection
34+
* Tactic: Defense Evasion
35+
* Data Source: Elastic Defend
36+
* Data Source: Elastic Endgame
37+
* Data Source: Auditd Manager
38+
39+
*Version*: 2
40+
41+
*Rule authors*:
42+
43+
* Elastic
44+
45+
*Rule license*: Elastic License v2
46+
47+
48+
==== Rule query
49+
50+
51+
[source, js]
52+
----------------------------------
53+
process where host.os.type == "linux" and event.type == "start" and
54+
event.action in ("exec", "exec_event", "executed", "process_started") and
55+
process.name == "setfacl" and not (
56+
process.command_line == "/bin/setfacl --restore=-" or
57+
process.args == "/var/log/journal/"
58+
)
59+
60+
----------------------------------
61+
62+
*Framework*: MITRE ATT&CK^TM^
63+
64+
* Tactic:
65+
** Name: Defense Evasion
66+
** ID: TA0005
67+
** Reference URL: https://attack.mitre.org/tactics/TA0005/
68+
* Technique:
69+
** Name: File and Directory Permissions Modification
70+
** ID: T1222
71+
** Reference URL: https://attack.mitre.org/techniques/T1222/
72+
* Sub-technique:
73+
** Name: Linux and Mac File and Directory Permissions Modification
74+
** ID: T1222.002
75+
** Reference URL: https://attack.mitre.org/techniques/T1222/002/

0 commit comments

Comments
 (0)