Detection: WinEvent Scheduled Task Created Within Public Path

Description

The following analytic detects the creation of scheduled tasks within user-writable paths using Windows Security EventCode 4698. It identifies tasks registered via schtasks.exe or TaskService that execute commands from directories like Public, ProgramData, Temp, and AppData. This behavior is significant as it may indicate an attempt to establish persistence or execute unauthorized commands. If confirmed malicious, an attacker could maintain long-term access, escalate privileges, or execute arbitrary code, posing a severe threat to system integrity and security.

 1`wineventlog_security`
 2EventCode=4698
 3TaskContent IN (
 4  "*\\users\\public\\*", "*\\programdata\\*", "*\\temp\\*",
 5  "*\\Windows\\Tasks\\*", "*\\appdata\\*", "*\\perflogs\\*"
 6  )
 7
 8| stats count min(_time) as firstTime max(_time) as lastTime
 9  by Computer, TaskName, TaskContent, user
10
11|  rename Computer as dest
12
13| `security_content_ctime(firstTime)`
14
15| `security_content_ctime(lastTime)`
16
17| `winevent_scheduled_task_created_within_public_path_filter`

Data Source

Name Platform Sourcetype Source
Windows Event Log Security 4698 Windows icon Windows 'XmlWinEventLog' 'XmlWinEventLog:Security'

Macros Used

Name Value
security_content_ctime convert timeformat="%Y-%m-%dT%H:%M:%S" ctime($field$)
winevent_scheduled_task_created_within_public_path_filter search *
winevent_scheduled_task_created_within_public_path_filter is an empty macro by default. It allows the user to filter out any results (false positives) without editing the SPL.

Annotations

Default Configuration

This detection is configured by default in Splunk Enterprise Security to run with the following settings:

Setting Value
Disabled true
Cron Schedule 0 * * * *
Earliest Time -70m@m
Latest Time -10m@m
Schedule Window auto
Creates Finding (Notable) Yes
Rule Title %name%
Rule Description %description%
Notable Event Fields user, dest
Creates Intermediate Finding (Risk Event) No
TTP detections generate a Finding (Notable) and may generate Intermediate Findings (Risk Events) for associated entities.

Implementation

To successfully implement this search, you need to be ingesting Windows Security Event Logs with 4698 EventCode enabled. The Windows TA is also required.

Known False Positives

False positives are possible if legitimate applications are allowed to register tasks in public paths. Filter as needed based on paths that are used legitimately.

Associated Analytic Story

Finding

Title Entity Field Entity Type Risk Score
A windows scheduled task was created (task name=$TaskName$) on $dest$ dest system 50

References

Detection Testing

Test Type Status Dataset Source Sourcetype
Validation Passing N/A N/A N/A
Unit Passing Dataset XmlWinEventLog:Security XmlWinEventLog
Integration ✅ Passing Dataset XmlWinEventLog:Security XmlWinEventLog

Replay any dataset to Splunk Enterprise by using our replay.py tool or the UI. Alternatively you can replay a dataset into a Splunk Attack Range


Source: GitHub | Version: 25