Endpoint Detection and Response (EDR) platforms have spent the past decade fine-tuning in-memory surveillance. Traditional process injection methods—ranging from classic VirtualAllocEx and WriteProcessMemory patterns to Asynchronous Procedure Call (APC) queuing and early bird injection—now trigger high-confidence behavioral alerts across modern Security Operations Centers (SOCs). Modern threat actors have adapted by transitioning from conspicuous cross-process memory manipulation to lesser-known, native OS primitives that mirror legitimate operating system mechanics.
Among the most sophisticated of these advanced evasion techniques is Dirty Vanity, a remote code injection method that weaponizes native Windows process forking. Originally introduced within the Windows NT architecture to support the POSIX subsystem and later adapted for the Windows Subsystem for Linux (WSL1), process cloning creates an exact duplicate of a target running process. By abusing RtlCloneUserProcess or NtCreateProcessEx, an attacker can duplicate a benign host process, inject shellcode without triggering cross-process allocation signatures, and evade user-mode API hooks. However, while memory-level detection can be blind-sided, network-level communication remains an inescapable requirement for malicious Command-and-Control (C2). Applying deterministic Layer 3 WireGuard egress filtering isolates cloned rogue processes before external data exfiltration can occur.
+-------------------------------------------------------------------------------+
| DIRTY VANITY PROCESS FORKING INJECTION & NETWORK CONTAINMENT |
+-------------------------------------------------------------------------------+
| |
| [Attacker Process (Malicious Context)] |
| +-------------------------------------------------------------------------+ |
| | 1. Obtain handle to target benign process (e.g., explorer.exe) | |
| | 2. Invoke undocumented RtlCloneUserProcess() API | |
| +-------------------------------------------------------------------------+ |
| | |
| v (Kernel Memory Copy-on-Write) |
| [Cloned Child Process (Forked Identity)] |
| +-------------------------------------------------------------------------+ |
| | - Inherits exact virtual memory, PEB, DLL mappings, and clean headers | |
| | - Unhooked ntdll.dll state (EDR user-mode telemetry neutralized) | |
| | 3. Overwrite clean memory section with payload shellcode | |
| | 4. Spawn initial thread via NtCreateThreadEx() | |
| +-------------------------------------------------------------------------+ |
| | |
| +-----------------------+-----------------------+ |
| | (Attempts Raw C2 Egress) | |
| v v |
| [Unprotected Network Stack] [WireGuard Cryptographic Tunnel] |
| - Raw outbound TCP connection - Strict WFP / netfilter rules |
| - Cleartext TLS SNI inspection - Micro-segmented egress gateway |
| - Exfiltration succeeds unmonitored - Rogue C2 beacon dropped (RST) |
+-------------------------------------------------------------------------------+
Windows NT Process Forking: The Mechanics of RtlCloneUserProcess
In Unix environments, the fork() system call is the bedrock of process lifecycle management. Windows historically rejected this paradigm in favor of CreateProcess, which initializes a process from an executable image stored on the disk filesystem. However, starting with Windows Vista and extended in Windows 10/11, the native NT kernel (ntoskrnl.exe) provides low-level system services capable of genuine process cloning: NtCreateProcessEx and the ntdll wrapper RtlCloneUserProcess.
When a thread invokes RtlCloneUserProcess, the kernel executes several key actions:
- It allocates a new process object (
EPROCESS) in kernel memory. - It replicates the entire Virtual Address Space (VAS) of the target process using memory management Copy-on-Write (CoW) pages.
- It duplicates handle tables, environment variables, loaded module lists, and the Process Environment Block (PEB).
- Unlike standard process creation, the kernel does not invoke
smss.exeor load the executable image afresh from storage media.
// Simplified architectural signature of RtlCloneUserProcess
NTSTATUS NTAPI RtlCloneUserProcess(
IN ULONG ProcessFlags,
IN PSECURITY_DESCRIPTOR ProcessSecurityDescriptor OPTIONAL,
IN PSECURITY_DESCRIPTOR ThreadSecurityDescriptor OPTIONAL,
IN HANDLE DebugPort OPTIONAL,
OUT PRTL_USER_PROCESS_INFORMATION ProcessInformation
);
The resulting cloned process possesses an identical memory footprint to the target process. If the attacker clones a trusted system component—such as explorer.exe, svchost.exe, or spoolsv.exe—the child process inherits clean, authenticode-verified module images, valid page table entries, and authentic command-line parameters.
Dirty Vanity Execution Chain and EDR Telemetry Gaps
The Dirty Vanity technique leverages process cloning to execute shellcode while remaining invisible to standard endpoint telemetry pipelines. The attack sequence unfolds across four distinct phases:
First, the attacker process obtains an open handle to a target benign process with PROCESS_CREATE_PROCESS access rights. Rather than allocating new memory regions inside the target (which triggers VirtualAllocEx behavioral detection), the attacker calls RtlCloneUserProcess specifying the target process handle. The operating system creates a detached, suspended child process with an exact duplicate of the target's memory space.
Second, the attacker locates an executable memory region within the cloned process. Because the memory is cloned via Copy-on-Write, the attacker writes the payload directly into an existing executable section (such as an unused code cave or memory region within ntdll.dll or kernel32.dll) using WriteProcessMemory. Crucially, because the target child process is newly created and suspended, EDR sensor DLLs have not yet initialized their user-mode API inline hooks (jmp patches) inside the child's address space.
+-------------------------------------------------------------------------------+
| DIRTY VANITY VS CLASSIC INJECTION TELEMETRY COMPARISON |
+-------------------------------------------------------------------------------+
| Telemetry Vector Classic Injection Dirty Vanity Forking |
| ------------------ ------------------- -------------------- |
| Process Creation Disk Image Read (PE) Fork Memory Cloning |
| Memory Allocation VirtualAllocEx (PAGE_RWX) Existing Cloned Region |
| EDR Inline Hooks Active in Target Absent in Suspended Fork |
| Kernel Callback PsSetCreateProcessNotify Forks lack ImageLoad |
| Call Stack Verification Foreign Thread Creation Legitimate Process PEB |
+-------------------------------------------------------------------------------+
Third, the attacker calls NtCreateThreadEx to start execution at the entry point of the injected shellcode. When the thread starts, kernel callbacks such as PsSetCreateProcessNotifyRoutineEx report process creation, but the image path matches the legitimate cloned binary. Additionally, memory scanners evaluating module integrity observe that the process image matches disk metadata, successfully masking the presence of the payload.
Network Containment: Blocking C2 Egress via WireGuard
While Dirty Vanity successfully neutralizes user-mode endpoint sensors, it cannot alter the fundamental laws of network communications. To execute second-stage payloads, receive interactive commands, or exfiltrate credentials, the cloned process must establish an external socket connection to a Command-and-Control (C2) server.
Organizations relying solely on host-based endpoint agents remain vulnerable to in-memory evasion. The decisive mitigation strategy lies in network-level micro-segmentation and mandatory cryptographic tunneling via WireGuard.
By routing all host outbound traffic through an immutable Layer 3 WireGuard gateway, network administrators enforce strict cryptographic egress policies:
# Hardening Linux and Windows network egress using policy-based routing
# Enforcing WireGuard cryptokey routing for all outbound enterprise connections
# 1. Establish isolated WireGuard interface
wg setconf wg0 /etc/wireguard/corporate-gateway.conf
# 2. Block direct outbound traffic directed past the VPN interface
iptables -A OUTPUT -m owner --uid-owner root -j ACCEPT
iptables -A OUTPUT -o wg0 -j ACCEPT
iptables -A OUTPUT -p udp --dport 51820 -j ACCEPT
iptables -A OUTPUT -j DROP
# 3. Log dropped anomalous sockets originating from rogue child processes
iptables -A OUTPUT -m limit --limit 5/min -j LOG --log-prefix "ANOMALOUS_EGRESS_BLOCKED: "
On Windows enterprise endpoints, administrators configure the Windows Filtering Platform (WFP) to mandate that only verified network adapters can establish external Layer 4 TCP/UDP sockets:
# PowerShell snippet: Enforce strict WireGuard socket binding via WFP
New-NetFirewallRule -DisplayName "Block-Direct-Egress" `
-Direction Outbound `
-InterfaceAlias "Ethernet", "Wi-Fi" `
-Action Block
New-NetFirewallRule -DisplayName "Allow-WireGuard-Egress" `
-Direction Outbound `
-InterfaceAlias "WireGuard Tunnel" `
-Action Allow
When a cloned Dirty Vanity process attempts to initiate an HTTP/3, TLS, or DNS covert beacon, the outbound packet is captured by the deterministic policy table. If the packet attempts to traverse physical interfaces directly, the firewall drops it immediately. If it enters the WireGuard tunnel, the egress gateway subjects the traffic to JA4 fingerprinting, entropy analysis, and domain reputation scoring, severing the C2 lifeline.
Practical Implementation and Hardening Architecture
Securing enterprise infrastructure against advanced process forking attacks requires combining endpoint memory hygiene with cryptographic network controls:
Audit Forking Privileges via Attack Surface Reduction (ASR): Configure Microsoft Defender ASR rule
Block process creations originating from PSExec and WMI commandsand monitor events with Event ID 4688 (A new process has been created). Specifically inspect processes where the Creator Process ID does not match standard parent-child hierarchies.Deploy In-Kernel Memory Scanning (Kernel EtwTI): Ensure your endpoint security solution utilizes the Microsoft-Windows-Threat-Intelligence provider (EtwTI). While user-mode hooks are omitted in cloned processes, EtwTI logs
EtwTiProcessCreateand memory modifications directly from kernel space, alerting on abnormal handle duplication.Mandate Split-Tunnel Lockdown in Corporate VPNs: Configure your VPN infrastructure to disable unmanaged split-tunneling. When mobile workers or remote engineers access sensitive corporate resources, all IP packets must be routed across authenticated WireGuard endpoints, neutralizing local rogue beaconing.
Utilize Modern Multi-Layer VPN Frameworks: Deploy VPN solutions with built-in zero-leak network architectures. Systems integrating RiceGuard network isolation continuously monitor interface metrics and enforce cryptographic encapsulation, ensuring corporate devices remain resilient against sophisticated process injection threats.



