Local Scheduled Task Creation

edit

A scheduled task can be used by an adversary to establish persistence, move laterally, and/or escalate privileges.

Rule type: eql

Rule indices:

  • winlogbeat-*
  • logs-endpoint.events.*
  • logs-windows.*

Severity: low

Risk score: 21

Runs every: 5 minutes

Searches indices from: now-9m (Date Math format, see also Additional look-back time)

Maximum alerts per execution: 100

Tags:

  • Elastic
  • Host
  • Windows
  • Threat Detection
  • Persistence

Version: 9 (version history)

Added (Elastic Stack release): 7.6.0

Last modified (Elastic Stack release): 7.16.0

Rule authors: Elastic

Rule license: Elastic License v2

Potential false positives

edit

Legitimate scheduled tasks may be created during installation of new software.

Rule query

edit
sequence with maxspan=1m [process where event.type != "end" and
((process.name : ("cmd.exe", "wscript.exe", "rundll32.exe",
"regsvr32.exe", "wmic.exe", "mshta.exe",
"powershell.exe", "pwsh.exe", "powershell_ise.exe", "WmiPrvSe.exe",
"wsmprovhost.exe", "winrshost.exe") or
process.pe.original_file_name : ("cmd.exe", "wscript.exe",
"rundll32.exe", "regsvr32.exe", "wmic.exe", "mshta.exe",
"powershell.exe", "pwsh.dll", "powershell_ise.exe", "WmiPrvSe.exe",
"wsmprovhost.exe",
"winrshost.exe")) or process.code_signature.trusted == false)] by
process.entity_id [process where event.type == "start" and
(process.name : "schtasks.exe" or process.pe.original_file_name ==
"schtasks.exe") and process.args : ("/create", "-create") and
process.args : ("/RU", "/SC", "/TN", "/TR", "/F", "/XML") and /*
exclude SYSTEM SIDs - look for task creations by non-SYSTEM user */
not user.id : ("S-1-5-18", "S-1-5-19", "S-1-5-20")] by
process.parent.entity_id

Threat mapping

edit

Framework: MITRE ATT&CKTM

Rule version history

edit
Version 9 (7.16.0 release)
  • Updated query, changed from:

    sequence with maxspan=1m [process where event.type != "end" and
    ((process.name : ("cmd.exe", "wscript.exe", "rundll32.exe",
    "regsvr32.exe", "wmic.exe", "mshta.exe",
    "powershell.exe", "pwsh.exe", "WmiPrvSe.exe", "wsmprovhost.exe",
    "winrshost.exe") or process.pe.original_file_name : ("cmd.exe",
    "wscript.exe", "rundll32.exe", "regsvr32.exe", "wmic.exe",
    "mshta.exe", "powershell.exe",
    "pwsh.exe", "WmiPrvSe.exe", "wsmprovhost.exe",
    "winrshost.exe")) or process.code_signature.trusted == false)] by
    process.entity_id [process where event.type == "start" and
    (process.name : "schtasks.exe" or process.pe.original_file_name ==
    "schtasks.exe") and process.args : ("/create", "-create") and
    process.args : ("/RU", "/SC", "/TN", "/TR", "/F", "/XML") and /*
    exclude SYSTEM SIDs - look for task creations by non-SYSTEM user */
    not user.id : ("S-1-5-18", "S-1-5-19", "S-1-5-20")] by
    process.parent.entity_id
Version 8 (7.13.0 release)
  • Rule name changed from: Local Scheduled Task Commands
  • Updated query, changed from:

    event.category:process and event.type:(start or process_started) and
    process.name:schtasks.exe and process.args:(-change or -create or -run
    or -s or /S or /change or /create or /run)
Version 7 (7.12.0 release)
  • Formatting only
Version 6 (7.11.2 release)
  • Formatting only
Version 5 (7.10.0 release)
  • Formatting only
Version 4 (7.9.1 release)
  • Formatting only
Version 3 (7.9.0 release)
  • Updated query, changed from:

    event.action:"Process Create (rule: ProcessCreate)" and
    process.name:schtasks.exe and process.args:(-change or -create or -run
    or -s or /S or /change or /create or /run)
Version 2 (7.7.0 release)
  • Updated query, changed from:

    event.action:"Process Create (rule: ProcessCreate)" and
    process.name:schtasks.exe and process.args:("/create" or "-create" or
    "/S" or "-s" or "/run" or "-run" or "/change" or "-change")