Skip to content

Boot Execute: Native Programs Run Before Windows Starts

How Session Manager's BootExecute value runs native programs before Windows starts, how attackers abuse it, and how to check and restore the autochk default.

MITRE ATT&CK
T1547.001
Tactics
Persistence, Privilege escalation
Runs
At boot
Set up by
Administrators
Locations
  • HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\BootExecute
  • HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\BootExecuteNoPnpSync
  • HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\SetupExecute
  • HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Execute
  • C:\Windows\System32\autochk.exe

How it works

The Session Manager, smss.exe, is the first user-mode process Windows starts. Early in its work, before it starts the Windows subsystem (csrss.exe), wininit.exe, the services and the logon screen, it reads the BootExecute value of HKLM\SYSTEM\CurrentControlSet\Control\Session Manager. That value is a multi-string list; Session Manager runs each line in turn and waits for it to finish.

On every Windows version the default is one line:

autocheck autochk *

autochk.exe is the boot-time version of chkdsk, and * asks it to consider every volume; it only scans volumes marked dirty, which is the disk check screen seen after a crash. Running chkntfs /x C: to exclude a drive adds a /k: switch to this line (autocheck autochk /k:C *); chkntfs /d puts the default back.

Programs run this early are native applications: their PE subsystem is "Native", they link only to ntdll.dll, and the Win32 API is not available yet. Session Manager looks for them in System32. They run with full privileges, before any user logs on, before the services start, and before the antivirus user-mode components start. No process creation event reaches the Security log: the event log service is not running yet.

Right after, Session Manager also performs the file moves and deletions queued in its PendingFileRenameOperations value, which installers use to replace files that are in use.

Where it lives

All in HKLM\SYSTEM\CurrentControlSet\Control\Session Manager:

ValueTypeStock content
BootExecuteREG_MULTI_SZautocheck autochk *
SetupExecuteREG_MULTI_SZUsed by Windows setup and servicing; normally empty outside an upgrade
BootExecuteNoPnpSync, ExecuteREG_MULTI_SZNormally empty or absent
PendingFileRenameOperationsREG_MULTI_SZPresent only while a file operation waits for a reboot

The programs themselves sit in C:\Windows\System32 (autochk.exe for the default). There is no per-user variant and no WOW6432Node copy: the key belongs to the SYSTEM hive. Offline, read the control set named by Select\Current.

Only administrators and SYSTEM can write the Session Manager key, and placing a program in System32 needs the same rights.

How attackers use it

ATT&CK lists the BootExecute value under registry autostarts: adding a line to it runs a program at every boot. The constraints shape how it is used. The program must be a native application, so attackers write small tools against the NT API rather than drop their usual payload. What makes it worth the effort is timing: the code runs before the services and the user-mode parts of security software, with full rights, so it can delete or replace protected files, change registry settings, or restore other persistence that defenders removed while Windows was running.

A typical change keeps the default line first and adds another, so a quick look still shows autocheck autochk *:

reg add "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager" /v BootExecute /t REG_MULTI_SZ /d "autocheck autochk *\0bootsvc" /f

The program name is chosen to fit in System32. Session Manager waits for each line, so a program that hangs stops the boot: these tools are short and exit quickly. A line can also start with the same autocheck keyword as the stock entry, so the two look alike in a list. A related trick uses PendingFileRenameOperations to swap a file at the next boot, before anything can protect it.

Legitimate software uses the same value: some antivirus boot-time scanners and disk tools add their own native program here. An extra line is therefore not proof of compromise, but it should be explained by a product installed on the machine.

How to check a host

On a live machine:

reg query "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager" /v BootExecute
Get-ItemProperty 'HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager' | Select-Object BootExecute, BootExecuteNoPnpSync, SetupExecute, Execute, PendingFileRenameOperations
autorunsc.exe -accepteula -a b -h -s -c > bootexecute.csv

For any line other than the default, find the program in C:\Windows\System32, check its signature (Get-AuthenticodeSignature) and identify the product it belongs to. A PE viewer shows its subsystem: a working boot-time program says Native (value 1), since the Win32 subsystem is not running yet when it starts.

Offline: the SYSTEM hive, Select\Current, then ControlSet00n\Control\Session Manager. The key's last-write time is weak evidence: it changes whenever any value of Session Manager changes, and installers and updates write PendingFileRenameOperations there often. File times of the native program in System32, Amcache and the timeline around them are more useful.

Events: there is no dedicated event. With auditing set on the key, 4657 records the value change; Sysmon event 13 does the same. The program itself runs before any log is written.

Suspicious: any line beyond autocheck autochk * and its chkntfs switches that no installed product explains; a program in System32 with no signature or a recent file time; anything in BootExecuteNoPnpSync or Execute; SetupExecute content on a machine that is not upgrading.

What Windows Persistence flags

The tool reads six values of Session Manager in the current control set: BootExecute, BootExecuteNoPnpSync, SetupExecute, Execute, S0InitialCommand and PlatformExecute. Each non-empty line becomes an entry. The program is the path on the line when there is one; otherwise the first name on the line (after autocheck when present), as an .exe in C:\Windows\System32.

autocheck autochk * in BootExecute, with or without switches such as /q or the /k:C that chkntfs /x adds, is Windows' default: it is marked as such and "Hide Windows entries" hides it. Every other line, in any of the six values, gets Extra boot-time program (high). The command-line rules are not applied: the line is already high.

Across mechanisms: Written date when the key changed in the 7 days before the newest time seen for that host (noisy here, for the reason above), Inside a Defender exclusion (exclusion) and program also runs from mechanisms.

Limits: the tool does not check that the program exists, is native or is signed. It does not read PendingFileRenameOperations, other values of Session Manager, or control sets other than the current one.

Cleaning up

  1. Preserve: reg export "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager" session-manager.reg, then copy and hash the native program.
  2. Restore the default, keeping any line a legitimate product needs:
reg add "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager" /v BootExecute /t REG_MULTI_SZ /d "autocheck autochk *" /f
  1. Do not delete the value or the autocheck autochk * line: without it, Windows no longer checks dirty volumes at boot. If the line carries chkntfs switches you did not set, chkntfs /d resets them.
  2. Empty attacker lines from BootExecuteNoPnpSync, SetupExecute or Execute, delete the program from System32, and reboot.
  3. The program ran before most defences, with full rights. Check what it may have changed: services, kernel drivers, Winlogon values, Defender settings, replaced system files (sfc /scannow compares them with the component store). Rotate the credentials used on the host and consider rebuilding it.

See also

On Windows Forensics

The artifacts behind this technique, in the Windows Forensics reference: