Skip to content

Active Setup: Per-User Persistence at Windows Logon

How Active Setup runs a StubPath command once for every user at logon, how attackers register a component to reach each account, and how to find and remove it.

MITRE ATT&CK
T1547.014
Tactics
Persistence, Privilege escalation
Runs
At logon
Set up by
Administrators
Locations
  • HKLM\SOFTWARE\Microsoft\Active Setup\Installed Components
  • HKLM\SOFTWARE\WOW6432Node\Microsoft\Active Setup\Installed Components
  • HKCU\Software\Microsoft\Active Setup\Installed Components

How it works

Active Setup exists so that software installed once for the whole machine can finish its per-user setup the first time each user logs on: copy default settings into the profile, register file types, create shortcuts. Internet Explorer, Windows Media Player and Microsoft Edge use it, and so do many enterprise installers.

Each component is a subkey of HKLM\SOFTWARE\Microsoft\Active Setup\Installed Components, usually named with a GUID. Its values:

ValueMeaning
(Default)Display name
StubPathThe command line to run for each user
VersionComma-separated version, such as 1,0,0,0
IsInstalledDWORD; 0 switches the component off
ComponentID, Locale, DontAskDescriptive or legacy values

At each logon, before the desktop appears, Windows walks the machine components and looks for the same subkey under HKCU\Software\Microsoft\Active Setup\Installed Components. If the user's copy is missing, or records a lower Version than the machine key, Windows runs StubPath and then writes the user's copy with the current version. The command runs in the user's session, as that user, once per user and per version.

This makes Active Setup unusual among logon mechanisms. It runs only once per account, so nothing repeats at every logon for a defender to notice. Raising Version in the machine key, or deleting a user's copy, makes it run again. And because the machine key needs administrator rights while the command runs as each user in turn, an administrator who registers a component gets code into the session of every account that logs on afterwards, other administrators included.

On 64-bit Windows, 32-bit installers write their components under HKLM\SOFTWARE\WOW6432Node\Microsoft\Active Setup\Installed Components; the tool reads both keys.

Where it lives

KeyWho can write itOn a stock Windows 10 or 11
HKLM\SOFTWARE\Microsoft\Active Setup\Installed Components\<GUID>Administrators, SYSTEMA set of Microsoft components; those with a StubPath run programs in System32 (such as ie4uinit.exe, unregmp2.exe, or rundll32.exe with a System32 DLL) or Edge's installer under Program Files
HKLM\SOFTWARE\WOW6432Node\Microsoft\Active Setup\Installed Components\<GUID>Administrators, SYSTEMComponents of 32-bit software
HKCU\Software\Microsoft\Active Setup\Installed Components\<GUID>The userA record of each component that already ran for this user, with its version; it holds no command Windows runs

The user's copy matters for investigations: its last-write time is roughly when the component ran for that user.

How attackers use it

Registering a component takes three values (run as administrator):

reg add "HKLM\SOFTWARE\Microsoft\Active Setup\Installed Components\{6B2F5C1E-8A1D-4E35-9C2B-5F0A7D3E9B14}" /ve /d "Microsoft Windows Media Update" /f
reg add "HKLM\SOFTWARE\Microsoft\Active Setup\Installed Components\{6B2F5C1E-8A1D-4E35-9C2B-5F0A7D3E9B14}" /v StubPath /d "C:\ProgramData\Microsoft\WMUpdate\wmupd.exe" /f
reg add "HKLM\SOFTWARE\Microsoft\Active Setup\Installed Components\{6B2F5C1E-8A1D-4E35-9C2B-5F0A7D3E9B14}" /v Version /d "1,0,0,0" /f

MITRE ATT&CK records PoisonIvy creating an Active Setup key that points at its executable. The patterns to expect:

  • A random GUID and a display name copied from a Microsoft component, so the subkey blends into a long list of GUIDs.
  • A StubPath that uses a built-in program to start the payload: rundll32.exe with a DLL in ProgramData, regsvr32.exe /s /i:, cmd.exe /c, powershell.exe with an encoded command.
  • A payload that, once running as the user, installs per-user persistence of its own (Run keys, a Startup folder item, a scheduled task), so the Active Setup component is only the delivery step and can be removed afterwards.
  • Re-running on demand by raising Version, or by deleting a target user's copy under HKCU.

How to check a host

On a live machine:

reg query "HKLM\SOFTWARE\Microsoft\Active Setup\Installed Components" /s /v StubPath
reg query "HKLM\SOFTWARE\WOW6432Node\Microsoft\Active Setup\Installed Components" /s /v StubPath
Get-ChildItem 'HKLM:\SOFTWARE\Microsoft\Active Setup\Installed Components', 'HKLM:\SOFTWARE\WOW6432Node\Microsoft\Active Setup\Installed Components' |
  Get-ItemProperty | Where-Object StubPath | Select-Object PSChildName, '(default)', StubPath, Version, IsInstalled

Autoruns lists Active Setup components with the logon entries (autorunsc.exe -accepteula -a l -s -h -c), with signature checks on the programs.

Offline, read Microsoft\Active Setup\Installed Components and its WOW6432Node twin in the SOFTWARE hive. The last-write time of a component's key is when it was registered or last changed; the same subkey in each user's NTUSER.DAT shows when it ran for that user. A component whose machine key is recent, and whose user copies appeared at each user's next logon, is the pattern to look for. Process creation events (4688 with command lines, or Sysmon event 1) at logon show the StubPath command, and Sysmon event 13 records the StubPath value being set.

What stands out: a StubPath outside System32 and Program Files, a built-in program running a file from ProgramData, a user folder or Temp, a display name that does not match the program it runs, a GUID no installed product explains, and a Version raised without a software update.

What Windows Persistence flags

The tool reads every subkey of Microsoft\Active Setup\Installed Components and WOW6432Node\Microsoft\Active Setup\Installed Components in the SOFTWARE hive that has a non-empty StubPath. The entry's name is the component's display name (or its ComponentID) followed by the subkey name; it shows the component and its Version, and IsInstalled set to 0 marks it disabled.

Active Setup has no flag of its own. The command-line rules run on StubPath as a machine-wide autostart: System-wide autostart from a writable folder, Runs from a temporary or public folder, Runs from a network share, Windows program used to run outside code, Script run by the Windows script host, Downloads and runs code, Encoded PowerShell command, Windows program name in the wrong place, Name one letter away from a Windows program, Machine-made name and the others. Across mechanisms: Written date when the component's key changed in the 7 days before the newest time collected from that host, Inside a Defender exclusion (exclusion), and program also runs from mechanisms.

With Hide Windows entries on, components whose StubPath runs a program in Windows' folders and raises no flag are hidden, which removes most of Microsoft's list.

Limits: the tool does not know which GUIDs are Microsoft's, so a new component pointing at a program in System32 or Program Files raises nothing and, in the first case, is hidden by the filter. It does not read the users' HKCU copies, so it cannot say who has already run a component, or when. It reads the command, not the program, and checks no signatures.

Cleaning up

  1. Preserve: reg export "HKLM\SOFTWARE\Microsoft\Active Setup\Installed Components\{6B2F5C1E-8A1D-4E35-9C2B-5F0A7D3E9B14}" activesetup.reg, and copy and hash the program StubPath runs.
  2. Remove the component: reg delete "HKLM\SOFTWARE\Microsoft\Active Setup\Installed Components\{6B2F5C1E-8A1D-4E35-9C2B-5F0A7D3E9B14}" /f. Setting IsInstalled to 0 also stops it but leaves it ready to be switched back on. Then delete the payload.
  3. Every user who logged on since the component was registered has already run it. Check each profile for what the payload left there: Run keys, Startup folder items, scheduled tasks, and files in AppData. The users' HKCU copies of the component are harmless records; delete them once preserved.
  4. Do not delete Microsoft's components: a missing one can break per-user setup of Windows features for new profiles.
  5. Rotate the credentials of the users whose sessions ran the payload, administrators first, and find out how the attacker obtained administrator rights to write the machine key.

See also

On Windows Forensics

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