Endpoint Detection and Response (EDR) agents rely heavily on kernel callbacks and file system minifilter drivers to verify the legitimacy of executing binaries. For decades, security vendors operated under the foundational premise that the executable bytes mapped into an address space correspond faithfully to the file residing on persistent storage. Advanced process manipulation primitives, however, continuously challenge this assumption. Techniques such as Process Hollowing, Process Doppelgänging, and Process Ghosting demonstrated that discrepancies between memory pages and disk images create lethal blind spots for inspection tools.
Process Herpaderping takes this divergence to an architectural extreme. By abusing the precise lifecycle of Windows NT Section Objects, an attacker writes an executable payload to disk, maps it into memory, creates the process object, and subsequently overwrites the disk file with a completely benign binary or random data before any thread begins execution. When kernel monitoring routines trigger upon thread startup, security sensors inspect the modified file on disk, validating its signature and hash against clean operating system components while the payload executes in volatile RAM. Neutralizing this threat requires both low-level kernel write telemetry and deterministic Layer 3 network egress containment through WireGuard cryptographic tunneling.
+-------------------------------------------------------------------------------+
| PROCESS HERPADERPING: DISK-MEMORY DESYNCHRONIZATION SEQUENCE |
+-------------------------------------------------------------------------------+
| |
| 1. DROP PAYLOAD Write malicious PE payload to target file on disk |
| (CreateFileW: FILE_READ_DATA | FILE_WRITE_DATA) |
| |
| 2. MAP SECTION Kernel creates SEC_IMAGE Section Object in memory |
| (NtCreateSection: references file handle) |
| |
| 3. CREATE PROCESS Instantiate Process Object linked to Section Object |
| (NtCreateProcessEx: no active threads running yet) |
| |
| 4. OBFUSCATE DISK Overwrite file on disk with benign data (e.g. calc.exe) |
| (SetFilePointer + WriteFile: Section remains intact) |
| |
| 5. SPAWN THREAD NtCreateThreadEx triggers PsSetCreateProcessNotify... |
| EDR reads benign disk file -> Verifies clean hash! |
| |
| 6. NETWORK CONTAIN Rogue process attempts C2 -> Blocked by WireGuard |
| Cryptokey Routing on isolated guest network gateway |
+-------------------------------------------------------------------------------+
Architectural Mechanics: How Process Herpaderping Exploits Windows Kernel Section Objects
Understanding Process Herpaderping begins with the Windows Memory Manager (Mm) and the Object Manager (Ob). In the Windows NT subsystem, executing an executable does not simply involve copying raw bytes into an allocated buffer. Instead, the operating system relies on Section Objects backed by files. When NtCreateSection is invoked with the SEC_IMAGE attribute, the Memory Manager parses the Portable Executable (PE) headers, establishes section alignment, resolves image characteristics, and commits page tables mapped directly to the underlying file.
In a normal execution sequence, the file handle remains open or shared during process creation. However, the NT kernel enforces write restrictions on an active image section only while certain handle flags persist. The Process Herpaderping workflow exploits this window:
- File Creation with Shared Write Permissions: The attacker opens a target file path on disk using
CreateFileW, requesting read, write, and execute rights while specifyingFILE_SHARE_READ | FILE_SHARE_WRITE. - Section Object Instantiation: The process invokes
NtCreateSectionspecifyingSEC_IMAGE. At this moment, the kernel reads the PE structure and populates the section control blocks. - Process Creation Without Threads: The attacker calls
NtCreateProcessEx(orNtCreateUserProcess), supplying the section handle. The kernel constructs theEPROCESSexecutive structure, initializes the virtual address space, and maps the image section into the new process context. Crucially, no thread has been created yet. - Disk File Overwriting: Because the initial file handle possessed write access, the attacker seeks to offset zero and writes benign bytes (such as an authentic, signed Microsoft binary like
notepad.exe, zero padding, or arbitrary metadata) over the disk file. The file handle is flushed and closed. - Thread Creation: Finally,
NtCreateThreadExis called with the entry point pointing to the malicious memory mapping.
Because Windows image sections are backed by the cache manager and dirty page mechanics, modifying the physical disk file after the SEC_IMAGE section is instantiated does not alter the already mapped memory pages in RAM. The memory pages continue to host the malicious code, while the file on the storage drive reflects benign content.
The Kernel Inspection Blindspot: Why Minifilters and Process Notify Callbacks Desynchronize
Security products rely on kernel callbacks registered via PsSetCreateProcessNotifyRoutineEx and file system minifilter drivers registering IRP_MJ_CREATE and IRP_MJ_ACQUIRE_FOR_SECTION_SYNCHRONIZATION. When a process starts, the operating system invokes these registered callbacks to notify endpoint defense agents.
The core vulnerability targeted by Process Herpaderping is temporal desynchronization:
- Inspection Timing: The
PsSetCreateProcessNotifyRoutineExcallback is executed by the kernel when the first thread is inserted into the process, not whenNtCreateProcessExconstructs theEPROCESSblock. By the time this callback fires, the attacker has already overwritten the disk file. - Disk Path Resolution: The
PS_CREATE_NOTIFY_INFOstructure provided to the security callback containsImageFileNameandFileOpenName. Security tools query these paths to inspect the binary on disk, compute cryptographic SHA-256 hashes, verify Authenticode signatures, and apply machine learning reputation scores. - Minifilter Misdirection: When the EDR sensor reads the binary from disk, the file system driver returns the overwritten data. If the attacker replaced the payload with a valid Windows system executable, the EDR verifies a legitimate Microsoft signature and concludes the process is trustworthy.
+-------------------------------------------------------------------------------+
| ENDPOINT SENSOR DESYNCHRONIZATION VS EXECUTION REALITY |
+-------------------------------------------------------------------------------+
| Component Disk State (Inspected) Memory State (Executed) |
| ------------------ ------------------------ ----------------------- |
| File Identity C:\Users\Target\app.exe Allocated SEC_IMAGE Base |
| SHA-256 Hash Clean OS Signature Custom Threat Payload |
| Authenticode Valid Microsoft Root CA Unsigned Shellcode Loader |
| EDR Perception Trusted System Process Rogue Command Execution |
+-------------------------------------------------------------------------------+
Even advanced memory scanners face detection hurdles. Many memory scanners inspect memory pages only when a suspicious disk-creation event triggers an alert. Because the creation event reported a benign binary with a valid signature, heuristic scanners deprioritize or omit deep memory inspection for that process PID, granting the attacker stealth execution.
Network Egress Containment: Neutralizing Unmapped C2 with WireGuard Cryptokey Routing
While host-level inspection mechanisms can be deceived by file-memory discrepancies, malware cannot accomplish its objectives in total isolation. Whether executing credential dumping, ransomware deployment, or data staging, modern threats depend on external Command-and-Control (C2) communication. An endpoint compromised via Process Herpaderping must eventually open a socket, initiate a TLS handshake, or exchange packets with remote infrastructure.
Deterministic network segmentation deployed through WireGuard tunnels provides an impenetrable perimeter defense that operates completely outside the compromised host operating system:
- Decoupled Security Boundary: By routing all outbound workstation traffic through a dedicated WireGuard gateway (such as a hardware firewall, OpenWrt router, or hypervisor network virtual appliance), network inspection does not trust the host kernel's process reputation tables.
- Cryptokey Routing Validation: WireGuard relies on static public keys bound strictly to predefined IP endpoints. Packets leaving the host are cryptographically authenticated and routed across isolated network namespaces. Rogue connections initiated by the desynchronized process cannot spoof internal peer identities.
- Strict Egress Whitelisting: On the WireGuard gateway, firewall rules enforce strict egress controls. Workstations bound to operational environments are restricted to designated proxy endpoints, preventing unauthorized TCP/UDP egress to external IP ranges regardless of whether the originating host process appears to be
calc.exeorsvchost.exe. - Elimination of Split-Tunnel Leaks: Configuring
AllowedIPs = 0.0.0.0/0, ::/0forces all endpoint communications into the encrypted tunnel. Malware attempting direct socket bindings to circumvent local inspection fails because non-tunneled traffic drops at the network interface layer.
[Interface]
PrivateKey = <Client_Device_Private_Key>
Address = 10.198.44.2/32, fd00:cafe:44::2/128
DNS = 10.198.44.1
MTU = 1420
[Peer]
PublicKey = <Gateway_Cryptokey_Routing_Endpoint>
Endpoint = 198.51.100.10:51820
AllowedIPs = 0.0.0.0/0, ::/0
PersistentKeepalive = 25
When an attacker achieves code execution through Process Herpaderping, their C2 payloads encounter strict cryptographic enforcement at the gateway. Attempts to beacon across non-standard ports or connect to unapproved IP destinations are dropped, neutralizing the compromise before lateral movement can occur.
Hardening Strategies: Kernel-Level Write Detection and Host Boundary Isolation
Relying solely on post-execution signatures leaves workstations vulnerable to zero-day evasion. Organizations must deploy defense-in-depth controls combining low-level OS telemetry, driver hardening, and network boundary policies.
Kernel-Level Write Telemetry for Mapped Images
Endpoint security architectures must upgrade kernel minifilters to detect writes to files backing existing section objects:
- Section Tracking via
FILE_OBJECT: File system minifilters (FltRegisterFilter) can examine theSectionObjectPointermember inside thePFILE_OBJECT. IfSectionObjectPointer->ImageSectionObjectis non-NULL while anIRP_MJ_WRITEorIRP_MJ_SET_INFORMATION(file truncation) request arrives, a process is actively modifying an executable image mapped into memory. - Denying Concurrent Write Handles: Security drivers can actively reject
CreateFilerequests that specify write permissions on files currently held inSEC_IMAGEsections, preventing the file content from mutating after section initialization.
Memory Integrity and Attack Surface Reduction
- Process Mitigation Policies: Enforcing
ProcessSignaturePolicyandMicrosoftSignedOnlyprevents arbitrary binaries from loading unsigned child dependencies. - Arbitrary Code Guard (ACG): Enabling ACG (
SetProcessMitigationPolicywithProcessDynamicCodePolicy) prevents processes from creating executable memory pages or altering existing code mappings, severely constraining the shellcode execution stage of injection loaders.
Operational Summary
| Defense Layer | Security Control | Protection Mechanism |
|---|---|---|
| Kernel File System | Minifilter IRP_MJ_WRITE Hook |
Blocks modifications to files with active ImageSectionObject pointers |
| Process Monitoring | Memory vs Disk Comparison | Validates volatile memory hashes against storage image at thread creation |
| Memory Isolation | Arbitrary Code Guard (ACG) | Blocks dynamic allocation and modification of executable pages |
| Network Perimeter | Router WireGuard Tunneling | Enforces Cryptokey Routing and strict egress filtering on outbound C2 |
By combining proactive kernel-level write monitoring on the endpoint with deterministic network containment via WireGuard tunnels, security operations teams establish a layered defense architecture capable of neutralizing sophisticated process desynchronization attacks.



