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 = "2025/03/20"
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]
42type = "eql"
43
44query = '''
45sequence by host.id with maxspan = 30s
46 [any where host.os.type == "windows" and
47 (event.category : ("library", "driver") or (event.category == "process" and event.action : "Image loaded*")) and
48 (?dll.name : "taskschd.dll" or file.name : "taskschd.dll") and
49 process.name : ("cscript.exe", "wscript.exe", "powershell.exe", "pwsh.exe", "powershell_ise.exe")]
50 [registry where host.os.type == "windows" and event.type == "change" and registry.value : "Actions" and
51 registry.path : (
52 "HKLM\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Schedule\\TaskCache\\Tasks\\*\\Actions",
53 "\\REGISTRY\\MACHINE\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Schedule\\TaskCache\\Tasks\\*\\Actions"
54 )]
55'''
56
57
58[[rule.threat]]
59framework = "MITRE ATT&CK"
60[[rule.threat.technique]]
61id = "T1053"
62name = "Scheduled Task/Job"
63reference = "https://attack.mitre.org/techniques/T1053/"
64[[rule.threat.technique.subtechnique]]
65id = "T1053.005"
66name = "Scheduled Task"
67reference = "https://attack.mitre.org/techniques/T1053/005/"
68
69
70
71[rule.threat.tactic]
72id = "TA0003"
73name = "Persistence"
74reference = "https://attack.mitre.org/tactics/TA0003/"
75[[rule.threat]]
76framework = "MITRE ATT&CK"
77[[rule.threat.technique]]
78id = "T1059"
79name = "Command and Scripting Interpreter"
80reference = "https://attack.mitre.org/techniques/T1059/"
81[[rule.threat.technique.subtechnique]]
82id = "T1059.001"
83name = "PowerShell"
84reference = "https://attack.mitre.org/techniques/T1059/001/"
85
86[[rule.threat.technique.subtechnique]]
87id = "T1059.005"
88name = "Visual Basic"
89reference = "https://attack.mitre.org/techniques/T1059/005/"
90
91
92
93[rule.threat.tactic]
94id = "TA0002"
95name = "Execution"
96reference = "https://attack.mitre.org/tactics/TA0002/"
toml
Triage and analysis
Decode the base64 encoded Tasks Actions registry value to investigate the task's configured action.
Related rules
- New ActiveSyncAllowedDeviceID Added via PowerShell
- Persistence via Hidden Run Key Detected
- Persistence via WMI Event Subscription
- Suspicious Image Load (taskschd.dll) from MS Office
- System Shells via Services