Endpoint Detection and Response (EDR) platforms have spent the last decade building sophisticated behavioral hooks around Windows memory management APIs. Security analysts and automated heuristics routinely flag suspicious API sequences such as VirtualAllocEx with PAGE_EXECUTE_READWRITE permissions, followed by WriteProcessMemory and execution via CreateRemoteThread.

To counter this, advanced adversaries developed techniques such as Process Hollowing, Module Stomping, and Process Ghosting. However, most memory evasion tradecraft still triggers alarms during memory allocation or memory permission transitions.

In 2023, security researchers at Security Joes introduced Mockingjay: a process injection methodology that evades user-mode EDR hooks by performing zero memory allocations and zero memory permission modifications. By identifying legitimate, digitally signed third-party DLLs containing default Read-Write-Execute (RWX) sections, an attacker writes shellcode directly into existing executable memory without invoking monitored Windows APIs.

+-------------------------------------------------------------------------+
|        MOCKINGJAY INJECTION WORKFLOW & NETWORK WIREGUARD CONTAINMENT     |
+-------------------------------------------------------------------------+
|                                                                         |
|  [ATTACK STAGE: EVADING EDR API HOOKS VIA DEFAULT RWX DLL SECTIONS]     |
|                                                                         |
|  1. Attacker enumerates binaries for PE Section Characteristics:        |
|     IMAGE_SCN_MEM_EXECUTE | IMAGE_SCN_MEM_READ | IMAGE_SCN_MEM_WRITE    |
|     (e.g., msys-2.0.dll containing pre-allocated 16 KB RWX space)       |
|                                                                         |
|  2. LoadLibraryA / Target Process Mapping                               |
|     - Windows PE Loader maps DLL into process virtual address space     |
|     - RWX memory is natively granted by operating system loader         |
|                                                                         |
|  3. Memory Writing (Zero Allocations / Zero Permission Changes)         |
|     - No VirtualAllocEx called   (EDR allocation hooks blind)           |
|     - No VirtualProtectEx called (EDR W^X transition hooks blind)       |
|     - Direct pointer copy or WriteProcessMemory into RWX section        |
|                                                                         |
|  4. Execution Handover                                                  |
|     - Thread context hijacked or function pointer invoked               |
|     - Shellcode executes cleanly in trusted process address space       |
|                                                                         |
|                      |                                                  |
|                      v (Payload Attempts C2 Egress & Lateral Pivot)     |
|                                                                         |
|  [DEFENSE LAYER: HARDENED WIREGUARD ENCLAVE & ROUTER EGRESS FILTERING]   |
|                                                                         |
|  Local Endpoint Firewall & Gateway Router:                              |
|  - Drops unauthenticated outbound TCP/UDP beacons                       |
|  - Forces all egress through WireGuard wg0 interface (ChaCha20-Poly1305)|
|  - Blocks RFC 1918 private subnet lateral scanning                      |
|  - Sinkholes unauthorized DNS staging queries at encrypted resolver     |
+-------------------------------------------------------------------------+

The Mechanics of Default RWX Sections

Under the Microsoft Portable Executable (PE) specification, every executable file and dynamic link library (DLL) organizes code and data into distinct sections (such as .text, .data, .rdata, and .reloc).

Each section is defined in the PE header by an IMAGE_SECTION_HEADER structure:

typedef struct _IMAGE_SECTION_HEADER {
    BYTE    Name[IMAGE_SIZEOF_SHORT_NAME];
    union {
            DWORD   PhysicalAddress;
            DWORD   VirtualSize;
    } Misc;
    DWORD   VirtualAddress;
    DWORD   SizeOfRawData;
    DWORD   PointerToRawData;
    DWORD   PointerToRelocations;
    DWORD   PointerToLinenumbers;
    WORD    NumberOfRelocations;
    WORD    NumberOfLinenumbers;
    DWORD   Characteristics;
} IMAGE_SECTION_HEADER, *PIMAGE_SECTION_HEADER;

The critical field is Characteristics, a bitmask determining the memory page protections applied by the Windows kernel loader (ntoskrnl.exe / ntdll.dll) when mapping the image into virtual memory:

  • IMAGE_SCN_MEM_EXECUTE (0x20000000): The section can be executed as code.
  • IMAGE_SCN_MEM_READ (0x40000000): The section can be read.
  • IMAGE_SCN_MEM_WRITE (0x80000000): The section can be written to.

When combined, these flags produce 0xE0000020 or 0xE0000040, granting full PAGE_EXECUTE_READWRITE permissions right out of the box.

$$\text{Section Characteristics} = \text{EXECUTE} \lor \text{READ} \lor \text{WRITE} = \mathtt{0xE0000000}$$

While modern compilers (such as MSVC with /NXCOMPAT and /DYNAMICBASE) separate code (RX) from data (RW) to enforce the W^X (Write XOR Execute) security model, legacy binaries, specialized developer runtimes, and outdated third-party dependencies frequently ship with default RWX sections.

For example, researchers discovered that msys-2.0.dll (distributed with various developer utilities) contains a default RWX section measuring over 16 kilobytes—more than enough space to stage sophisticated C2 loaders.

Why Mockingjay Evades Modern EDR Detection

Modern EDR platforms deploy inline hooks (such as jmp instructions in ntdll.dll) and kernel callbacks (ObRegisterCallbacks, PsSetCreateProcessNotifyRoutineEx) to monitor process creation and memory injection.

Detection engines evaluate four primary indicators:

  1. Dynamic Memory Allocation: Invocation of NtAllocateVirtualMemory with executable permissions (PAGE_EXECUTE_READWRITE).
  2. Page Protection Transition: Invocation of NtProtectVirtualMemory modifying memory from PAGE_READWRITE to PAGE_EXECUTE_READ (a signature indicator of reflective DLL loaders and shellcode unpackers).
  3. Unbacked Executable Memory: Shellcode executing from anonymous memory pages not backed by a valid image file on disk.
  4. Call Stack Integrity: Stack frames originating from non-image memory or exhibiting abnormal frame pointers.

Mockingjay neutralizes each of these telemetry points:

  • Zero Allocation: The attacker never calls VirtualAlloc or NtAllocateVirtualMemory. The target memory space was already allocated and mapped by the legitimate Windows PE loader during standard DLL initialization.
  • Zero Permission Mutation: The memory pages already possess RWX rights upon loading. There is never any call to VirtualProtect or NtProtectVirtualMemory.
  • Image-Backed Memory: Because the code resides inside a validly mapped DLL section on disk, memory scans (such as VirtualQueryEx) confirm that the region is mapped from a signed file (MEM_IMAGE), rather than unbacked private memory (MEM_PRIVATE).
+-------------------------------------------------------------------------+
|                  PROCESS INJECTION DETECTION MATRIX                     |
+-------------------------------------------------------------------------+
| Injection Technique  | Allocates Memory? | Mutates Protection? | Backed?|
| -------------------  | ----------------- | ------------------- | ------ |
| Classic DLL Injection| Yes (VirtualAlloc)| Yes (PAGE_EXECUTE)  | Yes    |
| Process Hollowing    | Yes (NtUnmap/Alloc| Yes (PAGE_EXECUTE)  | Mixed  |
| Module Stomping      | No (Uses DLL Text)| Yes (VirtualProtect)| Yes    |
| Mockingjay Injection | NO (Uses RWX Sec) | NO (Native RWX)     | YES    |
+-------------------------------------------------------------------------+

The Injection Execution Flow

An attacker executes Mockingjay through either self-injection (within a loader process) or cross-process injection targeting an existing workstation application:

// Step 1: Locate base address of vulnerable DLL with default RWX section
HMODULE hVulnDll = LoadLibraryA("msys-2.0.dll");
PIMAGE_DOS_HEADER dosHeader = (PIMAGE_DOS_HEADER)hVulnDll;
PIMAGE_NT_HEADERS ntHeaders = (PIMAGE_NT_HEADERS)((BYTE*)hVulnDll + dosHeader->e_lfanew);

// Step 2: Traverse Section Headers to find section with 0xE0000000 mask
PIMAGE_SECTION_HEADER section = IMAGE_FIRST_SECTION(ntHeaders);
void* pRwxPayloadAddress = NULL;

for (WORD i = 0; i < ntHeaders->FileHeader.NumberOfSections; i++) {
    if ((section[i].Characteristics & 0xE0000000) == 0xE0000000) {
        pRwxPayloadAddress = (void*)((BYTE*)hVulnDll + section[i].VirtualAddress);
        break;
    }
}

// Step 3: Write shellcode directly without VirtualProtect
if (pRwxPayloadAddress) {
    memcpy(pRwxPayloadAddress, rawShellcode, sizeof(rawShellcode));

    // Step 4: Execute via direct function pointer or thread trigger
    typedef void (*PayloadEntry)();
    PayloadEntry execute = (PayloadEntry)pRwxPayloadAddress;
    execute();
}

Because the memory region is natively writable and executable, the operating system kernel permits immediate execution without generating a single telemetry event related to memory manipulation.

Architectural Defense: Network Containment & WireGuard Enclaves

Detecting Mockingjay at the host endpoint requires deep memory scanning techniques, such as inspecting DLL section characteristics against known baselines or monitoring memory write operations via hardware breakpoints. However, endpoint controls can be delayed or blinded.

The ultimate objective of any process injection payload is operational impact: establishing Command and Control (C2) communication, downloading secondary modules, or probing the local network for lateral movement.

Security architectures must enforce network-level microsegmentation and cryptographic containment using WireGuard to stop post-exploitation activities dead in their tracks.

+-------------------------------------------------------------------------+
|            WIREGUARD EGRESS ISOLATION & FIREWALL CONFIGURATION          |
+-------------------------------------------------------------------------+
| Interface: wg-secure (Virtual WireGuard Device)                         |
| Cryptography: ChaCha20-Poly1305 / Curve25519                            |
| Host Policy: Restrict raw socket creation to non-isolated apps         |
| Egress Filter: Drop direct outbound traffic on physical NIC             |
| DNS Policy: Force TLS/HTTPS queries through hardened gateway resolver   |
+-------------------------------------------------------------------------+

1. Host-Level Network Microsegmentation

To prevent an injected process from opening outbound reverse shells or initiating internal port scans, enforce strict firewall filtering rules on the endpoint:

# Block direct outbound TCP/UDP traffic from untrusted local subnets
iptables -A OUTPUT -o eth0 -m owner --uid-owner 1001 -j DROP

# Force all developer and third-party workstation traffic into WireGuard
iptables -A OUTPUT -o wg0 -j ACCEPT
iptables -A OUTPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A OUTPUT -j DROP

Under this policy, even if shellcode runs undetected inside a modified DLL section, any packet attempting to reach an external C2 server across the default physical interface (eth0) is dropped by the kernel netfilter subsystem.

2. Cryptographic Enclave Routing via WireGuard

Routing all developer and workstation traffic through a secure WireGuard tunnel ensures that outbound packets undergo centralized inspection and cryptographic validation:

# WireGuard Workstation Isolation Configuration (/etc/wireguard/wg0.conf)
[Interface]
Address = 10.200.0.5/24
PrivateKey = [CLIENT_PRIVATE_KEY]
DNS = 10.200.0.1

[Peer]
PublicKey = [GATEWAY_PUBLIC_KEY]
Endpoint = vpn.vpnrice.net:51820
AllowedIPs = 0.0.0.0/0
PersistentKeepalive = 25

Enforce routing policy to prevent leakage:

# Enforce strict WireGuard routing table
ip rule add from 10.200.0.5 table 150
ip route add default dev wg0 table 150

# Prevent MTU blackholing with MSS clamping
iptables -t mangle -A FORWARD -p tcp --tcp-flags SYN,RST SYN -j TCPMSS --clamp-mss-to-pmtu

By encapsulating workstation traffic in a ChaCha20-Poly1305 tunnel, network administrators conceal endpoint IP addresses, encrypt transmission payloads, and filter malicious egress domains at the central gateway.

Diagnostic Verification and Egress Validation

Security engineers should test endpoint isolation policies to ensure that memory injection payloads cannot communicate with unauthorized network targets.

Admins can verify gateway routing and IP masking using diagnostic utilities such as What is my IP. Ensuring that the host reports the WireGuard gateway address rather than the local ISP address confirms that cryptographic routing is actively shielding the workstation.

Defense Layer Unprotected Enterprise Host Hardened Endpoint with WireGuard
Memory Monitoring Hooked APIs only (VirtualAlloc) PE Header hardening + RWX DLL audits
Injection Resilience Vulnerable to default RWX DLLs Memory execution quarantined at egress
Network Egress Direct unmonitored local interface ChaCha20-Poly1305 encrypted WireGuard
Lateral Movement Full access to local /24 subnet Strict microsegmentation blocks LAN
DNS Threat Defense Unencrypted, uninspected queries Encrypted DoH/DoT with domain sinkholing
C2 Containment Immediate outbound beaconing Completely isolated within secure tunnel

Organizations seeking to insulate developer systems, engineering workstations, and cloud environments from sophisticated evasion tradecraft deploy VPNRice. By orchestrating low-overhead WireGuard tunnels, enforcing granular egress filtering, and maintaining pristine cryptographic boundaries, VPNRice ensures that even zero-allocation memory injection attacks cannot compromise critical corporate infrastructure.

Get VPNRice.

As memory injection techniques evolve to exploit inherent operating system features like default RWX sections, relying solely on endpoint API hooks leaves dangerous blind spots. Combining robust PE section auditing with router-level WireGuard microsegmentation establishes defense-in-depth, containing stealthy payloads before they ever establish unauthorized network footholds.