Abuse of PowerShell Cmdlets for Scheduled Task Manipulation
Adversaries leverage native Windows PowerShell cmdlets to register, configure, and execute unauthorized scheduled tasks for persistence and lateral movement.
Threat actors frequently abuse the Windows Task Scheduler to establish persistence, achieve privilege escalation, or ensure recurring execution of malicious payloads. By utilizing native PowerShell cmdlets such as Register-ScheduledTask or through direct WMI/CIM method calls to the TaskScheduler namespace, attackers can create or modify system tasks without requiring external binaries or manual interaction with the GUI. This technique is particularly effective in environments where PowerShell is trusted and Script Block Logging is not actively monitored, allowing attackers to blend in with legitimate administrative automation. Defenders must focus on the invocation of specific task-related cmdlets to differentiate malicious persistence mechanisms from benign system management scripts.
Attack Chain
- The attacker gains initial access to the target host via phishing or exploit.
- The attacker identifies the need for recurring code execution for persistence.
- The attacker executes a PowerShell command using New-ScheduledTaskAction and New-ScheduledTaskTrigger to define the payload and timing.
- The attacker defines a security context for the task using New-ScheduledTaskPrincipal.
- The attacker finalizes the configuration using New-ScheduledTaskSettingsSet.
- The attacker uses Register-ScheduledTask or Invoke-CimMethod to commit the task to the Windows Task Scheduler.
- The scheduled task executes the malicious payload upon the next trigger event (e.g., system boot, user login).
Impact
Successful abuse of the Windows Task Scheduler allows attackers to maintain long-term access to compromised systems, even after system reboots. This capability is commonly used by various threat actors to deploy ransomware, exfiltrate data, or deploy additional C2 implants across enterprise networks.
Recommendation
Deploy the provided Sigma rule to identify unauthorized task creation. Ensure PowerShell Script Block Logging (Event ID 4104) is enabled across the endpoint estate to capture the specific cmdlets used during task registration. Audit all existing scheduled tasks for unexpected actions or suspicious command-line arguments.
Immediate actions
Enable PowerShell Script Block Logging (Event ID 4104) across all Windows endpoints
Deploy Sigma detection rule to SIEM
Threat Hunt
Search for instances of Register-ScheduledTask or Invoke-CimMethod pointing to unauthorized executables or scripts
Data: Event ID 4104
Mitigations
Restrict the ability of non-administrative users to create or modify scheduled tasks via group policy
T1053.005
Detection coverage 1
Detect PowerShell Scheduled Task Creation
mediumDetects the use of PowerShell cmdlets or CIM methods to create or register scheduled tasks for potential persistence
Detection queries are available on the platform. Get full rules →