Back to Blog
Red Teaming

The Art of Process Hollowing: Stealthy Code Injection Techniques

OffSec Research Team
10 June 2026 • 09:00 AM14 min
The Art of Process Hollowing: Stealthy Code Injection Techniques
TL;DR — Process hollowing (a.k.a. RunPE) is a code-injection technique that runs malicious code under the identity of a legitimate process. The operator launches a trusted program (e.g. svchost.exe) suspended, "hollows out" its original executable image from memory, maps a malicious image into the emptied space, repoints the entry point, and resumes — so the process tree, image name, and signatures say "legitimate," while the running code is the attacker's. This article (for authorized red-team and detection-engineering use) details the classic eight-step technique, why it evades naive defenses, its modern descendants (process doppelgänging, herpaderping, ghosting), and the kernel telemetry that exposes the image mismatch.

Context and Authorization

This is written for authorized red teamers and detection engineers. Process hollowing is decades-old, extensively documented, and implemented across open-source tooling and commoditised malware; the value here is a precise mechanical understanding so blue teams can detect it and red teams can emulate adversaries faithfully. Apply only to systems you are authorized to test.

The Goal: Borrow a Legitimate Identity

Defensive products and analysts ask of every running process: what is it, who launched it, is its image signed, does its name match its behaviour? Process hollowing is engineered to make all of those questions return reassuring answers while the actual executing code is malicious.

diagram — rendering…
flowchart TD
    A["Defender's questions"] --> B["Image name? → svchost.exe ✓"]
    A --> C["Path? → C:\\Windows\\System32 ✓"]
    A --> D["Parent? → services.exe-ish ✓"]
    A --> E["Disk file signed? → Microsoft ✓"]
    B & C & D & E --> F["Looks legitimate..."]
    F --> G["...but the MEMORY image was<br/>swapped for malicious code"]
    style G fill:#2a0c14,stroke:#ef233c,color:#fee2e2

The technique exploits a gap between what is on disk (a clean, signed Microsoft binary) and what is in memory (the attacker's code). Defences that judge a process by its on-disk file, its name, or its command line are fooled; only those that compare the in-memory image to the backing file — or watch the manipulation sequence — catch it.

The Classic Technique, Step by Step

diagram — rendering…
sequenceDiagram
    participant M as Malware (loader)
    participant W as Windows API
    participant T as Target (e.g. svchost.exe)
    M->>W: 1. CreateProcess(target, CREATE_SUSPENDED)
    Note over T: process created, primary thread suspended, image mapped but not running
    M->>W: 2. (Get context) GetThreadContext → read PEB/image base
    M->>W: 3. NtUnmapViewOfSection(target, imageBase)  ← "hollow out"
    M->>W: 4. VirtualAllocEx(target, imageBase, sizeOfImage, RWX)
    M->>W: 5. WriteProcessMemory: headers + each section of MALICIOUS image
    M->>W: 6. SetThreadContext: point entry (RIP/EAX) at malicious entry
    M->>W: 7. ResumeThread(target)
    Note over T: now runs attacker code under svchost.exe's identity
  • Create the target suspended. CreateProcess with CREATE_SUSPENDED spawns the legitimate host (commonly svchost.exe, RegAsm.exe, notepad.exe, or another trusted, low-suspicion binary). The OS maps its image but the primary thread never runs.
  • Locate the image base. Read the target's PEB (GetThreadContext → read the base address pointer) to find where its executable image is mapped.
  • Hollow it out. NtUnmapViewOfSection (or ZwUnmapViewOfSection) unmaps the original, legitimate image from the target's address space — leaving a hole.
  • Allocate replacement space. VirtualAllocEx in the target, ideally at the same base, sized to the malicious image, typically RWX.
  • Write the malicious image. WriteProcessMemory copies the attacker's PE headers and each section into the allocated region, applying relocations if the base differs.
  • Repoint the entry point. SetThreadContext updates the suspended thread's instruction pointer (and base-address register) to the malicious image's entry point.
  • Resume. ResumeThread lets the (now malicious) code run — under the host's name, path, PID, and parent.

The result: Task Manager shows svchost.exe, the disk file is genuinely Microsoft-signed, the process lineage looks normal — but the executing bytes are the operator's.

Why It Evades Naive Defences

text
DEFENSE THAT FAILS                 WHYOn-disk file signature check       The disk file is the real, signed binary;                                     the swap is in memory onlyImage-name / path allow-listing    Name & path are the legitimate target'sCommand-line heuristics            The benign host's command line is intactStatic AV scan of the file         Nothing malicious is ever written to disk                                     (the payload lives only in memory)Parent-child process baselining    If launched from a plausible parent, lineage                                     looks normal

Process hollowing's whole value proposition is defeating file- and name-centric trust. Because the payload may never touch disk, traditional file-scanning AV is blind; because the identity is borrowed, name/path/lineage checks pass.

The Tells (and Why Modern EDR Catches It)

The classic technique is, by today's standards, noisy — it leaves a sequence of high-signal API operations and a structural anomaly:

diagram — rendering…
flowchart TD
    A["Detection signals"] --> B["API SEQUENCE on a remote, suspended process:<br/>CreateProcess(SUSPENDED) → NtUnmapViewOfSection<br/>→ VirtualAllocEx(RWX) → WriteProcessMemory<br/>→ SetThreadContext → ResumeThread"]
    A --> C["IMAGE MISMATCH:<br/>in-memory image ≠ backing disk file"]
    A --> D["RWX / private executable region<br/>where a mapped image should be"]
    A --> E["Section is PRIVATE (not IMAGE-backed)<br/>or unmapped legitimate image"]
    B & C & D & E --> F["High-confidence hollowing detection"]
    style F fill:#0c2a22,stroke:#21d48e,color:#d1fae5
  • The API choreography is distinctive. CreateProcess(CREATE_SUSPENDED) followed by NtUnmapViewOfSection on the new process, VirtualAllocEx, WriteProcessMemory, SetThreadContext, and ResumeThread — performed on a suspended child — is a recognisable, rarely-legitimate pattern. EDRs flag this sequence via kernel callbacks and syscall telemetry that the loader cannot patch away.
  • The image doesn't match its file. This is the killer. After hollowing, the process's main module in memory differs from the svchost.exe on disk. EDRs and tools like Moneta, PE-sieve, and Hollows Hunter scan for executable regions whose contents don't match their backing file, or where the legitimate image was unmapped and replaced with a private (non-image-backed) region. Memory-scanning is what undoes the disk/memory gap that hollowing relies on.
  • Anomalous memory characteristics. An RWX private region where a clean mapped image should be, or a thread whose start address points into private memory rather than a mapped module, are strong indicators.

So while hollowing defeats file-centric defences, it is memory- and behaviour-centric defences (image-vs-disk comparison, the API sequence) that reliably catch the classic form — which is exactly why attackers evolved it.

Modern Descendants

To beat the image-mismatch and API-sequence detections, researchers developed stealthier variants that achieve the same "run malicious code as a clean image" goal with fewer tells:

text
TECHNIQUE              KEY IDEA / WHAT IT EVADESProcess Doppelgänging  Abuse NTFS Transactions (TxF): create the malicious                         image inside a transaction, map a section from it,                         then ROLLBACK so nothing ever commits to disk. The                         section is image-backed → fewer "private RWX" tells,                         and scanners find no malicious file.Process Herpaderping    Write malicious image to disk, map it, THEN overwrite                         the file with benign content before execution. Disk                         scan sees the benign version; memory runs the malware.Process Ghosting        Create a "delete-pending" file, map the image from it,                         then delete it — the image-section persists with no                         backing file for scanners to inspect.Transacted Hollowing    Combine doppelgänging + hollowing for image-backed                         malicious sections inside a legitimate process.Module Stomping /       Overwrite the .text of an already-loaded LEGITIMATE DLL  "DLL hollowing"         in the host with shellcode — execution origin is a                         signed, mapped module (passes origin/image checks).

These variants target the specific signals the classic technique trips: doppelgänging and ghosting aim to make the malicious section image-backed and remove the on-disk artifact; herpaderping desynchronises the scanned-file from the executed-file; module stomping borrows a legitimately mapped module so the region is image-backed and signed. Each is an answer to a particular detection — the same cat-and-mouse seen with EDR hook bypasses.

Detection Guidance for Blue Teams

  • Watch the API sequence on suspended children. Correlate CreateProcess(CREATE_SUSPENDED) → NtUnmapViewOfSection/VirtualAllocEx/WriteProcessMemory → SetThreadContext → ResumeThread against a remote process. This sequence is rare in benign software and high-fidelity when seen together. Use kernel callbacks/ETW, not user-mode hooks (which the loader can bypass).
  • Compare in-memory images to their backing files. The structural truth of hollowing (and most variants) is a discrepancy between the executing image and the disk file. Periodic and event-driven memory scanning (Moneta, PE-sieve/Hollows Hunter, EDR memory inspection) surfaces it.
  • Flag anomalous executable memory — private RWX regions, threads whose start addresses point into non-image memory, unmapped/replaced main modules, and image-backed sections originating from transacted/deleted files.
  • Detect the variant-specific artifacts — TxF transactional file operations preceding section mapping (doppelgänging), files overwritten after mapping (herpaderping), delete-pending files backing executable sections (ghosting), and writes to a loaded module's .text (module stomping).
  • Baseline expected process behaviour. A svchost.exe with no service host arguments, an unusual parent, or making network connections it never should is suspicious regardless of how the code got there — behavioural anomaly detection backstops the memory analysis.

Advanced Variant Deep Dive: Process Doppelgänging

Process doppelgänging (Tal Liberman & Eugene Kogan, BlackHat EU 2017) is the most technically sophisticated variant of the hollowing family. It exploits the Windows NTFS Transaction Manager (TxF) — a feature designed for atomic file operations — to create an image section from a file that never commits to disk.

diagram — rendering…
sequenceDiagram
    participant M as Malware (loader)
    participant T as TxF (NTFS Transaction)
    participant K as Kernel / Process
    M->>T: NtCreateTransaction()
    M->>T: CreateFileTransacted(existing_binary_path) → hFileTx
    M->>T: WriteFile(hFileTx, malicious_PE_bytes) [INSIDE transaction]
    M->>K: NtCreateSection(hFileTx) → hSection [image section from uncommitted file]
    M->>T: NtRollbackTransaction() [malicious bytes NEVER land on disk]
    M->>K: NtCreateProcessEx(hSection) → create process from transacted section
    M->>K: NtCreateThreadEx + set entry point
    K-->>M: Process runs malicious image, section backed by the ROLLED-BACK file
    Note over K: On-disk file is CLEAN; no malicious bytes ever committed

The key insight is step 3 through 6: by writing the malicious bytes inside an uncommitted NTFS transaction and then creating an image section (NtCreateSection with SEC_IMAGE) from the transacted file handle before rolling back, the kernel's section object holds a reference to the malicious in-memory image. When the transaction is rolled back, the disk file reverts to clean bytes — but the section object persists. Creating a process from that section produces a process whose backing image on disk is clean (or is the original legitimate binary), but whose in-memory image is malicious.

What this defeats:

  • File-scanning AV at execution time — the backing file is clean by the time the process is running.
  • The classic "image mismatch" check — the process's section is backed by a file, it's just that the file's contents were in a transacted write that was rolled back.

What still trips it:

  • The TxF API calls themselves (NtCreateTransaction, CreateFileTransacted) are observable and extremely rare in benign software.
  • Some EDRs specifically monitor for image sections created from transacted file handles.
  • The process still has anomalous memory characteristics detectable on deeper inspection.

Process Ghosting

Process ghosting (Gabriel Landau, 2021) achieves a similar "imageless" effect without TxF, using delete-pending files:

c
// 1. Create a temp file in FILE_DELETE_ON_CLOSE mode// 2. Write the malicious PE to it// 3. Set the file to "delete pending" (NtSetInformationFile FileDispositionInfo)// 4. NtCreateSection(SEC_IMAGE) from the file handle before the delete completes// 5. Close the file handle → the file is deleted (no on-disk artifact)// 6. NtCreateProcessEx from the section → process runs from the "ghosted" image

The file is deleted before the process ever appears in the process list, so a real-time file scanner scanning "what file backs this process" finds nothing. The process's backing file handle is invalid — it backed a deleted file. Tools that attempt to read the process's backing file to scan it will fail.

Detection Guidance: Sysmon Queries and Memory Analysis

Concrete detection queries are more valuable than abstract guidance. The following Sysmon rules and KQL queries operationalise the detection principles.

Sysmon Configuration — Catching the API Sequence

xml
<!-- sysmon config excerpts targeting hollowing indicators --> <!-- CreateRemoteThread into a recently-created suspended process --><RuleGroup name="Process Hollowing - Remote Thread" groupRelation="and">  <CreateRemoteThread onmatch="include">    <!-- Thread created in a process that was created with CREATE_SUSPENDED -->    <SourceImage condition="is not">C:\Windows\System32\svchost.exe</SourceImage>  </CreateRemoteThread></RuleGroup> <!-- WriteProcessMemory by a process into another within seconds of creation --><RuleGroup name="Process Hollowing - Cross-Process Write" groupRelation="or">  <ProcessAccess onmatch="include">    <GrantedAccess condition="is">0x1fffff</GrantedAccess>  <!-- PROCESS_ALL_ACCESS -->    <GrantedAccess condition="is">0x001f0fff</GrantedAccess>    <GrantedAccess condition="contains">0x0020</GrantedAccess> <!-- WRITE -->  </ProcessAccess></RuleGroup>

KQL — Microsoft Defender for Endpoint / Sentinel

kusto
// Detect NtUnmapViewOfSection on a child process shortly after CREATE_SUSPENDEDlet SuspendedCreations = DeviceProcessEvents    | where ProcessCreationFlags has "CREATE_SUSPENDED"    | project DeviceName, ChildPid = ProcessId, ParentPid = InitiatingProcessId,              CreateTime = Timestamp, ChildName = FileName; DeviceEvents| where ActionType == "ProcessMemoryModified"| join kind=inner SuspendedCreations    on $left.ProcessId == $right.ChildPid| where Timestamp between (CreateTime .. CreateTime + 30s)| project Timestamp, DeviceName, TargetProcess = ChildName,          ModifyingProcess = InitiatingProcessFileName,          ActionType| order by Timestamp desc
kusto
// Flag processes whose in-memory image hash does not match their on-disk file hash// (requires EDR with memory-scanning capability)DeviceEvents| where ActionType == "ImageSectionMismatch"| project Timestamp, DeviceName, ProcessId, ProcessName = InitiatingProcessFileName,          DiskHash = AdditionalFields.OnDiskSHA256,          MemoryHash = AdditionalFields.InMemorySHA256| where DiskHash != MemoryHash| order by Timestamp desc

PE-sieve and Hollows Hunter — Manual Investigation

For incident response and threat hunting, PE-sieve (hasherezade) and Hollows Hunter provide the definitive host-based check:

bash
# Scan all running processes for hollowing artefactshollows_hunter.exe /dir C:\hunt_output /json # Scan a specific PIDpe-sieve.exe /pid 1234 /out C:\hunt_output /imp 3 # Key output fields to examine:# "has_replaced_exe"    -> image in memory doesn't match disk (classic hollowing)# "has_implanted_pe"    -> extra PE mapped into process that isn't a loaded module# "has_anomalous_module" -> loaded module with suspicious characteristics# "has_shellcode"        -> executable region that isn't backed by any mapped file
ToolWhat it catchesRun-time overhead
PE-sieve (per-PID)Image mismatch, shellcode regions, implanted PEsLow
Hollows Hunter (all PIDs)All of the above, system-wide sweepMedium
MonetaAnomalous private executable regions, module stompingLow
Get-InjectedThread (PowerShell)Threads starting in non-image memoryVery low

Conclusion and Takeaways

Process hollowing is the archetypal "borrow a legitimate identity" injection: spawn a trusted, signed binary suspended, unmap its real image, write your own image into the hole, repoint the entry, and resume — leaving the process name, path, lineage, and on-disk signature all reassuringly genuine while the executing code is entirely the attacker's. It was devastating against defences that judge a process by its file and name, because the malicious payload may never touch disk and the identity is impeccable. That same focus is its weakness: the technique cannot hide the gap between the in-memory image and the on-disk file, nor the distinctive choreography of suspended-process manipulation. Memory-scanning tools and kernel/ETW behavioural telemetry catch the classic form reliably by attacking exactly those two truths.

The arms race then produced the modern descendants — process doppelgänging, herpaderping, ghosting, transacted hollowing, and module stomping — each engineered to erase a specific tell: to make the malicious section image-backed, to desynchronise the scanned file from the executed one, or to run from a legitimately mapped, signed module. Doppelgänging abuses NTFS transaction rollback to create a section from never-committed bytes; ghosting leverages delete-pending semantics so the backing file is gone before the process surfaces. For red teamers, the lesson is that classic RunPE is now loud and that emulating current adversaries means understanding which detection each variant defeats. For defenders, the durable strategy is clear and independent of which variant is used: do not trust the disk file or the process name, instrument the kernel for the manipulation sequence rather than relying on patchable user-mode hooks, and — above all — continuously compare what is executing in memory against what is backed on disk, because every member of the hollowing family ultimately depends on that gap, and closing the visibility gap closes the technique.