Back to Blog

Advanced Malware Analysis of Process Hollowing Techniques

Advanced Malware Analysis of Process Hollowing Techniques

In the landscape of modern endpoint defense, signature-based detection is increasingly obsolete. As adversaries move toward "living-off-the-land" (LotL) strategies, the ability to execute arbitrary code within the context of a trusted, legitimate process is paramount for evasion. One of the most enduring and sophisticated methods for achieving this is Process Hollowing.

For the malware analyst or incident responder, understanding the mechanics of process hollowing is not merely an academic exercise; it is a prerequisite for effective memory forensics and behavioral detection. This post provides a deep dive into the technical execution, detection vectors, and the evolving nuances of this technique.

The Core Mechanism: Execution Flow

Process hollowing is a technique where an attacker creates a new instance of a legitimate process (e.g., `svchost.exe`, `explorer.exe`, or `lsass.exe`) in a suspended state, unmaps the legitimate code from the process's memory, and replaces it with a malicious payload. To the operating system and many basic monitoring tools, the process appears to be a legitimate, digitally signed Windows binary.

The execution flow typically follows five distinct stages:

1. Process Creation in Suspended State

The adversary initiates the attack using the `CreateProcessW` API. The critical component here is the `dwCreationFlags` parameter, specifically the `CREATE_SUSPENDED` flag. By starting the process in a suspended state, the attacker ensures that the primary thread is halted before the initial entry point of the legitimate image is executed. This provides a window of opportunity to manipulate the process's memory space without interference from the original code.

2. Unmapping the Original Image

Once the process is suspended, the attacker must remove the original executable's code from the target's memory. This is traditionally achieved via `NtUnmapViewOfSection` or `ZwUnmapViewOfSection`. The goal is to clear the memory region where the original PE (Portable Executable) image resides, effectively "hollowing" the process.

Note: Modern EDRs closely monitor calls to `NtUnmapViewOfSection` targeting common system processes, leading many modern variants to move toward "Process Overloading" (overwriting sections without unmapping) to evade this specific heuristic.

3. Memory Allocation and Payload Injection

With the original image removed, the attacker allocates new memory within the target process using `VirtualAllocEx`. The size of this allocation must be sufficient to hold the malicious payload's image.

The payload is then written into the newly allocated space using `WriteProcessMemory`. A sophisticated actor does not simply dump a raw blob; they must perform a manual mapping of the malicious PE. This involves:

  • Writing the PE headers.
  • Allocating and mapping individual sections (`.text`, `.data`, `.rsrc`) according to their virtual offsets.
  • Handling relocations if the payload's preferred base address cannot be honored.

4. Thread Context Manipulation

This is the most critical step for redirection. The attacker must point the process's execution flow to the new entry point of the malicious payload. This is accomplished using `GetThreadContext` to retrieve the current state of the suspended thread's registers, followed by `SetThreadContext`.

The attacker specifically modifies the `EAX`/`RAX` register (which holds the entry point address in many architectures) or the `EIP`/`RIP` register. By updating the instruction pointer to point to the entry point of the injected payload, the attacker prepares the process for a seamless transition from "legitimate" to "malicious."

scape 5. Resuming Execution

The final step is calling `ResumeThread`. The kernel transitions the thread from the `Wait:Suspended` state to `Running`. The CPU begins executing instructions at the newly defined entry point, and the malicious payload executes under the guise of the trusted process.

Detection and Forensic Analysis

Detecting process hollowing requires moving beyond the file system and into the realm of volatile memory analysis and behavioral telemetry.

Memory Forensics: The Gold Standard

When analyzing a suspected memory dump (e.g., via Volatility), look for the following indicators:

  • Discrepancies in PE Headers: Use the `malfind` plugin to identify memory regions marked as `PAGE_EXECUTE_READWRITE` (RWX) that contain an `MZ` header but lack a corresponding file on disk.
  • Inconsistent Base Addresses: Compare the `ImageBaseAddress` reported in the Process Environment Block (PEB) with the actual mapped memory. If the PEB points to a location that does not align with the executable's disk-based headers, hollowing is likely.
  • Module Mismatch: Check for "floating" code-executable memory regions that are not backed by any loaded module (DLL or EXE) on the file system.

Behavioral and API Telemetry

Modern EDR/XDR solutions utilize ETW (Event Tracing for Windows), specifically the `Microsoft-Windows-Threat-Intelligence` provider, to monitor for suspicious API sequences. High-fidelity alerts are often triggered by:

  1. `CreateProcess` with `CREATE

Conclusion

As shown across "The Core Mechanism: Execution Flow", "Detection and Forensic Analysis", a secure implementation for advanced malware analysis of process hollowing techniques depends on execution discipline as much as design.

The practical hardening path is to enforce host hardening baselines with tamper-resistant telemetry, behavior-chain detection across process, memory, identity, and network telemetry, and continuous control validation against adversarial test cases. This combination reduces both exploitability and attacker dwell time by forcing failures across multiple independent control layers.

Operational confidence should be measured, not assumed: track time from suspicious execution chain to host containment and reduction in reachable unsafe states under fuzzed malformed input, then use those results to tune preventive policy, detection fidelity, and response runbooks on a fixed review cadence.

Related Articles

Explore related cybersecurity topics:

Recommended Next Steps

If this topic is relevant to your organisation, use one of these paths: