Scheduled Task Created by a Windows Script

A scheduled task was created by a Windows script via cscript.exe, wscript.exe or powershell.exe. This can be abused by an adversary to establish persistence.

Elastic rule (View on GitHub)

  1[metadata]
  2creation_date = "2020/11/29"
  3integration = ["endpoint", "windows"]
  4maturity = "production"
  5updated_date = "2026/09/18"
  6
  7[rule]
  8author = ["Elastic"]
  9description = """
 10A scheduled task was created by a Windows script via cscript.exe, wscript.exe or powershell.exe. This can be abused by
 11an adversary to establish persistence.
 12"""
 13false_positives = ["Legitimate scheduled tasks may be created during installation of new software."]
 14from = "now-9m"
 15index = [
 16    "winlogbeat-*",
 17    "logs-endpoint.events.registry-*",
 18    "logs-endpoint.events.library-*",
 19    "logs-windows.sysmon_operational-*",
 20    "endgame-*",
 21]
 22language = "eql"
 23license = "Elastic License v2"
 24name = "Scheduled Task Created by a Windows Script"
 25note = """## Triage and analysis
 26
 27Decode the base64 encoded Tasks Actions registry value to investigate the task's configured action."""
 28risk_score = 47
 29rule_id = "689b9d57-e4d5-4357-ad17-9c334609d79a"
 30severity = "medium"
 31tags = [
 32    "Domain: Endpoint",
 33    "OS: Windows",
 34    "Use Case: Threat Detection",
 35    "Tactic: Persistence",
 36    "Tactic: Execution",
 37    "Data Source: Elastic Endgame",
 38    "Data Source: Elastic Defend",
 39    "Data Source: Sysmon",
 40    "Resources: Investigation Guide",
 41    "Noise: Medium",
 42    "Performance: Normal",
 43    "Rule Type: Event Correlation (EQL)",
 44    "Platform: Windows",
 45]
 46type = "eql"
 47
 48query = '''
 49sequence by host.id with maxspan = 30s
 50  [any where host.os.type == "windows" and 
 51    (event.category : ("library", "driver") or (event.category == "process" and event.action : "Image loaded*")) and
 52    (?dll.name : "taskschd.dll" or file.name : "taskschd.dll") and
 53    process.name : ("cscript.exe", "wscript.exe", "powershell.exe", "pwsh.exe", "powershell_ise.exe")]
 54  [registry where host.os.type == "windows" and event.type == "change" and registry.value : "Actions" and
 55    registry.path : (
 56      "HKLM\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Schedule\\TaskCache\\Tasks\\*\\Actions",
 57      "\\REGISTRY\\MACHINE\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Schedule\\TaskCache\\Tasks\\*\\Actions"
 58  )]
 59'''
 60
 61setup = """## Setup
 62
 63This rule is designed for data generated by [Elastic Defend](https://www.elastic.co/security/endpoint-security), which provides native endpoint detection and response, along with event enrichments designed to work with our detection rules.
 64
 65Setup instructions: https://ela.st/install-elastic-defend
 66
 67### Additional data sources
 68
 69This rule also supports the following third-party data sources. For setup instructions, refer to the links below:
 70
 71- [Sysmon Event ID 7 - Image Loaded](https://ela.st/sysmon-event-7-setup)
 72- [Sysmon Registry Events](https://ela.st/sysmon-event-reg-setup)
 73"""
 74
 75
 76[[rule.threat]]
 77framework = "MITRE ATT&CK"
 78[[rule.threat.technique]]
 79id = "T1053"
 80name = "Scheduled Task/Job"
 81reference = "https://attack.mitre.org/techniques/T1053/"
 82[[rule.threat.technique.subtechnique]]
 83id = "T1053.005"
 84name = "Scheduled Task"
 85reference = "https://attack.mitre.org/techniques/T1053/005/"
 86
 87
 88
 89[rule.threat.tactic]
 90id = "TA0003"
 91name = "Persistence"
 92reference = "https://attack.mitre.org/tactics/TA0003/"
 93[[rule.threat]]
 94framework = "MITRE ATT&CK"
 95[[rule.threat.technique]]
 96id = "T1059"
 97name = "Command and Scripting Interpreter"
 98reference = "https://attack.mitre.org/techniques/T1059/"
 99[[rule.threat.technique.subtechnique]]
100id = "T1059.001"
101name = "PowerShell"
102reference = "https://attack.mitre.org/techniques/T1059/001/"
103
104[[rule.threat.technique.subtechnique]]
105id = "T1059.005"
106name = "Visual Basic"
107reference = "https://attack.mitre.org/techniques/T1059/005/"
108
109
110
111[rule.threat.tactic]
112id = "TA0002"
113name = "Execution"
114reference = "https://attack.mitre.org/tactics/TA0002/"

Triage and analysis

Decode the base64 encoded Tasks Actions registry value to investigate the task's configured action.

Related rules

to-top