Repository navigation
v2.7.0 — Canary Safety, Service-State Restore, Real-Target Verified
Safety and accuracy fixes from benchmarking against the HijackRange lab and a real target. Verified on Windows 11 Enterprise (build 26300) with Microsoft Defender and tamper protection on: a 42-scan HijackRange regression with no outcome regressions, no residue and no Defender detections; Checkmk Windows agent 2.2.0p23 (CVE-2024-28827), where a plain --profile aggressive scan now finds the hole in the agent's child process, types it SearchOrder and confirms it as SYSTEM, while the fixed 2.2.0p29 reports nothing; and the Windows SDK IP over USB service (CVE-2025-47962), where --target or --restart-services confirms the CVE's CRYPTSP.dll as SYSTEM and the fixed build reports nothing. New exit code 4 (artifacts or service state could not be restored); new flags and JSON fields are additive.
Canary safety and ETW attribution
Fixes for the first safety defects found on the HijackRange lab (TIER 0B, 2026-11-21). In one aggressive scan, the canary for an ETW finding attributed to MsMpEng.exe ran sc.exe stop WinDefend, which Defender flagged as Trojan:Win32/MpTamperSrvDisableAV.H. A canary that could not be deleted was left at a Users-writable machine-PATH position, and later runs treated it as the original DLL. The tool's own file activity also became findings.
Safety
- Service guard. One decision,
ServiceGuard.IsGuarded, coversLaunchProtectedservices, Microsoft security services, binaries under the Defender folders, and an embedded, source-cited list of third-party EDR/AV services. Every stop goes throughServiceControl, which cannot build a stop for a guarded service. A guarded service gets no canary (NotTestedplus the reason), and the ETW phase never sends itstop. - Artifact manifest.
%ProgramData%\DLLHijackHunter\artifacts.jsonrecords each canary, sidecar, backup and confirm file before it is placed. It is written atomically and accepted only if owned by SYSTEM or Administrators. A startup sweep deletes hash-matched leftovers, restores backups, and reports the rest. - Previous artifacts. A previous artifact at a deploy path (manifest hash match, or the canary marker) is never backed up or proxied. Runtime proxies now carry an explicit marker.
- Cleanup on failure. On a failed cleanup the tool stops the trigger again, retries with backoff, names the holder via the Restart Manager, and schedules
MOVEFILE_DELAY_UNTIL_REBOOT. - Residue. Anything left behind goes in the JSON
Residuearray, a red console block, and new exit code 4.
ETW attribution
- The scanner's own PID and all of its descendants, tracked by parent PID, are excluded.
- File opens by security-product processes are not lookups.
- Tool artifacts never become candidates:
*_hhorig.dll,*.hijackhunter.bak,*.probebak, the tool folder, and manifest entries. - Process paths are resolved from the EXE's own image-load event or its command line before
OpenProcess, so short-lived processes keep their full path. When no full path is found the finding saysbinary path unresolvedandBinaryPathis empty; it is never a bare name.
Scoring
Failedcaused by the harness (could not trigger, back up, or stage the sidecar; target directory missing) no longer costs −20. The cause is recorded inCanaryFailureCause.Timeoutkeeps −10.
Audit
- Every side effect is logged at Info level, with a UTC time and ID, whether or not
--verboseis set. Each finding carries the same list asCanaryActions.
New JSON fields (additive; existing names unchanged)
- Top level:
ScanId,Residue[](Path,Role,Sha256,Holder,DelayedDeleteScheduled,CandidateId,Reason) andArtifactSweep[](Path,Role,Outcome,ScanId,Detail). - Per finding:
CanaryFailureCause,CanaryActions[](Utc,Action,Target,Result) andBinaryImageName.
Tests
- New
tests/DLLHijackHunter.Tests(xUnit,net8.0-windows) covers the guard, attribution, artifact, cleanup, audit and scoring decisions with no side effects outside a temp directory.
Fixes from the Checkmk run (CVE-2024-28827)
The real-target run on Checkmk agent 2.2.0p23 confirmed the hole as SYSTEM, and exposed four problems.
Typing
- One typing decision,
HijackTypeResolver.Classify, for the ETW FileIOCreate path and the static engine. A real copy later in the process's own search order (System32 for 64-bit, SysWOW64 for 32-bit, then System and Windows; PATH only where the static engine already models it) makes the finding SearchOrder withDllLegitPathset; Phantom only when no copy exists. ETW findings were always Phantom before. The note now states the evidence: "Writable position probed before C:\Windows\SysWOW64\secur32.dll (SearchOrder)".
Canary
- Service children. For Service triggers the canary waits until the service is stably RUNNING, then up to
--canary-service-waitseconds (default 90) for the confirm file. Checkmk launches the vulnerablecmk-agent-ctl.exe~31 s after every start; the old ~23 s wait gave up first (two Timeouts) and two other holes fired only from the previous candidate's start. The export-forwarding proxy builder is unchanged: it was not the cause. - Each fire is timed (
canary-firedinCanaryActions). host-failed-after-plant. A canary that does not fire, where an Application Error 1000, WER 1001 or Application Popup 26 event since the plant names the planted module, isFailedwith thatCanaryFailureCause: no penalty, not Confirmed. Otherwise Timeout keeps −10.
Service safety
- Guarded services are never started either. The ETW phase used to start a stopped guarded service; the tool cannot stop it again, so it was left differing from its snapshot (DoSvc, LaunchProtected=2, on p23).
- Snapshot once, restore always. One snapshot (state, start type, PID) per service before the ETW and canary phases; every decision reads it. Every stop and start waits for a stable SCM state (
QueryServiceStatusEx). After each candidate and at the end of each phase every touched service is restored to its snapshot and verified (3 attempts with backoff). On p23 the targeted run had leftCheckmkServicestopped. - A service that cannot be restored is residue (
Kind = "service-state",Service,ExpectedState,ActualState,LastError), a red console block, and exit code 4 ("artifacts or service state could not be restored").
Coverage
- Service companion executables (always on, read-only): EXEs in a service's related directories (binary directory, install root,
%ProgramData%\<vendor>, directories inImagePatharguments andParameters) that a standard user can write to are analysed with the parent's trigger and identity.DiscoverySource = "companion", capped at Medium unless a canary fires or ETW sees the EXE run under that service. --restart-services(opt-in, disruptive): without--target, the ETW phase restarts running, non-guarded services with evidence, up to--restart-cap(default 20), and logs the plan first.
New flags and JSON fields (additive)
- Flags:
--restart-services,--restart-cap <n>,--canary-service-wait <sec>. Residue[]:Kind,Service,ExpectedState,ActualState,LastError.- Per finding:
CompanionOf,CompanionObserved;DiscoverySourcecan becompanion; newCanaryActionsactionscanary-wait,canary-fired,service-restore,host-failed-after-plant.
Cleanup after the Checkmk fixes
- Scheduled-task leftovers. A task trigger records the processes its run creates (Task Scheduler parent chain, started after
/run). When a canary cannot be removed,/endis followed by a wait of up to 10 s for those processes; one still holding the canary is terminated, never a process the trigger did not start and never a guarded or security-product image.task-process-recorded/task-process-wait/task-process-terminatedinCanaryActions. - Companion report. Every executable companion discovery examines is logged (verbose) as kept or rejected with the reason; the end-of-scan summary gives examined / kept / rejected.
- ETW duplicates. An ETW finding with an unresolved binary path is merged into a resolved finding with the same DLL and hole directory when the PID or image name matches. File opens attributed to the System process (PID 4) are no longer treated as loader lookups. New field
ObservedPid. - Guard skips visible. "not starting stopped guarded service" is logged at Info with the guard reason and counted in the summary.
- Runtime-added directories. A static Phantom whose binary ETW saw load the same DLL from a directory outside its standard search order becomes SearchOrder (note "Real copy observed loading from (runtime-added directory)"); otherwise binaries importing SetDllDirectory/AddDllDirectory get a note.
- DotLocal on 32-bit binaries. On Windows 11 the loader ignored
<exe>.localfor a 32-bit, unmanifested EXE (Checkmkcmk-agent-ctl.exe): an unmodified realsecur32.dllplaced there was never loaded. A 32-bit EXE on 64-bit Windows now gets a DotLocal finding only whenDevOverrideEnable=1.
Fixes from the Windows SDK run (CVE-2025-47962)
A real-target run on the Windows SDK "IP over USB" service (IpOverUsbSvc, 10.1.26100.3323) confirmed the CVE's CRYPTSP.dll hole as SYSTEM, typed SearchOrder; the fixed 10.1.26100.4188 reports nothing. It also found five problems.
-
no false load-probe wins for a .NET image's
mscoree.dll. An image with a CLR header getsmscoree.dllfrom the OS loader, which loads it from the system directory without searching the application directory (start trace: no app-directory probe). The static engine no longer emits a SearchOrder/Phantom/EnvPath finding for that import and logs the skip at verbose level. The--verify-loadprobe had reported Wins because it resolves the name in the scanner's own child process. General rule: when the probe says Wins but the canary in the target timed out, the finding gets "Load probe and canary disagree: probe Wins, canary Timeout" and the probe does not raise its tier; scoring is otherwise unchanged. Themscoreerule is based on Windows 11 build 26300. -
existing files are restored under their exact name. When a canary or probe position already held a file (the Microsoft
IpOverUsbDiscovery.dll), the restore used the candidate's lower-caseDllName, so the file came back asipoverusbdiscovery.dll(content, size and mtime were preserved). The backup now records the on-disk name, SHA-256, size and mtime, restores to that exact path and verifies all four (file-restore-verified); a mismatch is residue and exit code 4. The finding gets "Canary replaced an existing file (writable existing DLL); original restored". -
the first cleanup delete of a loaded canary no longer falls through to a second stop. Every service canary's first delete failed ("Access denied") and only the retry, after a second stop, succeeded. Measured on the VM: the service's process had already exited, there was no Restart Manager holder (not Defender, not a child process), the error was access denied (never a sharing violation), and the delete succeeded 49–65 ms later: the image was still mapped for a moment after the process exited. After the first failure the cleanup now retries every 50 ms for up to 2 s (
file-deleted ok (bounded retry: …)), and the failure's audit line records the error type and the holders at that moment. The canary's stops also capture the service's PID and wait up to 10 s for it to exit (process-exit-wait, with the PID and the wait time). The stop-again, retry and residue path stays as the fallback. A stop is no longer sent to a service that is already Stopped. -
stage-ready console output. One
CONFIRMED <DLL> <hole> <type> as <identity> (<trigger>)line per Confirmed finding, whatever--formatis; per-event "ETW: ignored open … by the System process (PID 4)" lines go to the log file only (one count line at verbose level); each phase header and summary is printed once; ASCII symbols (->for→) when the output is redirected or the console is not UTF-8; the fire time is given relative to the plant and the start request ("2.2 s after plant, 0.2 s after start request (before RUNNING)") instead of a negative "after RUNNING"; soft gates are worded as score adjustments; the AutoElevate hunt is skipped (and says so) when--targetis outside the Windows directory. -
release build documented. The release asset
DLLHijackHunter-v2.7.0-win-x64.exeis.\build.ps1 -Release -SingleFile(Release, net8.0-windows, win-x64, self-contained single file). The README's rawdotnet publishcommand now includes-p:TargetFrameworks=net8.0-windows, without which it fails on a machine with only the .NET 8 SDK (NETSDK1045)..\build.ps1with no switches stays a Debug build. -
never start a service the tool cannot stop again. On the VM,
gpsvc(Group Policy Client) had stopped on its own just before the ETW snapshot; the ETW phase started it, and everysc stop gpsvcthen failed with OpenService error 5, so the scan ended with service-state residue and exit code 4. Before any phase starts a service the snapshot recorded as Stopped, the tool now opens the SCM and the service withSERVICE_START | SERVICE_STOP; if that fails, the service is not started (not starting stopped service <name>: tool cannot stop it again (<error>)at Info, counted in the end-of-scan summary next to the guard-skip count). As a fallback, a service the tool started that does not accept a stop (dwControlsAcceptedwithoutSERVICE_ACCEPT_STOP) is not restored but reported as residue of the new kindservice-not-restorable(exit code 4). The guard, the snapshot and every other residue / exit-4 case are unchanged.- only stable states are judged, and the end of the scan decides. On the HijackRange VM,
edgeupdatewas started by the ETW phase, was RUNNING withdwControlsAccepted=0x083 ms later, and was reported asservice-not-restorable(exit 4), although it stopped on its own (network off) before the scan ended.dwControlsAcceptedis now read only once the service has reached a stable state. A service that stops on its own right after its start is auditedservice <name> stopped on its own after N s. A RUNNING service withoutSERVICE_ACCEPT_STOPis only provisionally not restorable (audit line, no error). When the residue list is built at the end of the scan, each such service gets a bounded wait (up to 120 s): back in its snapshot state = no residue (service-not-restorable <name> returned to <state> on its own after N s), still off it =service-not-restorableresidue and exit 4, as before. The end-of-scan summary counts the services that returned to their snapshot state on their own.
- only stable states are judged, and the end of the scan decides. On the HijackRange VM,
New CanaryActions actions: process-exit-wait, file-restore-verified, service-not-restorable, service-provisionally-not-restorable, service-self-stopped, service-self-recovered; new residue kind service-not-restorable. New log level TRACE (log file only).
Known issues
- Untargeted scans and already-running services. An auto-start service that is running when the scan starts loaded its start-up DLLs before the ETW trace existed. Without
--targetor--restart-servicesit is not restarted under the trace, so DLLs it loads only at run time are not seen: a plain--profile aggressivescan of the SDK's IP over USB service misses the CVE'sCRYPTSP.dll(it reports the companion finding only).--target <install dir>and the disruptive, opt-in--restart-servicesboth find and confirm it as SYSTEM. - The
mscoree.dllrule was verified on Windows 11 build 26300 only; Windows 10 is not yet verified. - Overwriting an existing DLL is reported with its usual type (e.g. SearchOrder) plus a note that the original was restored; a separate "writable existing DLL" type is not part of this release.
Download
DLLHijackHunter-v2.7.0-win-x64.exe (self-contained single file, no .NET install needed)
- Size: 77,714,721 bytes
- SHA-256:
6FA3D6E3173FCBC05C789B8F3F173AFFED7C7E18AF9406ABE070E08359EE085E - Built from
6c60d82with.\build.ps1 -Release -SingleFile