Skip to content

Commit 2f7be40

Browse files
Update latest docs
1 parent 7cf195e commit 2f7be40

File tree

1,023 files changed

+109427
-2973
lines changed

Some content is hidden

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

1,023 files changed

+109427
-2973
lines changed
Lines changed: 186 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,186 @@
1+
[[prebuilt-rule-8-19-13-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*: 218
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 libvirt_leaseshelper or
163+
s6-ipcserver-socketbinder or xinetd or libvirtd or veeamdeploymentsvc or dnsmasq or virtlogd or lynis or
164+
veeamtransport or bash or dash or sh or touch or podman or chrome_crashpad_handler or snmpd or automount or
165+
chrome or yumBackend.py or rhsmcertd-worker or snapd or cp or dotnet or leapp or haproxy or multipathd or
166+
falcond or python* or atopacctd or postmaster or httpd or pulseaudio or iptables or atd or package-cleanup or local
167+
) or
168+
file.name : (
169+
jem.*.pid or lynis.pid or redis.pid or yum.pid or MFS.pid or jenkins.pid or nvmupdate.pid or openlitespeed.pid or
170+
rhnsd.pid
171+
) or
172+
file.path : (/run/containerd/* or /var/run/docker/containerd/* or /var/run/jem*.pid)
173+
)
174+
175+
----------------------------------
176+
177+
*Framework*: MITRE ATT&CK^TM^
178+
179+
* Tactic:
180+
** Name: Execution
181+
** ID: TA0002
182+
** Reference URL: https://attack.mitre.org/tactics/TA0002/
183+
* Technique:
184+
** Name: Native API
185+
** ID: T1106
186+
** Reference URL: https://attack.mitre.org/techniques/T1106/
Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
[[prebuilt-rule-8-19-13-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. Attackers may use the setfacl utility to modify file and directory permissions in order to evade detection and maintain persistence on a compromised system.
5+
6+
*Rule type*: eql
7+
8+
*Rule indices*:
9+
10+
* auditbeat-*
11+
* endgame-*
12+
* logs-auditd_manager.auditd-*
13+
* logs-crowdstrike.fdr*
14+
* logs-endpoint.events.process*
15+
* logs-sentinel_one_cloud_funnel.*
16+
17+
*Severity*: low
18+
19+
*Risk score*: 21
20+
21+
*Runs every*: 5m
22+
23+
*Searches indices from*: now-9m ({ref}/common-options.html#date-math[Date Math format], see also <<rule-schedule, `Additional look-back time`>>)
24+
25+
*Maximum alerts per execution*: 100
26+
27+
*References*:
28+
29+
* https://www.uptycs.com/blog/threat-research-report-team/evasive-techniques-used-by-malicious-linux-shell-scripts
30+
31+
*Tags*:
32+
33+
* Domain: Endpoint
34+
* OS: Linux
35+
* Use Case: Threat Detection
36+
* Tactic: Defense Evasion
37+
* Data Source: Elastic Defend
38+
* Data Source: Elastic Endgame
39+
* Data Source: Auditd Manager
40+
* Data Source: Crowdstrike
41+
* Data Source: SentinelOne
42+
* Resources: Investigation Guide
43+
44+
*Version*: 107
45+
46+
*Rule authors*:
47+
48+
* Elastic
49+
50+
*Rule license*: Elastic License v2
51+
52+
53+
==== Investigation guide
54+
55+
56+
57+
*Triage and analysis*
58+
59+
60+
> **Disclaimer**:
61+
> 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.
62+
63+
64+
*Investigating Access Control List Modification via setfacl*
65+
66+
67+
Access Control Lists (ACLs) in Linux enhance file permission management by allowing more granular access control. The `setfacl` command modifies these ACLs, potentially altering who can access or modify files. Adversaries may exploit `setfacl` to stealthily change permissions, evading detection and maintaining persistence. The detection rule identifies suspicious `setfacl` executions, excluding benign patterns, to flag potential misuse.
68+
69+
70+
*Possible investigation steps*
71+
72+
73+
- Review the process details to confirm the execution of the setfacl command, focusing on the process.name and event.type fields to ensure the alert is valid.
74+
- Examine the process.command_line to understand the specific ACL modifications attempted and identify any unusual or unauthorized changes.
75+
- Investigate the user account associated with the process execution to determine if the action aligns with their typical behavior or role.
76+
- Check the process's parent process to identify how the setfacl command was initiated and assess if it was part of a legitimate workflow or a potential compromise.
77+
- Correlate the event with other security logs or alerts from the same host to identify any related suspicious activities or patterns that might indicate a broader attack.
78+
79+
80+
*False positive analysis*
81+
82+
83+
- Routine system maintenance tasks may trigger the rule if they involve legitimate use of setfacl. To manage this, identify and document regular maintenance scripts or processes that use setfacl and create exceptions for these specific command lines.
84+
- Backup operations that restore ACLs using setfacl can be mistaken for suspicious activity. Exclude these by adding exceptions for command lines that match known backup procedures, such as those using the --restore option.
85+
- Automated log management tools might use setfacl to manage permissions on log directories like /var/log/journal/. To prevent false positives, exclude these specific directory paths from triggering the rule.
86+
- Custom applications or services that require dynamic permission changes using setfacl could be flagged. Review these applications and, if deemed safe, add their specific command patterns to the exception list to avoid unnecessary alerts.
87+
88+
89+
*Response and remediation*
90+
91+
92+
- Immediately isolate the affected system from the network to prevent further unauthorized access or changes.
93+
- Review the process execution logs to identify any unauthorized users or processes that executed the `setfacl` command.
94+
- Revert any unauthorized ACL changes by restoring the original file permissions from a known good backup or configuration.
95+
- Conduct a thorough scan of the system for any additional signs of compromise, such as unauthorized user accounts or unexpected processes.
96+
- Update and patch the system to address any vulnerabilities that may have been exploited to gain access.
97+
- Implement stricter access controls and monitoring on critical systems to detect and prevent unauthorized ACL modifications in the future.
98+
- Escalate the incident to the security operations team for further investigation and to determine if additional systems are affected.
99+
100+
==== Rule query
101+
102+
103+
[source, js]
104+
----------------------------------
105+
process where host.os.type == "linux" and event.type == "start" and
106+
event.action in ("exec", "exec_event", "start", "ProcessRollup2", "executed", "process_started") and
107+
process.name == "setfacl" and not (
108+
?process.parent.executable in (
109+
"/opt/puppetlabs/puppet/bin/ruby", "/usr/libexec/dirsrv/ds_systemd_ask_password_acl", "/usr/lib/systemd/systemd-udevd",
110+
"/usr/bin/udevadm", "/usr/sbin/ds_systemd_ask_password_acl", "/usr/bin/su", "/bin/su"
111+
) or
112+
process.command_line == "/bin/setfacl --restore=-" or
113+
process.args == "/var/log/journal/" or
114+
?process.parent.name in ("stats.pl", "perl", "find") or
115+
?process.parent.command_line like~ "*ansible*" or
116+
?process.parent.args == "/opt/audit-log-acl.sh"
117+
)
118+
119+
----------------------------------
120+
121+
*Framework*: MITRE ATT&CK^TM^
122+
123+
* Tactic:
124+
** Name: Defense Evasion
125+
** ID: TA0005
126+
** Reference URL: https://attack.mitre.org/tactics/TA0005/
127+
* Technique:
128+
** Name: File and Directory Permissions Modification
129+
** ID: T1222
130+
** Reference URL: https://attack.mitre.org/techniques/T1222/
131+
* Sub-technique:
132+
** Name: Linux and Mac File and Directory Permissions Modification
133+
** ID: T1222.002
134+
** Reference URL: https://attack.mitre.org/techniques/T1222/002/

0 commit comments

Comments
 (0)