GH-025 T1036.009 PHASE RED INSIDE

The Severed Thread

The launcher is gone. Its process is still running, and the process tree has nothing to say about where it came from. Two forks cut the thread; two birth times tie it back together. This file runs both.

TechniqueMasquerading: Break Process Trees (T1036.009)
Target OSUbuntu 24.04.5 LTS
Toolchainpython3
LevelIntermediate
Time25 min

OBJECTIVES

  1. Double-fork a payload so both parents exit and the survivor is reparented to PID 1
  2. Prove the orphan by comparing its birth time against PID 1's
  3. Contain the orphan with evidence first and stage the exec-time watch
  4. Take the IOC checklist and the one-sentence lesson
01

Intel Brief

CONTEXT

MITRE ATT&CK T1036.009: adversaries sever the parent-child link so the payload's lineage no longer points at its launcher. If the detection leans on the tree, the tree now vouches for nothing. This file cuts the thread, then ties it back together with the two things the cut cannot erase. Two actors: the attacker, who owns the launcher and every write in the red phase; and the defender, who owns every read, hunt, kill, and rule in the blue phases.

Why this technique. The process tree is the first map every triage reads: who launched what, in what order, from where. Endpoint tools that score on the parent-child relationship lean on the same map: a payload whose parent is a user shell reads as user activity, while the same payload under init reads as system furniture. The tree is an index of origins, and origins are what incident response is for. Sever the link and the payload keeps running while its origin stops existing; the map still draws, but the road it used to draw is gone.

Why not just run it and read the tree. The obvious alternative is no tradecraft at all: run the payload directly and let the tree tell the truth. It works: the red phase's baseline starts sleep 600 from the shell, and ps -o pid,ppid,cmd names the launcher in the PPID column while the launcher lives. Break it on the concrete input the technique names: fork twice, let both parents exit before anyone looks. The kernel reparents the surviving grandchild to PID 1, and the same ps query now reports PPID 1 with the launcher unfindable (no such process). The tree was never lying; its input, a live parent, is gone. That is the whole technique: not forging the map, but removing the territory it maps.

The mechanism, in one paragraph. fork() clones the process; the original (the parent) then exits, which orphans the child. Do it twice: the first parent exits, orphaning the child once; the middle child exits, orphaning the grandchild twice. The kernel must put orphans somewhere, so it reparents them to the nearest subreaper, which on a normal system is init, PID 1. The grandchild then calls setsid() to start a new session, detaching from any terminal. What remains is a running process whose PPID is 1 and whose true launcher has exited: the lineage is severed. This is also, unremarkably, how every well-behaved Unix daemon is born; the technique is the abuse of a system feature, not a bug.

The concrete case, before the abstraction. The lab launcher prints its pid (launcher pid: ...) and exits. Its grandchild keeps running: ps -o pid,ppid,cmd reports PPID 1 for it. kill -0 on the launcher pid answers no such process. The forest view draws the payload as a direct child of PID 1. The only record of the launch is the canary file the grandchild wrote itself: GHOSTLIGHT-CANARY-025 launched-pid=.... Same machine, before and after: a child with a parent, then an orphan with a story nobody can check.

Terms, earned. PPID is the parent process ID: the field the tree is drawn from. An orphan is a process whose parent has exited; reparenting is the kernel assigning the orphan to PID 1. A daemon is a background process detached from any terminal, conventionally born by exactly this double fork plus setsid(). init is PID 1, the ancestor every orphan is handed to. The process tree is the PPID linkage drawn as a hierarchy; breaking it is T1036.009.

Scope. T1036 covers masquerading broadly: names, paths, arguments, and lineage. This file works the break-process-trees case end to end: the double fork, the severed lineage, the birth-time hunt, the evidence-first containment, and the staged exec-time watch. The canary is a benign token: it marks the lab payload and nothing else. The lab runs in a disposable PID and mount namespace with a private /tmp; teardown removes the lab directory, and the namespace's death reaps every stray. Nothing persists outside the lab.

02

Target Environment

LOADOUT

Ubuntu 24.04.5 LTS, x86-64, python3 (3.12.3), root inside a disposable PID and mount namespace used only for this lab. The attack needs no privilege beyond what the launcher already has: any process can fork and exit. The detection needs only read access to /proc.

1

Build the isolated lab

The recording runs inside its own PID and mount namespace with a private /tmp, so every take begins identical. rm -rf /tmp/ghlab starts clean; mkdir -p stages the work directory. The heredoc writes threadcut.py, the lab launcher, whose full source is shown and glossed in the next step. python3 -c "import ast; ..." parses the file to prove it is valid Python before anything runs it, ls -l shows the staged artifact, and sleep 50 ages the namespace: PID 1 must predate the payload for the birth-time comparison to mean anything. On a real host init is born at boot; the lab compresses that into fifty seconds, stated here, not hidden.

bash
$ rm -rf /tmp/ghlab; mkdir -p /tmp/ghlab
cat > /tmp/ghlab/threadcut.py <<'PYEOF'
#!/usr/bin/env python3
"""threadcut.py - GH-025 lab launcher (attacker's side).

Double-fork daemonization: the launcher forks twice and both parents exit,
so the surviving grandchild is reparented to PID 1 and the process tree no
longer points at the launcher. Benign: the payload only sleeps, and writes
a GHOSTLIGHT-CANARY-025 launch record for the blue phase to find.
"""
import os
import sys
import time

CANARY = 'GHOSTLIGHT-CANARY-025'
WORK = '/tmp/ghlab'

def main():
    pid = os.getpid()
    print('launcher pid: %d' % pid, flush=True)
    with open(WORK + '/launcher.pid', 'w') as f:
        f.write('%d\n' % pid)
    if os.fork() != 0:
        sys.exit(0)          # first parent exits: child is orphaned once
    if os.fork() != 0:
        os._exit(0)          # middle child exits: grandchild orphaned twice
    os.setsid()              # new session: fully detached from any terminal
    gp = os.getpid()
    with open(WORK + '/canary.txt', 'a') as f:
        f.write('%s launched-pid=%d\n' % (CANARY, gp))
    with open(WORK + '/payload.pid', 'w') as f:
        f.write('%d\n' % gp)
    time.sleep(600)          # benign: holds the slot for the blue phase

if __name__ == '__main__':
    main()
PYEOF
python3 -c "import ast; ast.parse(open('/tmp/ghlab/threadcut.py').read()); print('syntax OK')"
ls -l /tmp/ghlab
sleep 50  # age the namespace: PID 1 must predate the payload, as init predates everything on a real host
syntax OK
total 4
-rw-rw---- 1 root root 1211 Oct  5 10:23 threadcut.py
2

The payload: threadcut.py

One file, two roles: the launcher half runs first and exits; the grandchild half is the payload that survives. Line by line: the CANARY and WORK constants name the benign mark and the lab directory. main() prints the launcher pid and writes it to launcher.pid (the pidfile the red phase uses to prove the launcher is gone). The first os.fork(): the parent branch calls sys.exit(0), orphaning the child once. The second os.fork(): the middle branch calls os._exit(0), orphaning the grandchild twice (_exit skips interpreter cleanup, which is the correct way to end a forked child). os.setsid() starts a new session, detaching from any terminal. The grandchild writes the canary launch record (GHOSTLIGHT-CANARY-025 launched-pid=...) and its own pid to payload.pid, then time.sleep(600): the benign hold, ten minutes of doing nothing, so the blue phase has a live orphan to inspect. On a real host the sleep would be the implant; here it is the canary-marked placeholder.

python: threadcut.py
#!/usr/bin/env python3
"""threadcut.py - GH-025 lab launcher (attacker's side).

Double-fork daemonization: the launcher forks twice and both parents exit,
so the surviving grandchild is reparented to PID 1 and the process tree no
longer points at the launcher. Benign: the payload only sleeps, and writes
a GHOSTLIGHT-CANARY-025 launch record for the blue phase to find.
"""
import os
import sys
import time

CANARY = 'GHOSTLIGHT-CANARY-025'
WORK = '/tmp/ghlab'

def main():
    pid = os.getpid()
    print('launcher pid: %d' % pid, flush=True)
    with open(WORK + '/launcher.pid', 'w') as f:
        f.write('%d\n' % pid)
    if os.fork() != 0:
        sys.exit(0)          # first parent exits: child is orphaned once
    if os.fork() != 0:
        os._exit(0)          # middle child exits: grandchild orphaned twice
    os.setsid()              # new session: fully detached from any terminal
    gp = os.getpid()
    with open(WORK + '/canary.txt', 'a') as f:
        f.write('%s launched-pid=%d\n' % (CANARY, gp))
    with open(WORK + '/payload.pid', 'w') as f:
        f.write('%d\n' % gp)
    time.sleep(600)          # benign: holds the slot for the blue phase

if __name__ == '__main__':
    main()
03

Phase Red: cut the thread

ATTACK

The attacker runs the launcher, watches both parents exit, and proves the survivor's lineage now ends at PID 1.

Real screen recording 189.3s
What you are watching: The lab is staged, the honest baseline shows the tree telling the truth, and the double fork severs the payload's lineage: PPID 1, launcher gone. Every command below is copy-pasteable.
1

Stage the lab

Private work directory, the launcher written by heredoc, a syntax parse proving the file is valid Python before it runs, and the staged artifact listed. Nothing has executed yet.

bash
$ rm -rf /tmp/ghlab; mkdir -p /tmp/ghlab
cat > /tmp/ghlab/threadcut.py <<'PYEOF'
#!/usr/bin/env python3
"""threadcut.py - GH-025 lab launcher (attacker's side).

Double-fork daemonization: the launcher forks twice and both parents exit,
so the surviving grandchild is reparented to PID 1 and the process tree no
longer points at the launcher. Benign: the payload only sleeps, and writes
a GHOSTLIGHT-CANARY-025 launch record for the blue phase to find.
"""
import os
import sys
import time

CANARY = 'GHOSTLIGHT-CANARY-025'
WORK = '/tmp/ghlab'

def main():
    pid = os.getpid()
    print('launcher pid: %d' % pid, flush=True)
    with open(WORK + '/launcher.pid', 'w') as f:
        f.write('%d\n' % pid)
    if os.fork() != 0:
        sys.exit(0)          # first parent exits: child is orphaned once
    if os.fork() != 0:
        os._exit(0)          # middle child exits: grandchild orphaned twice
    os.setsid()              # new session: fully detached from any terminal
    gp = os.getpid()
    with open(WORK + '/canary.txt', 'a') as f:
        f.write('%s launched-pid=%d\n' % (CANARY, gp))
    with open(WORK + '/payload.pid', 'w') as f:
        f.write('%d\n' % gp)
    time.sleep(600)          # benign: holds the slot for the blue phase

if __name__ == '__main__':
    main()
PYEOF
python3 -c "import ast; ast.parse(open('/tmp/ghlab/threadcut.py').read()); print('syntax OK')"
ls -l /tmp/ghlab
sleep 50  # age the namespace: PID 1 must predate the payload, as init predates everything on a real host
syntax OK
total 4
-rw-rw---- 1 root root 1211 Oct  5 10:23 threadcut.py
2

The honest baseline

No tradecraft: sleep 600 & starts an ordinary child, and ps -o pid,ppid,cmd names the launcher in the PPID column while the launcher lives. kill $BASE cleans it up. The tree tells the truth here, because the parent is still around to be named. Remember this row: it is what the next step deletes.

bash
$ sleep 600 &
BASE=$!
echo "shell pid: $$"
ps -o pid,ppid,etime,cmd -p $BASE
kill $BASE
echo 'baseline: the tree names the launcher while it lives'
[1] 10
shell pid: 1
    PID    PPID     ELAPSED CMD
     10       1       00:00 sleep 600
baseline: the tree names the launcher while it lives
3

Cut the thread

python3 /tmp/ghlab/threadcut.py prints the launcher pid and exits. One second later the pidfiles are read: the launcher pid and the payload pid. kill -0 $L answers no such process: the launcher is gone, both parents exited. ps -o pid,ppid,etime,lstart,cmd -p $P shows the survivor with PPID 1: the kernel reparented the twice-orphaned grandchild to PID 1, exactly the adoption the technique names.

bash
$ python3 /tmp/ghlab/threadcut.py
sleep 1
L=$(cat /tmp/ghlab/launcher.pid); P=$(cat /tmp/ghlab/payload.pid)
echo "launcher: $L  payload: $P"
kill -0 $L 2>/dev/null && echo "launcher $L alive" || echo "launcher $L: no such process (exited)"
ps -o pid,ppid,etime,lstart,cmd -p $P
launcher pid: 12
launcher: 12  payload: 14
launcher 12: no such process (exited)
    PID    PPID     ELAPSED                  STARTED CMD
     14       1       00:01 Mon Oct  5 10:24:15 2026 python3 /tmp/ghlab/threadcu
4

The lineage is severed

ps -ef --forest draws the payload as a direct child of PID 1; the launcher appears nowhere in the tree. The canary file is the only launch record left: GHOSTLIGHT-CANARY-025 launched-pid=..., written by the grandchild itself. An analyst starting from this tree can reach the payload, but cannot reach back to what launched it.

bash
$ P=$(cat /tmp/ghlab/payload.pid)
ps -ef --forest
echo '--- the tree ends at PID 1; the launcher is gone ---'
cat /tmp/ghlab/canary.txt
echo 'stealth confirmed: payload orphaned under PPID 1, launcher exited'
UID          PID    PPID  C STIME TTY          TIME CMD
root           1       0  0 10:23 ?        00:00:00 bash --norc --noprofile
root          14       1  0 10:24 ?        00:00:00 python3 /tmp/ghlab/threadcut
root          20       1  0 10:24 ?        00:00:00 ps -ef --forest
--- the tree ends at PID 1; the launcher is gone ---
GHOSTLIGHT-CANARY-025 launched-pid=14
stealth confirmed: payload orphaned under PPID 1, launcher exited
Stealth confirmed

Two forks and two exits moved a running process from "child of its launcher" to "child of PID 1", and the launcher is unfindable: kill -0 answers no such process. The process tree still draws, but the road the payload arrived on is gone. The break cost nothing beyond the normal daemonization calls every Unix service uses.

04

Phase Blue: read the birth times

DEFENSE

The defender stops trusting the tree and starts reading what the cut cannot erase: when each process was born, and what the kernel recorded about it at birth.

Here is the trap: opening the forest view, seeing the payload under PID 1, and filing it as system furniture. The tree is not lying; it is answering a narrower question than the one you asked. It says who the parent is now. It says nothing about who the parent was. The checks that work never ask the tree for history; they read the records the cut cannot rewrite.

Real screen recording 149.8s
What you are watching: The defender finds the orphan by birth time, cross-checks the kernel's per-process records, contains it with evidence first, and stages the exec-time watch. Every command below is copy-pasteable.
1

DETECTION: the naive view, and the anomaly in it

The defender starts where the analyst starts: ps -ef --forest draws the payload as a child of PID 1, origin gone. The tree is the claim; now check it against the record. ps -p 1 -o lstart shows when PID 1 was born; ps -p $P -o lstart shows when the payload was born: the fifty-second aging sleep sits between them, so PID 1 is near a minute old and the payload is seconds old. A child of PID 1 born long after PID 1 is the LEAD: init's real children are born at boot, and this one was not. D3FEND names this discipline D3-PLA: Process Lineage Analysis: examining a process's ancestry and the metadata of each node, including execution order and duration relative to its siblings.

bash
$ P=$(cat /tmp/ghlab/payload.pid); echo "suspect pid: $P"
ps -ef --forest
echo '--- the tree says PPID 1; the origin is gone ---'
ps -p 1 -o pid,lstart,etime
ps -p $P -o pid,lstart,etime
echo '--- LEAD: a child of PID 1 born long after PID 1 ---'
suspect pid: 14
UID          PID    PPID  C STIME TTY          TIME CMD
root           1       0  0 10:23 ?        00:00:00 bash --norc --noprofile
root          14       1  0 10:24 ?        00:00:00 python3 /tmp/ghlab/threadcut
root          23       1  0 10:24 ?        00:00:00 ps -ef --forest
--- the tree says PPID 1; the origin is gone ---
    PID                  STARTED     ELAPSED
      1 Mon Oct  5 10:23:25 2026       00:51
    PID                  STARTED     ELAPSED
     14 Mon Oct  5 10:24:15 2026       00:01
--- LEAD: a child of PID 1 born long after PID 1 ---
2

DETECTION: the independent observation path

Reparenting rewrites the PPID field; it cannot rewrite the kernel's per-process records. /proc/$P/stat field 4 confirms PPID 1, and field 22 gives the birth time in clock ticks since boot: the payload's ticks sit 5050 ticks after init's, so it was not born of init. readlink /proc/$P/exe names the real interpreter (/usr/bin/python3.12); readlink /proc/$P/cwd names where it was launched from; the canary file carries the launch record the tree deleted. Three independent reads, one finding: the orphan's own files still point at its origin.

bash
$ P=$(cat /tmp/ghlab/payload.pid)
awk '{print "ppid="$4" starttime_ticks="$22}' /proc/$P/stat
echo "init starttime_ticks: $(awk '{print $22}' /proc/1/stat)"
readlink /proc/$P/exe
readlink /proc/$P/cwd
cat /tmp/ghlab/canary.txt
ppid=1 starttime_ticks=557771
init starttime_ticks: 552721
/usr/bin/python3.12
/tmp
GHOSTLIGHT-CANARY-025 launched-pid=14
3

MITIGATION: evidence first, then scope

mkdir -p evidence; the full ps row, the sha256sum of the executed interpreter, and the process listing are captured BEFORE anything is killed, because /proc dies with the process and a killed orphan takes its records with it. Then the sibling sweep: ps -o pid,ppid,lstart,etime,cmd --ppid 1 lists every child of PID 1 with birth times. Two rows: the payload, and the ps query itself (it is a child of the shell too, born this second, which is exactly what an innocent late-born child looks like). ls -la /tmp/ghlab inventories the launcher's artifacts: the launcher is gone, its files are not, and they are now evidence.

bash
$ P=$(cat /tmp/ghlab/payload.pid)
mkdir -p evidence
ps -o pid,ppid,lstart,etime,args -p $P | tee evidence/process.txt
sha256sum /proc/$P/exe | tee evidence/hash.txt
echo '--- siblings: every child of PID 1, with birth times ---'
ps -o pid,ppid,lstart,etime,cmd --ppid 1
ls -la /tmp/ghlab
    PID    PPID                  STARTED     ELAPSED COMMAND
     14       1 Mon Oct  5 10:24:15 2026       00:01 python3 /tmp/ghlab/threadcut.py
e50d468e8b0adfb05733f5b87b3cff34829c4a8c1aea50c865aa8bdfe4bb150f  /proc/14/exe
--- siblings: every child of PID 1, with birth times ---
    PID    PPID                  STARTED     ELAPSED CMD
     14       1 Mon Oct  5 10:24:15 2026       00:01 python3 /tmp/ghlab/threadcu
     38       1 Mon Oct  5 10:24:16 2026       00:00 ps -o pid,ppid,lstart,etime
total 16
drwxrwx--- 2 root root  120 Oct  5 10:24 .
drwxrwxrwt 3 root root   60 Oct  5 10:23 ..
-rw-rw---- 1 root root   38 Oct  5 10:24 canary.txt
-rw-rw---- 1 root root    3 Oct  5 10:24 launcher.pid
-rw-rw---- 1 root root    3 Oct  5 10:24 payload.pid
-rw-rw---- 1 root root 1211 Oct  5 10:23 threadcut.py
4

MITIGATION: contain by PID, verify, resweep

kill $P: by PID, not by name. The payload runs as python3, a shared interpreter name; a name-based kill is the wrong tool and would take innocent interpreters with it. kill -0 $P verifies containment: no such process. The sibling sweep runs again: no late-born children of PID 1 remain. The delivery vector stays open as the incident's question: the launcher exited before the investigation began, so how it arrived is answered from the artifacts, not from the tree.

bash
$ P=$(cat /tmp/ghlab/payload.pid)
kill $P
sleep 1
kill -0 $P 2>/dev/null && echo "payload $P still alive" || echo "payload $P: contained (no such process)"
ps -o pid,ppid,lstart,etime,cmd --ppid 1
echo 'sibling sweep: no late-born children of PID 1 remain'
payload 14: contained (no such process)
    PID    PPID                  STARTED     ELAPSED CMD
     42       1 Mon Oct  5 10:24:17 2026       00:00 ps -o pid,ppid,lstart,etime
sibling sweep: no late-born children of PID 1 remain
5

PREVENTION: stage the exec-time watch

The heredoc stages ghostlight-025.rules: an execve watch that records every program execution with its parent at creation time. Reparenting happens after exec, so the audit record keeps the original parentage the tree later loses. command -v auditctl confirms the tooling is installed; pgrep confirms auditd not running in this lab: rule staged, not loaded, stated with its dependency, not demonstrated. Where the daemon runs, the double fork still happens, but the exec record names the launcher that the tree forgot.

bash
$ mkdir -p /tmp/ghlab/staged
cat > /tmp/ghlab/staged/ghostlight-025.rules <<'EOF'
# GH-025: record every execve with its parent at creation time (needs auditd running)
-a always,exit -F arch=b64 -S execve -k gh025-exec
-a always,exit -F arch=b32 -S execve -k gh025-exec
EOF
cat /tmp/ghlab/staged/ghostlight-025.rules
command -v auditctl
pgrep -a auditd || echo 'auditd not running in this lab: rule staged, not loaded'
# GH-025: record every execve with its parent at creation time (needs auditd running)
-a always,exit -F arch=b64 -S execve -k gh025-exec
-a always,exit -F arch=b32 -S execve -k gh025-exec
/usr/sbin/auditctl
auditd not running in this lab: rule staged, not loaded
6

Verdict and teardown

The summary, in the defender's own words: the tree is the claim, the birth times are the record. Teardown: rm -rf /tmp/ghlab evidence deletes the lab and the evidence copies; ls /tmp shows the empty private tmp; the forest view shows the namespace clean. The namespace's death reaps anything left.

bash
$ echo 'detection verified: the tree is the claim, the birth times are the record'
rm -rf /tmp/ghlab evidence
ls /tmp
ps -e -o pid,ppid,cmd --forest | head -8
detection verified: the tree is the claim, the birth times are the record
    PID    PPID CMD
      1       0 bash --norc --noprofile
     49       1 ps -e -o pid,ppid,cmd --forest
     50       1 head -8
Detection verified

The forest view was clean-looking; the birth-time comparison named the late-born orphan; the kernel's per-process records (exe, cwd, stat) and the canary launch record confirmed the origin the tree had deleted; the orphan's records and hashes were captured before the kill; the kill went by PID; the resweep is clean; the exec-time watch is staged with its dependency stated. The tree never got a second hearing.

05

Countermeasures

DEFENSE

Three moves, in order: contain with evidence first, sweep for late-born orphans on a schedule, watch executions at creation time. Each is one way, not the way.

1

Mitigate: capture, kill by PID, resweep

Proven first against the live orphan: the full ps row and the interpreter's hash are captured into evidence/ BEFORE the kill, because /proc dies with the process. The kill goes by PID: the payload shares its interpreter name with innocent processes, so name-based kills are the wrong tool. The sibling sweep runs before and after: every child of PID 1 with its birth time, clean afterward. The launcher already exited, so there is no parent to question; the delivery vector is reconstructed from the artifacts (the script, the pidfiles, the canary), not from the tree.

bash
$ P=$(cat /tmp/ghlab/payload.pid)
mkdir -p evidence
ps -o pid,ppid,lstart,etime,args -p $P | tee evidence/process.txt
sha256sum /proc/$P/exe | tee evidence/hash.txt
echo '--- siblings: every child of PID 1, with birth times ---'
ps -o pid,ppid,lstart,etime,cmd --ppid 1
ls -la /tmp/ghlab
    PID    PPID                  STARTED     ELAPSED COMMAND
     14       1 Mon Oct  5 10:24:15 2026       00:01 python3 /tmp/ghlab/threadcut.py
e50d468e8b0adfb05733f5b87b3cff34829c4a8c1aea50c865aa8bdfe4bb150f  /proc/14/exe
--- siblings: every child of PID 1, with birth times ---
    PID    PPID                  STARTED     ELAPSED CMD
     14       1 Mon Oct  5 10:24:15 2026       00:01 python3 /tmp/ghlab/threadcu
     38       1 Mon Oct  5 10:24:16 2026       00:00 ps -o pid,ppid,lstart,etime
total 16
drwxrwx--- 2 root root  120 Oct  5 10:24 .
drwxrwxrwt 3 root root   60 Oct  5 10:23 ..
-rw-rw---- 1 root root   38 Oct  5 10:24 canary.txt
-rw-rw---- 1 root root    3 Oct  5 10:24 launcher.pid
-rw-rw---- 1 root root    3 Oct  5 10:24 payload.pid
-rw-rw---- 1 root root 1211 Oct  5 10:23 threadcut.py

Honest limit. Evidence-first is load-bearing here and fragile in practice: on a real host the orphan may exit on its own before the responder arrives, and then the /proc records are gone with it; the disk artifacts and any exec-time telemetry are all that remain. Killing the orphan ends this instance but answers nothing about persistence: a launcher that re-runs on a timer will simply orphan a successor, which is why the mitigation ships with the sibling sweep, not instead of it.

2

Monitor: sweep for late-born orphans on a schedule

The scheduled form of the phase-blue reads: every child of PID 1 (ps -o pid,ppid,lstart,etime,cmd --ppid 1) whose birth time is long after PID 1's, cross-checked against exe and cwd before anyone acts. The tell is concrete: good is born at boot with the service tree; bad is born minutes ago under PID 1 with a temp-directory cwd. Production versions add alerting and a known-good inventory of PID-1 children, not new ideas. This is D3-PLA as a cron job: lineage plus per-node metadata, on a timer.

bash
$ P=$(cat /tmp/ghlab/payload.pid); echo "suspect pid: $P"
ps -ef --forest
echo '--- the tree says PPID 1; the origin is gone ---'
ps -p 1 -o pid,lstart,etime
ps -p $P -o pid,lstart,etime
echo '--- LEAD: a child of PID 1 born long after PID 1 ---'
suspect pid: 14
UID          PID    PPID  C STIME TTY          TIME CMD
root           1       0  0 10:23 ?        00:00:00 bash --norc --noprofile
root          14       1  0 10:24 ?        00:00:00 python3 /tmp/ghlab/threadcut
root          23       1  0 10:24 ?        00:00:00 ps -ef --forest
--- the tree says PPID 1; the origin is gone ---
    PID                  STARTED     ELAPSED
      1 Mon Oct  5 10:23:25 2026       00:51
    PID                  STARTED     ELAPSED
     14 Mon Oct  5 10:24:15 2026       00:01
--- LEAD: a child of PID 1 born long after PID 1 ---

Honest limit. Late-born children of PID 1 are a lead, not a verdict: administrators start services by hand, container entrypoints adopt children, and job schedulers reparent routinely. Every hit needs the exe/cwd cross-check before action, or the sweep pages the on-call for normal operations. And the poll interval sets the floor: an orphan that lives and dies between sweeps leaves no ps trace behind, only the exec-time telemetry, if it was running.

3

Prevent: watch executions at creation time

The staged rule (ghostlight-025.rules) is the durable control: an execve audit watch records every program execution with its parent at creation time, before any fork can orphan it. Reparenting happens after exec, so the record keeps the original parentage the tree later loses. Pair it with executable allowlisting on what may run at all (the D3FEND family names the heavier forms); the watch tells you who launched what, the allowlist narrows what can be launched.

bash
$ mkdir -p /tmp/ghlab/staged
cat > /tmp/ghlab/staged/ghostlight-025.rules <<'EOF'
# GH-025: record every execve with its parent at creation time (needs auditd running)
-a always,exit -F arch=b64 -S execve -k gh025-exec
-a always,exit -F arch=b32 -S execve -k gh025-exec
EOF
cat /tmp/ghlab/staged/ghostlight-025.rules
command -v auditctl
pgrep -a auditd || echo 'auditd not running in this lab: rule staged, not loaded'
# GH-025: record every execve with its parent at creation time (needs auditd running)
-a always,exit -F arch=b64 -S execve -k gh025-exec
-a always,exit -F arch=b32 -S execve -k gh025-exec
/usr/sbin/auditctl
auditd not running in this lab: rule staged, not loaded

Honest limit. The rule needs auditd running with rules loaded; this lab has the binary but no daemon, and many containers lack the subsystem entirely. The watch detects the launch; it does not prevent it. And the deeper limit is the technique itself: MITRE's own mitigation note says this type of attack "cannot be easily mitigated with preventive controls since it is based on the abuse of system features." fork() cannot be forbidden, because daemonization is standard Unix practice: every well-behaved service double-forks. noexec on writable directories does not stop the break either: the break is fork plus exit, not execution from a path. This control makes the severing observable at creation time; it does not remove the severing. That is why detection outlives prevention here.

Countermeasures verified

The orphan's records and hashes were captured before the kill; the kill went by PID and the resweep is clean; the scheduled sweep names its tell, its false-positive load, and its interval floor; the exec-time watch is staged with its dependency stated. Every control names its bypass: /proc dies with the process, late-born orphans include innocent services, and no control forbids fork.

06

Debrief

TAKEAWAY

The process tree is a claim about parentage that dies with the parent. Birth times and the kernel's per-process records survive it. When the tree says PID 1, check when the child was born.

IOC checklist: signs this technique was used

  • A process with PPID 1 whose start time is long after PID 1's (the late-born orphan; the sweep's LEAD)
  • Launcher artifacts with no launcher: pidfiles, scripts, or canary-style markers in temp directories whose owning process is gone
  • An interpreter running a script from a temp or user-writable directory with PPID 1 and a recent birth time
  • execve audit records (where the watch runs) showing a process whose parent exited within seconds of the exec
  • A cwd or environ pointing at an operator's working directory on a process whose tree position claims init ancestry

Reproducibility checklist

  • Verified on Ubuntu 24.04.5 LTS, python3 3.12.3, x86-64, on 2026-10-05
  • Both recordings are real executions on that platform, not simulations
  • The attack runs as root inside a PID and mount namespace (unshare -pfm --mount-proc) with a private /tmp; forking needs no privilege beyond the launcher's own
  • The detection needs only read access to /proc
  • Cleanup: rm -rf /tmp/ghlab; the namespace's death reaps every stray; verify with ps -e --forest

Sources

MITRE ATT&CK T1036.009: Masquerading: Break Process Trees
MITRE ATT&CK T1036: Masquerading (the parent technique)
fork(2) (the clone; the parent's exit orphans the child)
daemon(3) (the double fork plus setsid, as standard practice)
setsid(1) (the session detachment)
proc(5) (/proc/<pid>/stat fields: PPID, starttime)
ps(1) (the ppid, lstart, and etime output columns)
auditctl(8) and audit.rules(7) (the staged execve watch)
D3FEND D3-PLA: Process Lineage Analysis

Next file

GH-026 The Borrowed Crown

The next file sets the setuid bit and watches a process borrow root's privileges.