Skip to content

COM Hijacking: Per-User CLSID Persistence on Windows

How per-user COM registrations in HKCU\Software\Classes override Windows classes, how attackers pick a target, and how to find and remove a hijacked CLSID.

MITRE ATT&CK
T1546.015
Tactics
Persistence, Privilege escalation
Runs
When a program starts
Set up by
Users and administrators
Locations
  • HKCU\Software\Classes\CLSID
  • %LOCALAPPDATA%\Microsoft\Windows\UsrClass.dat
  • HKLM\SOFTWARE\Classes\CLSID
  • HKLM\SOFTWARE\WOW6432Node\Classes\CLSID

How it works

COM lets a program create an object from a class ID (CLSID) without knowing which file implements it. When a program calls CoCreateInstance, COM looks up CLSID\{…} in HKEY_CLASSES_ROOT and starts the server it finds there:

Subkey of the CLSIDWhat COM does with it
InprocServer32Loads the DLL in the default value into the calling process; ThreadingModel says how it may be called
LocalServer32Starts the program in the default value, with its arguments, as a separate process
InprocHandler32Loads a handler DLL in process for an out-of-process server
TreatAsUses the CLSID in the default value instead of this one
ScriptletURLRuns a Windows Script Component (.sct), local or remote, through scrobj.dll

HKEY_CLASSES_ROOT is a merged view of HKLM\SOFTWARE\Classes and the user's own HKCU\Software\Classes. When the same key exists in both, the user's copy wins. That is what lets software install for one user without administrator rights, and it is what lets anyone who can write a user's classes replace any COM class for that user's processes, Windows' own included.

The server then runs inside, or is started by, whichever process created the object, as that process's account, each time it does. A class that explorer.exe creates at logon, that browsers or Office create at start, or that a scheduled task uses as its custom handler gives regular execution with no autostart entry anywhere. Nothing in HKLM changes, and the program loading the DLL is a signed Windows binary.

Where it lives

LocationWhatWho can write it
HKCU\Software\Classes\CLSID\{…}Per-user classes; the hive file is %LOCALAPPDATA%\Microsoft\Windows\UsrClass.dat, loaded as HKU\<SID>_ClassesThe user, no elevation needed
Software\Classes\CLSID inside NTUSER.DATNormally unused, since Windows maps HKCU\Software\Classes to UsrClass.dat; check it anywayThe user
HKLM\SOFTWARE\Classes\CLSID\{…}Machine-wide classes, 64-bit viewAdministrators; many Windows classes only TrustedInstaller
HKLM\SOFTWARE\WOW6432Node\Classes\CLSID\{…}Machine-wide classes, 32-bit viewAdministrators

The per-user CLSID key is not empty on a normal machine. Software installed per user, such as OneDrive and Teams, registers its own classes there, with DLLs under AppData. A per-user class with a new CLSID is ordinary. A per-user class that repeats a CLSID Windows registers machine-wide, with a different server, is the pattern to look for.

How attackers use it

The attacker picks a class that a long-running or frequently started process creates, writes the same CLSID under the user's classes, and points InprocServer32 at a DLL:

reg add "HKCU\Software\Classes\CLSID\{42AEDC87-2188-41FD-B9A3-0C966FEABEC1}\InprocServer32" /ve /t REG_EXPAND_SZ /d "C:\Users\alice\AppData\Roaming\Microsoft\Windows\thumbcache.dll" /f

That CLSID is MruPidlList, which explorer.exe loads; MITRE's entry on ComRAT, a Turla implant, describes this exact hijack, with the path to shell32.dll replaced. Careful implementations copy ThreadingModel from the machine registration and build a proxy DLL that forwards every call to the original server, so Explorer keeps working and nothing looks broken.

Finding a target is simple: Process Monitor filtered on RegOpenKey results of NAME NOT FOUND under HKCU\Software\Classes\CLSID shows every class a process asks the user's hive for before falling back to HKLM. Other variants:

  • Scheduled task handlers. A task whose action is a custom handler names a CLSID; hijacking that class for the user runs the DLL each time the task fires, without touching the task. See Scheduled tasks.
  • LocalServer32 pointing at powershell.exe, mshta.exe or a script host with arguments.
  • TreatAs redirecting a Windows class to an attacker's class, and ScriptletURL loading a remote .sct, which leaves only a URL in the registry.
  • Abandoned registrations. Machine-wide classes left by uninstalled software can point at a DLL that no longer exists. Whoever can write that folder gets loaded without changing the registry.

How to check a host

On a live machine, list the current user's in-process servers and whether each CLSID also exists machine-wide:

Get-ChildItem 'HKCU:\Software\Classes\CLSID' -ErrorAction SilentlyContinue | ForEach-Object {
  $id = $_.PSChildName
  $srv = (Get-ItemProperty "$($_.PSPath)\InprocServer32" -ErrorAction SilentlyContinue).'(default)'
  if ($srv) { [pscustomobject]@{ CLSID = $id; Server = $srv; InHKLM = Test-Path "HKLM:\SOFTWARE\Classes\CLSID\$id" } }
}

Repeat for LocalServer32, TreatAs and ScriptletURL. Other signed-in users' classes are under HKU\<SID>_Classes\CLSID. For a user who is signed out, load the hive, query it and unload it:

reg load HKU\IR C:\Users\bob\AppData\Local\Microsoft\Windows\UsrClass.dat
reg query HKU\IR\CLSID /s /f InprocServer32 /k
reg unload HKU\IR

Then check each DLL: Get-AuthenticodeSignature, its folder, and its creation time.

Offline, open each user's UsrClass.dat (and NTUSER.DAT) and read CLSID and Wow6432Node\CLSID. The last-write time of an InprocServer32 key is when its server path was last set, which for a hijack is usually the time of the intrusion. Compare each CLSID with the SOFTWARE hive's Classes\CLSID and WOW6432Node\Classes\CLSID. On a host with Sysmon, event 13 records registry writes under \Software\Classes\CLSID\ or _Classes\CLSID\, and event 7 shows explorer.exe or taskhostw.exe loading a DLL from a user folder. Event 4657 records the write where auditing is set on the key, which is rare for per-user classes.

Suspicious: a per-user class that overrides a machine one with another server; a server DLL in AppData, ProgramData or Temp that no installed per-user application explains; an unsigned DLL; TreatAs, ScriptletURL or a LocalServer32 running a script host in the user's classes.

What Windows Persistence flags

The tool reads each user's UsrClass.dat (CLSID and Wow6432Node\CLSID) and NTUSER.DAT (Software\Classes\CLSID and Software\Classes\Wow6432Node\CLSID), so per-user registrations for 32-bit programs are covered too. For every class, the default value of InprocServer32, LocalServer32 and InprocHandler32 becomes an entry named after the CLSID and the class name, with ThreadingModel in the details. It then flags:

  • Hijack of a COM class commonly hijacked: CLSID (high) for three classes loaded by common Windows processes: {42AEDC87-2188-41FD-B9A3-0C966FEABEC1} (MruPidlList, the ComRAT target ATT&CK documents), {BCDE0395-E52F-467C-8E3D-C4579291692E} (MMDeviceEnumerator) and {B5F8350B-0548-48B1-A6EE-88BD00B4A5E7} (CAccPropServicesClass).
  • Per-user COM class overrides a system one: CLSID (high) for any other per-user class whose CLSID the SOFTWARE hive also registers, in Classes\CLSID or WOW6432Node\Classes\CLSID.
  • COM class redirected (TreatAs CLSID) (medium) for a per-user TreatAs.
  • COM class backed by a scriptlet (high) for a per-user ScriptletURL.

The command-line rules run on each server path in their per-user form: Runs from a temporary or public folder, Runs from a network share, Windows program name in the wrong place, Windows program used to run outside code, Machine-made name and the others, but not System-wide autostart from a writable folder, since per-user classes normally live in AppData. Across mechanisms come Written date, Inside a Defender exclusion (path) and program also runs from mechanisms. A per-user class that overrides nothing and whose server sits in Windows' folders raises no flag, and the "Hide Windows entries" filter hides it.

Limits: without the SOFTWARE hive, the override check cannot run, and an override shows only through its path. The tool uses machine-wide classes only for that comparison and does not judge them, so a server path changed in HKLM, or an HKLM class pointing at a missing DLL, goes unseen. It does not read ProgID registrations or the DLL itself.

Cleaning up

  1. Preserve: reg export "HKCU\Software\Classes\CLSID\{42AEDC87-2188-41FD-B9A3-0C966FEABEC1}" C:\IR\clsid.reg (or from the loaded hive), plus the DLL and its hash.
  2. Delete the user's copy of the class only: reg delete "HKCU\Software\Classes\CLSID\{42AEDC87-2188-41FD-B9A3-0C966FEABEC1}" /f. The machine registration takes over again at once. Never delete the HKLM class.
  3. The DLL is usually loaded in explorer.exe or another long-running process: sign the user out, or restart that process, before deleting the file.
  4. Check every profile on the host, and other hosts the user signs in to: tooling often plants the same hijack in each profile it reaches.

Before deleting a per-user class that overrides nothing, check its DLL's signer: removing a legitimate per-user application's class breaks that application. Then look for other mechanisms pointing at the same DLL, and treat what that user's session could reach (browser sessions, tokens, mail) as exposed.

See also

On Windows Forensics

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