At boot
Time Providers: Windows Persistence via W32Time
How the Windows Time service loads time provider DLLs from the registry, how attackers register their own, and how to find, verify and remove a rogue provider.
- MITRE ATT&CK
- T1547.003
- Tactics
- Persistence, Privilege escalation
- Runs
- At boot
- Set up by
- Administrators
- Locations
- HKLM\SYSTEM\CurrentControlSet\Services\W32Time\TimeProviders
- HKLM\SYSTEM\CurrentControlSet\Services\W32Time\Parameters
- HKLM\SYSTEM\CurrentControlSet\Services\W32Time\Config
- C:\Windows\System32\w32time.dll
How it works
The Windows Time service (W32Time) keeps the clock in sync. It is itself a shared service: svchost.exe loads w32time.dll, named by ServiceDll in W32Time\Parameters, and runs it as LOCAL SERVICE. The service does not fetch time on its own; it relies on time providers, plug-in DLLs listed under HKLM\SYSTEM\CurrentControlSet\Services\W32Time\TimeProviders.
Each provider is a subkey:
| Value | Meaning |
|---|---|
DllName | The DLL to load (REG_EXPAND_SZ or REG_SZ) |
Enabled | 1 to load the provider, 0 to skip it |
InputProvider | 1 for a time source (client), 0 for a provider that serves time to others |
When the service starts, and when its configuration is reloaded, the time provider manager loads every enabled provider's DLL into the service's process and calls the provider's exported functions (TimeProvOpen, TimeProvCommand, TimeProvClose). The DLL then runs as long as the service does, as LOCAL SERVICE.
When that happens depends on the machine. On a domain member, W32Time starts automatically at boot. On a standalone Windows 10 or 11 machine it is a manual, trigger-start service, also started by the \Microsoft\Windows\Time Synchronization\SynchronizeTime scheduled task, so a provider loads whenever the service starts rather than strictly at boot.
Where it lives
| Location | What |
|---|---|
HKLM\SYSTEM\CurrentControlSet\Services\W32Time\TimeProviders\<name> | DllName, Enabled, InputProvider, plus provider settings |
HKLM\SYSTEM\CurrentControlSet\Services\W32Time\Parameters | ServiceDll (w32time.dll), Type (NTP, NT5DS…), NtpServer |
HKLM\SYSTEM\CurrentControlSet\Services\W32Time\Config | Global settings, such as polling intervals |
C:\Windows\System32\w32time.dll | The service and the two NTP providers |
Windows registers these providers:
| Provider | DllName | Usual state |
|---|---|---|
NtpClient | %systemroot%\system32\w32time.dll | Enabled |
NtpServer | %systemroot%\system32\w32time.dll | Disabled, except on domain controllers |
VMICTimeProvider | %SystemRoot%\System32\vmictimeprovider.dll | Hyper-V guest time source; usually present |
PtpClient | %SystemRoot%\System32\ptpprov.dll | Precision Time Protocol client; disabled unless PTP is set up |
There is no per-user or WOW6432Node variant. Only administrators and SYSTEM can write under W32Time, which is why the technique needs administrator rights even though the DLL then runs with LOCAL SERVICE's limited privileges.
How attackers use it
The registration is three values in a new subkey with any name, then a restart of the service:
reg add "HKLM\SYSTEM\CurrentControlSet\Services\W32Time\TimeProviders\NtpUpdate" /v DllName /t REG_EXPAND_SZ /d "C:\Windows\System32\ntpupd.dll" /f
reg add "HKLM\SYSTEM\CurrentControlSet\Services\W32Time\TimeProviders\NtpUpdate" /v Enabled /t REG_DWORD /d 1 /f
reg add "HKLM\SYSTEM\CurrentControlSet\Services\W32Time\TimeProviders\NtpUpdate" /v InputProvider /t REG_DWORD /d 1 /f
The DLL must export the three TimeProv* functions. Such a DLL is typically a loader: TimeProvOpen starts the payload in a new thread and returns success, so the service keeps it loaded. A variant points the DllName of NtpClient or NtpServer at the attacker's DLL; forwarding the exports to w32time.dll would keep the clock in sync and the change unnoticed.
The appeal is the host process and the location. The code runs inside a Windows service's svchost.exe, under a Windows account, from a key that few people review. LOCAL SERVICE is not SYSTEM, so this is a foothold that survives reboots, not an elevation: the attacker needed administrator rights to set it up. The technique is less common in public incident reports than services or scheduled tasks.
Disguise is mostly the names: subkeys that sound like part of the time service (NtpUpdate, TimeSync), DLLs in System32 with Microsoft-like file names and version information.
How to check a host
On a live machine:
reg query "HKLM\SYSTEM\CurrentControlSet\Services\W32Time\TimeProviders" /s
w32tm /query /configuration
tasklist /svc /fi "services eq W32Time"
tasklist /m /fi "pid eq 1234"
Get-AuthenticodeSignature C:\Windows\System32\ntpupd.dll | Format-List
w32tm /query /configuration lists each provider with its DllName and Enabled state. The two tasklist lines find the process that hosts W32Time, then list the DLLs loaded in it (replace 1234 with that PID).
Offline: the SYSTEM hive, Select\Current, then Services\W32Time\TimeProviders. Each provider has its own subkey, so its last-write time dates the last change to that provider rather than to the whole service. Then examine the DLL: signature, version information, file times, Amcache.
Events: there is no dedicated event. Registry auditing (4657) or Sysmon event 13 on the TimeProviders key records the change; Sysmon event 7 (image loaded), when configured, shows the DLL loading into svchost.exe. A burst of W32Time stops and starts in the System log (7036) around the time of the change fits the pattern.
Suspicious: any provider beyond those above, a DllName that is not w32time.dll for NtpClient or NtpServer, a DLL outside System32, an unsigned DLL, or a recent key on an old installation. Some precision time setups add their own provider (GPS receivers, vendor PTP software); check that it belongs to software or a feature really in use on the machine.
What Windows Persistence flags
The tool reads each subkey of Services\W32Time\TimeProviders in the current control set that has a DllName. The entry shows the provider name, the DLL with environment variables expanded, and whether it is enabled (from Enabled; unknown when the value is missing). Its trigger follows the W32Time service's Start value: boot when the service is automatic, on demand otherwise.
NtpClient and NtpServer pointing at System32\w32time.dll, VMICTimeProvider at System32\vmictimeprovider.dll and PtpClient at System32\ptpprov.dll are Windows defaults; "Hide Windows entries" hides them. Any other provider, or a default name with another DLL, gets Unknown time provider (high), whether it is enabled or not, plus the path rules in system context: System-wide autostart from a writable folder, Runs from a temporary or public folder, Runs from a network share, Windows program name in the wrong place, Name one letter away from a Windows program and Machine-made name.
Across mechanisms: Written date when the provider's key changed in the 7 days before the newest time seen for that host, Inside a Defender exclusion (exclusion) and program also runs from mechanisms.
Limits: the tool does not check the DLL's signature or exports, and does not read InputProvider or control sets other than the current one. A hijacked ServiceDll of W32Time itself shows on the Windows services side, not here.
Cleaning up
- Preserve:
reg export "HKLM\SYSTEM\CurrentControlSet\Services\W32Time" w32time.reg, then copy and hash the DLL. - Remove the rogue provider:
reg delete "HKLM\SYSTEM\CurrentControlSet\Services\W32Time\TimeProviders\NtpUpdate" /f. - If a stock provider was changed, do not delete it: set its
DllNameback. In PowerShell, single quotes keep the variable unexpanded:Set-ItemProperty 'HKLM:\SYSTEM\CurrentControlSet\Services\W32Time\TimeProviders\NtpClient' -Name DllName -Value '%systemroot%\system32\w32time.dll' -Type ExpandString. - Restart the service so the DLL is unloaded:
net stop w32time, thennet start w32time. Delete the DLL, and check time synchronisation withw32tm /resync. - Look for the same DLL in services, port monitors and netsh helpers. The code ran as LOCAL SERVICE, but setting it up took administrator rights: look for how the attacker got them, and rotate the credentials used on the host.
See also
Related techniques
On Windows Forensics
The artifacts behind this technique, in the Windows Forensics reference: