Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
[[prebuilt-rule-8-19-34-a-scheduled-task-was-created]]
=== A scheduled task was created

Indicates the creation of a scheduled task using Windows event logs. Adversaries can use these to establish persistence, move laterally, and/or escalate privileges.

*Rule type*: eql

*Rule indices*:

* logs-system.security*
* logs-windows.forwarded*
* winlogbeat-*

*Severity*: low

*Risk score*: 21

*Runs every*: 5m

*Searches indices from*: now-9m ({ref}/common-options.html#date-math[Date Math format], see also <<rule-schedule, `Additional look-back time`>>)

*Maximum alerts per execution*: 100

*References*:

* https://docs.microsoft.com/en-us/windows/security/threat-protection/auditing/event-4698

*Tags*:

* Domain: Endpoint
* OS: Windows
* Use Case: Threat Detection
* Tactic: Persistence
* Data Source: Windows Security Event Logs
* Resources: Investigation Guide
* Noise: High
* Performance: Normal
* Profile: Aggressive
* Rule Type: Event Correlation (EQL)
* Platform: Windows

*Version*: 116

*Rule authors*:

* Elastic

*Rule license*: Elastic License v2


==== Investigation guide



*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 A scheduled task was created*


Scheduled tasks in Windows automate routine tasks, enhancing efficiency. However, adversaries exploit this feature to maintain persistence, move laterally, or escalate privileges by creating malicious tasks. The detection rule identifies suspicious task creation by filtering out benign tasks and those initiated by system accounts, focusing on potential threats. This approach helps security analysts pinpoint unauthorized task creation indicative of malicious activity.


*Possible investigation steps*


- Review the user account associated with the task creation to determine if it is a known and authorized user, ensuring it is not a system account by checking that the username does not end with a dollar sign.
- Examine the task name and path in the event data to identify if it matches any known benign tasks or if it appears suspicious or unfamiliar.
- Investigate the origin of the task creation by checking the source IP address or hostname, if available, to determine if it aligns with expected network activity.
- Check the task's scheduled actions and triggers to understand what the task is designed to execute and when, looking for any potentially harmful or unexpected actions.
- Correlate the task creation event with other security events or logs around the same time to identify any related suspicious activities or anomalies.


*False positive analysis*


- Scheduled tasks created by system accounts or computer accounts are often benign. These can be excluded by filtering out user names ending with a dollar sign, which typically represent system accounts.
- Tasks associated with common software updates or maintenance, such as those from Hewlett-Packard or Microsoft Visual Studio, are generally non-threatening. These can be excluded by specifying their full task names in the exclusion list.
- OneDrive update tasks are frequently triggered and are usually safe. Exclude these by using patterns that match their task names, such as those starting with "OneDrive Standalone Update Task".
- Regularly review and update the exclusion list to include any new benign tasks that are identified over time, ensuring that the rule remains effective without generating unnecessary alerts.


*Response and remediation*


- Immediately isolate the affected system from the network to prevent potential lateral movement by the adversary.
- Terminate any suspicious scheduled tasks identified by the alert to halt any ongoing malicious activity.
- Conduct a thorough review of the system's scheduled tasks to identify and remove any other unauthorized or suspicious tasks.
- Restore the system from a known good backup if any malicious activity has been confirmed and has potentially compromised system integrity.
- Update and patch the system to the latest security standards to close any vulnerabilities that may have been exploited.
- Monitor the system and network for any signs of re-infection or further unauthorized scheduled task creation.
- Escalate the incident to the security operations center (SOC) or incident response team for further investigation and to determine if additional systems are affected.

==== Setup



*Setup*


Audit Other Object Access Events must be enabled to generate the events used by this rule.
Setup instructions: https://ela.st/audit-other-object-access-events


==== Rule query


[source, js]
----------------------------------
iam where host.os.type == "windows" and event.action == "scheduled-task-created" and

/* excluding tasks created by the computer account */
not user.name : "*$" and

/* TaskContent is not parsed, exclude by full taskname noisy ones */
not winlog.event_data.TaskName : (
"\\CreateExplorerShellUnelevatedTask",
"\\Hewlett-Packard\\HPDeviceCheck",
"\\Hewlett-Packard\\HP Support Assistant\\WarrantyChecker",
"\\Hewlett-Packard\\HP Support Assistant\\WarrantyChecker_backup",
"\\Hewlett-Packard\\HP Web Products Detection",
"\\Microsoft\\VisualStudio\\Updates\\BackgroundDownload",
"\\OneDrive Standalone Update Task-S-1-5-21*",
"\\OneDrive Standalone Update Task-S-1-12-1-*",
"\\SoftLanding\\S-1-5-21-*\\SoftLanding*",
"\\SoftLanding\\S-1-12-*\\SoftLanding*",
"\\OneDrive Reporting Task-S-1-5-21-*",
"\\OneDrive Reporting Task-S-1-12-1-*",
"\\GoogleUserPEH\\RunPlatformExperienceHelper*",
"\\Mozilla\\Firefox Default Browser Agent*",
"\\Microsoft\\Office\\Office Background Push Maintenance",
"\\Microsoft\\Windows\\GroupPolicy\\GPUpdate"
)

----------------------------------

*Framework*: MITRE ATT&CK^TM^

* Tactic:
** Name: Persistence
** ID: TA0003
** Reference URL: https://attack.mitre.org/tactics/TA0003/
* Technique:
** Name: Scheduled Task/Job
** ID: T1053
** Reference URL: https://attack.mitre.org/techniques/T1053/
* Sub-technique:
** Name: Scheduled Task
** ID: T1053.005
** Reference URL: https://attack.mitre.org/techniques/T1053/005/
Original file line number Diff line number Diff line change
@@ -0,0 +1,203 @@
[[prebuilt-rule-8-19-34-abnormal-process-id-or-lock-file-created]]
=== Abnormal Process ID or Lock File Created

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.

*Rule type*: new_terms

*Rule indices*:

* logs-endpoint.events.*
* endgame-*

*Severity*: medium

*Risk score*: 47

*Runs every*: 5m

*Searches indices from*: now-9m ({ref}/common-options.html#date-math[Date Math format], see also <<rule-schedule, `Additional look-back time`>>)

*Maximum alerts per execution*: 100

*References*:

* https://www.sandflysecurity.com/blog/linux-file-masquerading-and-malicious-pids-sandfly-1-2-6-update/
* https://twitter.com/GossiTheDog/status/1522964028284411907
* https://exatrack.com/public/Tricephalic_Hellkeeper.pdf
* https://www.elastic.co/security-labs/a-peek-behind-the-bpfdoor

*Tags*:

* Domain: Endpoint
* OS: Linux
* Use Case: Threat Detection
* Tactic: Execution
* Threat: BPFDoor
* Resources: Investigation Guide
* Data Source: Elastic Defend
* Data Source: Elastic Endgame
* Noise: High
* Performance: Normal
* Profile: Aggressive
* Rule Type: New Terms
* Platform: Linux

*Version*: 220

*Rule authors*:

* Elastic

*Rule license*: Elastic License v2


==== Investigation guide



*Triage and analysis*



*Investigating Abnormal Process ID or Lock File Created*


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.

Linux lock files are used to coordinate operations in files so that conflicts and race conditions are prevented.

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.


*Possible investigation steps*


- Retrieve the file and determine if it is malicious:
- Check the contents of the PID files. They should only contain integer strings.
- Check the file type of the lock and PID files to determine if they are executables. This is only observed in malicious files.
- Check the size of the subject file. Legitimate PID files should be under 10 bytes.
- Check if the lock or PID file has high entropy. This typically indicates an encrypted payload.
- Analysts can use tools like `ent` to measure entropy.
- 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.
- Trace the file's creation to ensure it came from a legitimate or authorized process.
- Investigate other alerts associated with the user/host during the past 48 hours.
- Investigate any abnormal account behavior, such as command executions, file creations or modifications, and network connections.
- Investigate any abnormal behavior by the subject process such as network connections, file modifications, and any spawned child processes.


*False positive analysis*


- 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.
- If this activity is expected and noisy in your environment, consider adding exceptions — preferably with a combination of file name and process executable conditions.


*Response and remediation*


- Initiate the incident response process based on the outcome of the triage.
- Isolate the involved host to prevent further post-compromise behavior.
- 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.
- Block the identified indicators of compromise (IoCs).
- Take actions to terminate processes and connections used by the attacker.
- Run a full antimalware scan. This may reveal additional artifacts left in the system, persistence mechanisms, and malware components.
- Determine the initial vector abused by the attacker and take action to prevent reinfection through the same vector.
- 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).


==== Setup



*Setup*


This rule requires data coming in from Elastic Defend.


*Elastic Defend Integration Setup*

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.


*Prerequisite Requirements:*

- Fleet is required for Elastic Defend.
- To configure Fleet Server refer to the https://www.elastic.co/guide/en/fleet/current/fleet-server.html[documentation].


*The following steps should be executed in order to add the Elastic Defend integration on a Linux System:*

- Go to the Kibana home page and click "Add integrations".
- In the query bar, search for "Elastic Defend" and select the integration to see more details about it.
- Click "Add Elastic Defend".
- Configure the integration name and optionally add a description.
- Select the type of environment you want to protect, either "Traditional Endpoints" or "Cloud Workloads".
- 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].
- We suggest selecting "Complete EDR (Endpoint Detection and Response)" as a configuration setting, that provides "All events; all preventions"
- 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.
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].
- Click "Save and Continue".
- 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.
For more details on Elastic Defend refer to the https://www.elastic.co/guide/en/security/current/install-endpoint.html[helper guide].


==== Rule query


[source, js]
----------------------------------
host.os.type:linux and event.category:file and event.action:(creation or file_create_event) and
file.extension:(pid or lock or reboot) and file.path:(/var/run/* or /run/*) and (
(process.name : (
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)
) or (
process.executable : (
./* or /tmp/* or /var/tmp/* or /dev/shm/* or /var/run/* or /boot/* or /srv/* or /run/*
))
) and not (
process.executable : (
/tmp/newroot/* or /run/containerd/* or /run/k3s/containerd/* or /run/k0s/container* or /snap/* or /vz/* or
/var/lib/docker/* or /etc/*/universal-hooks/pkgs/mysql-community-server/* or /var/lib/snapd/* or /etc/rubrik/* or
/run/udev/data/*
) or
process.name : (
go or git or containerd* or snap-confine or cron or crond or sshd or unattended-upgrade or vzctl or ifup or
rpcbind or runc or gitlab-runner-helper or elastic-agent or metricbeat or redis-server or libvirt_leaseshelper or
s6-ipcserver-socketbinder or xinetd or libvirtd or veeamdeploymentsvc or dnsmasq or virtlogd or lynis or
veeamtransport or bash or dash or sh or touch or podman or chrome_crashpad_handler or snmpd or automount or
chrome or yumBackend.py or rhsmcertd-worker or snapd or cp or dotnet or leapp or haproxy or multipathd or
falcond or python* or atopacctd or postmaster or httpd or pulseaudio or iptables or atd or package-cleanup or local
) or
file.name : (
jem.*.pid or lynis.pid or redis.pid or yum.pid or MFS.pid or jenkins.pid or nvmupdate.pid or openlitespeed.pid or
rhnsd.pid
) or
file.path : (/run/containerd/* or /var/run/docker/containerd/* or /var/run/jem*.pid)
)

----------------------------------

*Framework*: MITRE ATT&CK^TM^

* Tactic:
** Name: Execution
** ID: TA0002
** Reference URL: https://attack.mitre.org/tactics/TA0002/
* Technique:
** Name: Native API
** ID: T1106
** Reference URL: https://attack.mitre.org/techniques/T1106/
* Tactic:
** Name: Defense Evasion
** ID: TA0005
** Reference URL: https://attack.mitre.org/tactics/TA0005/
* Technique:
** Name: Masquerading
** ID: T1036
** Reference URL: https://attack.mitre.org/techniques/T1036/
* Sub-technique:
** Name: Match Legitimate Resource Name or Location
** ID: T1036.005
** Reference URL: https://attack.mitre.org/techniques/T1036/005/
Loading
Loading