Skip to content
WETNav

PersistenceHigh

Scheduled task persistence

Also known as schtasks persistence, At job

Registering a scheduled task that re-launches attacker code on a trigger. Security 4698 and Task Scheduler 106 record the task.

Signals in the logs

  1. 01Security4698A scheduled task was createdAny host

    A scheduled task was created; the full task XML is in the event.

    TaskName
    the task path and name, e.g. \Microsoft\Windows\...\Updater
    SubjectUserName
    account that created the task
  2. 02Task Scheduler106Scheduled task registeredAny host

    A task was registered (operational log equivalent of the create).

    TaskName
    the registered task name
    UserContext
    account that registered it
  3. 03Task Scheduler200Scheduled task action startedAny host

    A task action started, showing the program the task launched.

    ActionName
    the executable the task ran
    TaskName
    the task that fired
  4. 04Task Scheduler140Scheduled task updatedAny host

    An existing task was updated, which can hijack a legitimate task to run attacker code.

    TaskName
    the task that was updated
    UserName
    account that updated it

What happens

A scheduled task is one of the most common persistence methods because it is built in, flexible, and can run as SYSTEM. The operator registers a task with schtasks.exe, the Task Scheduler COM interface, or PowerShell's ScheduledTasks module, setting a trigger (at logon, at startup, on a schedule, or on an event) and an action that launches their payload. The task definition is stored as XML on disk and the action often points at powershell.exe, cmd.exe, or a dropped binary. Registration is audited in two places: Security 4698 records the task creation with its full XML, and the Task Scheduler operational log records 106 when a task is registered and 140 when one is updated. When the trigger fires, the operational log records 200 (action started) and 129 (task launched a process).

Logging you need

  • Security 4698 requires the Audit Other Object Access Events subcategory, which is off by default.
  • Task Scheduler operational history (106, 140, 141, 200, 129) is disabled by default on many Windows versions and must be enabled.
  • Reading the action needs the task XML in 4698 or the ActionName in Task Scheduler 200.

Hunt queries

Starting points. Tune thresholds and exclusions to your environment before alerting on them.

Get-WinEvent -FilterHashtable @{LogName='Security'; Id=4698}

Benign look-alikes

  • Software installers and updaters that create their own scheduled tasks.
  • Legitimate administrative automation and GPO-deployed tasks.
  • Microsoft's own built-in tasks, which register under \Microsoft\Windows\ paths.

Notes

  • Inspect the task XML for the Command and Arguments; encoded PowerShell or a path in a user-writable directory is a strong indicator.
  • A 140 (update) on a long-standing Microsoft task is a hijack pattern worth examining closely.
  • Remote task creation is handled separately under the remote-scheduled-task lateral technique (4698 from a network logon).

References