GH-027 T1036.011 PHASE RED INSIDE

The Palimpsest

The process list says a kernel thread named [kworker/u16:2] is running on this machine. No such thread was ever born. The process launched with a truthful command line, then scraped its own argv clean and wrote a new story over it. This file runs the rewrite, then reads the two things the rewrite cannot change.

TechniqueOverwrite Process Arguments (T1036.011)
Target OSUbuntu 24.04.5 LTS
Toolchaingcc 13
LevelBeginner
Time20 min

OBJECTIVES

  1. Rewrite a running process's own argv memory and watch ps report a kernel thread
  2. Hunt the bracket decoy and convict it on the comm/cmdline/exe mismatch
  3. Contain with evidence first and pin the exec-time record against the next rewrite
  4. Take the IOC checklist and the one-sentence lesson
01

Intel Brief

CONTEXT

MITRE ATT&CK T1036.011: adversaries overwrite a running process's own argument memory, so the process list reports a story the launch never told. This file performs the rewrite after launch, then checks the two things the rewrite cannot change. Two actors: the attacker, who owns the lab binary and the rewrite; and the defender, who owns every hunt, read, kill, and rule in the blue phases.

Why this technique. The command line is the process's testimony about itself, and it is the most-read text on the system: ps, htop, top, every EDR sensor, every SIEM process feed. But the testimony is not a record. It is live memory. Every tool that prints a command line reads /proc/<pid>/cmdline, which is a window into the process's own stack, and the process owns that memory the way it owns its variables. Rewriting it costs one memcpy, fires no system call, changes no pid, no start time, no parent, no executable. The lie is total and the process never stops being itself.

Why not the obvious alternative. The obvious check is the birth certificate: capture argv at exec time, in an auditd execve record, an EDR process-creation event, or the operator's own launch log, and trust it. Break it on this file's concrete input: the pinned exec record reads ./palimpsest PADDINGPADDINGPADDING GHOSTLIGHT-CANARY-027, truthful to the byte. Three seconds later the same pid's cmdline reads [kworker/u16:2]. The record is accurate and useless: it describes a moment that has passed, and nothing re-checks it. Any defense that verifies the testimony once, at birth, loses to a rewrite that happens after. (Plain difference from GH-021 "The False Testimony": that file forged the argument vector at launch with execve, so the birth record itself was the lie; this file launches truthfully and rewrites the memory afterwards, with no exec at all, so the birth record is true and the live testimony is the lie. Different moment, different author of the bytes, same deceived reader.)

The mechanism, in one paragraph. At exec, the kernel copies the launch argv onto the new process's stack and remembers the bounds of that memory. /proc/<pid>/cmdline prints exactly that range, so a memcpy into argv[0] changes what every reader sees, with no system call and no exec. The writable length is bounded by the original argv's total bytes: writing past the end would corrupt the environment block sitting above it on the stack, so the demo measures the region first, writes the decoy, and NUL-pads the rest so no stale argument bytes leak through. Two things the rewrite cannot touch: comm, the kernel's separate 16-byte name field (ps -o comm still says palimpsest), and /proc/<pid>/exe, the kernel's symlink to the executed file.

The concrete case, before the abstraction. In /tmp/gh027: ./palimpsest PADDINGPADDINGPADDING GHOSTLIGHT-CANARY-027 & starts the lab binary. ps -o pid,comm,args prints palimpsest ./palimpsest PADDINGPADDINGPADDING GHOSTLIGHT-CANARY-027. Three seconds later, the same pid: palimpsest [kworker/u16:2]. No new process, no exec, no privilege. readlink /proc/<pid>/exe still says /tmp/gh027/palimpsest. Same parchment, new text: a palimpsest is a manuscript scraped clean and written over, and that is exactly what happened to this process's argv.

Terms, earned. argv is the argument vector: the process's words about itself, living in its own writable stack memory. cmdline is /proc's view of argv, the testimony in raw bytes. comm is the kernel's separate 16-byte process name, set at exec, untouched by the rewrite. The exe link is /proc/<pid>/exe, the kernel's symlink to the file it actually executed. Overwrite process arguments is T1036.011: rewriting argv after launch so the testimony tells a new story.

Scope. T1036.011 covers post-launch argument overwrites wherever a process can write its own argv memory. This file works the Linux case end to end: the in-place rewrite, the kernel-thread decoy, the bracket-plus-live-cmdline hunt, the evidence-first containment, and the exec-record diff that pins the next rewrite. The canary is a benign token: it marks the lab payload and touches nothing else. The lab runs in a disposable PID and mount namespace with a private /tmp; teardown removes it and the namespace's death reaps every stray.

02

Target Environment

LOADOUT

Ubuntu 24.04.5 LTS with gcc 13, x86-64, in a disposable PID and mount namespace used only for this lab. The attack needs no privilege at all: a process may always write its own memory. Run it on a throwaway box anyway, because you are about to practice lying to your own tools.

1

Build the lab

The recording starts from an empty private /tmp inside its own mount namespace, so every take begins identical. rm -rf /tmp/gh027 starts clean; mkdir -p and cd set up the lab directory. The heredoc writes palimpsest.c (quoted 'EOF', so the shell passes the source through untouched); gcc -O2 builds it; ls -l shows the lab binary. The attacker needs no privilege: rewriting argv is writing your own stack, not a capability.

bash
$ rm -rf /tmp/gh027; mkdir -p /tmp/gh027; cd /tmp/gh027
cat > palimpsest.c <<'EOF'
/* palimpsest.c - GH-027 lab: post-launch argv overwrite (T1036.011).
 * Prints the benign canary and its launch-time argv[0], waits, then
 * overwrites its own argument memory in place with a kernel-thread
 * decoy. No exec, no privilege, no persistence: a benign demo. */
#include <stdio.h>
#include <string.h>
#include <unistd.h>

int main(int argc, char **argv) {
    printf("GHOSTLIGHT-CANARY-027: benign lab payload\n");
    printf("argv[0] at launch: %s\n", argv[0]);
    fflush(stdout);
    sleep(3);
    size_t total = 0;
    for (int i = 0; i < argc; i++)
        total += strlen(argv[i]) + 1;
    const char *decoy = "[kworker/u16:2]";
    size_t n = strlen(decoy);
    if (n + 1 > total) {
        printf("argv region too small for decoy\n");
        return 1;
    }
    memcpy(argv[0], decoy, n + 1);
    memset(argv[0] + n + 1, 0, total - (n + 1));
    printf("argv[0] rewritten in place: %s\n", argv[0]);
    fflush(stdout);
    for (;;) pause();
    return 0;
}
EOF
gcc -O2 -o palimpsest palimpsest.c && ls -l palimpsest
-rwxrwx--- 1 root root 16272 Oct  5 11:26 palimpsest
2

The payload: palimpsest.c

Twenty-nine lines. It prints the benign canary and its launch-time argv[0], then sleep(3) gives the operator time to pin the launch record. total measures the writable argv region (every argument's length plus its NUL); the [kworker/u16:2] decoy needs 15 bytes, and the size guard refuses the rewrite if the region is smaller. memcpy writes the decoy over argv[0], and memset NUL-pads the rest so no stale argument bytes leak through into the new testimony. The process announces the rewritten argv[0] itself, then pause()s forever so the process list can be inspected. The PADDINGPADDINGPADDING launch argument exists only to size the writable region comfortably: without it the region would still fit the decoy, but the padding makes the before/after contrast unmistakable.

c: palimpsest.c
/* palimpsest.c - GH-027 lab: post-launch argv overwrite (T1036.011).
 * Prints the benign canary and its launch-time argv[0], waits, then
 * overwrites its own argument memory in place with a kernel-thread
 * decoy. No exec, no privilege, no persistence: a benign demo. */
#include <stdio.h>
#include <string.h>
#include <unistd.h>

int main(int argc, char **argv) {
    printf("GHOSTLIGHT-CANARY-027: benign lab payload\n");
    printf("argv[0] at launch: %s\n", argv[0]);
    fflush(stdout);
    sleep(3);
    size_t total = 0;
    for (int i = 0; i < argc; i++)
        total += strlen(argv[i]) + 1;
    const char *decoy = "[kworker/u16:2]";
    size_t n = strlen(decoy);
    if (n + 1 > total) {
        printf("argv region too small for decoy\n");
        return 1;
    }
    memcpy(argv[0], decoy, n + 1);
    memset(argv[0] + n + 1, 0, total - (n + 1));
    printf("argv[0] rewritten in place: %s\n", argv[0]);
    fflush(stdout);
    for (;;) pause();
    return 0;
}
03

Phase Red: scrape the parchment

ATTACK

The attacker launches the payload with a truthful argv, lets the operator pin the launch record, and waits three seconds. The process then rewrites its own argument memory. No exec, no new pid, no privilege.

Real screen recording 152.0s
What you are watching: The lab binary launches with a truthful command line, then rewrites its own argv memory. ps reports a kernel thread that was never born. Every command below is copy-pasteable.
1

Launch clean, pin the launch record

./palimpsest PADDINGPADDINGPADDING GHOSTLIGHT-CANARY-027 & starts the lab binary in the background; [1] 13 is the shell's job notice and lab pid: 13 saves the pid. The canary line and argv[0] at launch: ./palimpsest are the payload announcing itself: a benign marker, nothing more. tr '\0' '\n' < /proc/13/cmdline > exec-record.txt pins the launch-time argv to a file before the rewrite happens (the operator's harness record; the production form is the immutable auditd execve log). ps -o pid,comm,args shows the truthful launch: comm palimpsest, args the real command line.

bash
$ ./palimpsest PADDINGPADDINGPADDING GHOSTLIGHT-CANARY-027 &
P=$!
echo "lab pid: $P"
tr '\0' '\n' < /proc/$P/cmdline > exec-record.txt
echo '--- exec-time argv, pinned before the rewrite:'
cat exec-record.txt
ps -o pid,comm,args -p $P
[1] 13
lab pid: 13
GHOSTLIGHT-CANARY-027: benign lab payload
argv[0] at launch: ./palimpsest
--- exec-time argv, pinned before the rewrite:
./palimpsest
PADDINGPADDINGPADDING
GHOSTLIGHT-CANARY-027
    PID COMMAND         COMMAND
     13 palimpsest      ./palimpsest PADDINGPADDINGPADDING GHOSTLIGHT-CANARY-027
2

Read the rewritten story

sleep 4 waits out the three-second fuse. The process's own line lands first: argv[0] rewritten in place: [kworker/u16:2]. Then the same pid, ps -o pid,comm,args: comm still palimpsest, args now [kworker/u16:2]. The cmdline, with the NUL padding squeezed, is the decoy and nothing else. The exe link still says /tmp/gh027/palimpsest; comm still says palimpsest. Nothing was exec'd, no pid was born or died: the only thing that changed is the bytes in the process's own argv memory.

bash
$ sleep 4
echo '--- the same pid, after the rewrite:'
ps -o pid,comm,args -p $P
echo '--- cmdline now (NUL padding squeezed):'
tr '\0' ' ' < /proc/$P/cmdline | tr -s ' '; echo
echo '--- exe link (unchanged):'
readlink /proc/$P/exe
echo '--- comm (unchanged):'
cat /proc/$P/comm
argv[0] rewritten in place: [kworker/u16:2]
--- the same pid, after the rewrite:
    PID COMMAND         COMMAND
     13 palimpsest      [kworker/u16:2]
--- cmdline now (NUL padding squeezed):
[kworker/u16:2]
--- exe link (unchanged):
/tmp/gh027/palimpsest
--- comm (unchanged):
palimpsest

An operator skimming the process list reads a kernel thread name they expect and moves on; that moving on is the entire technique. The birth certificate in exec-record.txt still tells the truth, and nobody is reading it.

bash
$ echo 'stealth confirmed: no exec happened, yet ps now reports a kernel thread'
stealth confirmed: no exec happened, yet ps now reports a kernel thread
Stealth confirmed

No exec happened, yet ps now reports a kernel thread. The process list was never checking the process; it was reading the process's own memory back to the operator, and the process changed what was there.

04

Phase Blue: read the parchment, not the ink

DEFENSE

The defender never saw the launch; the blue take opens on the rewritten process list. The triad, at runbook quality. Detection: hunt for bracket-named processes whose cmdline is live and whose exe link resolves (real kernel threads have neither), then convict on the three-way mismatch between comm, cmdline, and exe. Mitigation: capture the evidence first (cmdline bytes, exe target, binary hash), then kill by exact PID. Prevention: pin the exec-time argv where the process cannot reach it and diff every live cmdline against the pin; the rewrite emits no event, so the diff is the durable control.

Real screen recording 103.9s
What you are watching: The defender hunts the bracket decoy, convicts it against the kernel's records, captures evidence, and removes it. Every command below is copy-pasteable.
1

Hunt the bracket decoys

pgrep -f 'kworker/u16:2' finds the suspect by its forged cmdline: real kernel threads have empty cmdlines, so the full-text match never touches them. The loop is the fleet form: for every pid, squeeze the cmdline and match bracket-wrapped names, and a hit only counts if the exe link resolves. Real kworkers fail both tests at once: their cmdline is empty and their exe link dangles. The output is one lead: LEAD pid=13 cmdline=[[kworker/u16:2]]. An operator who trusts brackets alone would stop here; the blue phase does not.

bash
$ cd /tmp/gh027
P=$(pgrep -f 'kworker/u16:2'); echo "suspect pid: $P"
for d in /proc/[0-9]*; do
  c=$(tr '\0' ' ' < "$d/cmdline" 2>/dev/null | tr -s ' ' | sed 's/^ //;s/ $//')
  case "$c" in
    \[*\]) readlink "$d/exe" >/dev/null 2>&1 && echo "LEAD pid=${d#/proc/} cmdline=[$c]" ;;
  esac
done
suspect pid: 13
LEAD pid=13 cmdline=[[kworker/u16:2]]
2

Convict and capture evidence

ps -o pid,ppid,lstart,comm,args is the conviction: started Mon Oct 5 11:26:39 2026, comm palimpsest, args [kworker/u16:2], and the exe link says /tmp/gh027/palimpsest. Three records, two authors: comm and exe are the kernel's (written at exec), cmdline is the process's (rewritten after). Two agree; the testimony stands alone. Evidence before action: the cmdline bytes, the exe target, a copy of the binary, its sha256, and the ps line, all timestamped into evidence/. Only then does the blue phase move to removal.

bash
$ ps -o pid,ppid,lstart,comm,args -p $P
echo '--- exe:'; readlink /proc/$P/exe
mkdir -p evidence
tr '\0' '\n' < /proc/$P/cmdline > evidence/cmdline-bytes.txt
readlink /proc/$P/exe > evidence/exe.txt
cp /proc/$P/exe evidence/palimpsest.bin
sha256sum evidence/palimpsest.bin > evidence/hash.txt
ps -o pid,ppid,lstart,comm,args -p $P > evidence/ps.txt
ls -l evidence
    PID    PPID                  STARTED COMMAND         COMMAND
     13       1 Mon Oct  5 11:26:39 2026 palimpsest      [kworker/u16:2]
--- exe:
/tmp/gh027/palimpsest
total 32
-rw-rw---- 1 root root    57 Oct  5 11:26 cmdline-bytes.txt
-rw-rw---- 1 root root    22 Oct  5 11:26 exe.txt
-rw-rw---- 1 root root    90 Oct  5 11:26 hash.txt
-rwxrwx--- 1 root root 16272 Oct  5 11:26 palimpsest.bin
-rw-rw---- 1 root root   138 Oct  5 11:26 ps.txt
3

Pin the rewrite against the exec record

diff exec-record.txt against the live cmdline (NUL padding filtered for display): three truthful launch lines against one forged line. The && echo 'no rewrite' branch never fires; the || prints the verdict: the live cmdline no longer matches the exec-time record. command -v auditctl finds /usr/sbin/auditctl, so the tooling is present, but the audit daemon is not running in this lab and no execve records were written; exec-record.txt is the lab stand-in for the immutable audit log, and the diff is the demonstration that actually ran. The production form of this pin is the immutable execve rule in the countermeasures.

bash
$ echo '--- live cmdline vs exec-time record:'
diff exec-record.txt <(tr '\0' '\n' < /proc/$P/cmdline | grep -v '^$') && echo 'no rewrite' || echo 'REWRITE: the live cmdline no longer matches the exec-time record'
command -v auditctl || echo 'no auditd in this lab: exec-record.txt is the lab stand-in for the immutable auditd execve log'
--- live cmdline vs exec-time record:
1,3c1
< ./palimpsest
< PADDINGPADDINGPADDING
< GHOSTLIGHT-CANARY-027
---
> [kworker/u16:2]
REWRITE: the live cmdline no longer matches the exec-time record
/usr/sbin/auditctl
4

Kill by PID, verify, clean up

kill 13: by exact PID, never by name or pattern. The evidence already convicted this pid; a bracket pattern is a regex, and the wrong match on a fleet would be catastrophic. sleep 0.5, then ps -p 13 finds nothing: the header prints, no row follows, and the echo confirms the impostor is gone and no real kworker was ever touched. rm -rf /tmp/gh027 removes the lab; the namespace's death reaps every stray.

bash
$ kill $P
sleep 0.5
ps -p $P || echo 'impostor gone; no real kworker was ever touched'
cd /tmp && rm -rf /tmp/gh027 && ls /tmp
    PID TTY          TIME CMD
impostor gone; no real kworker was ever touched
Detection verified

The bracket hunt found the one live cmdline with a resolvable exe, the comm/cmdline/exe mismatch convicted it, the exec-record diff proved the rewrite happened after launch, and the evidence was captured before the kill. The testimony changed; the records did not.

05

Countermeasures

DEFENSE

Three moves, in order: remove it, sweep for its siblings, make the next rewrite checkable. Each is one way, not the way.

1

Mitigate: kill the impostor, evidence first

It is an ordinary unprivileged process: kill ends it, and there is no persistence here, no reinfection, no second stage. The order is the procedure: read the exe link, copy the binary, hash it, save the cmdline bytes, then kill. Kill by exact PID, confirmed against the exe link first. Never pkill -f 'kworker': a pattern is a promise you keep making to every future process on the box, and the wrong match on a fleet is catastrophic. Never bare pkill kworker either: without -f it matches comm, and comm is exactly what real kernel threads are named. The blue take ran this order: evidence/ first, kill second, verification third.

bash
$ P=$(pgrep -f 'kworker/u16:2')
kill $P
sleep 0.5
ps -p $P || echo 'impostor gone; no real kworker was ever touched'
    PID TTY          TIME CMD
impostor gone; no real kworker was ever touched
2

Monitor: sweep for bracket-named live cmdlines

The fleet form of the blue hunt, on a timer: every pid, squeeze the cmdline, match bracket-wrapped names, keep the hit only if the exe link resolves. One loop, no baseline, no agent.

bash
$ for d in /proc/[0-9]*; do
  c=$(tr '\0' ' ' < "$d/cmdline" 2>/dev/null | tr -s ' ' | sed 's/^ //;s/ $//')
  case "$c" in
    \[*\]) readlink "$d/exe" >/dev/null 2>&1 && echo "LEAD pid=${d#/proc/} cmdline=[$c]" ;;
  esac
done
LEAD pid=13 cmdline=[[kworker/u16:2]]

Run it across the fleet and you have the whole monitor; production versions add alerting, not new ideas.

Honest limit. This net catches only the bracket style. An attacker who overwrites argv[0] with sshd: ubuntu@pts/0 or /usr/sbin/cron -f, no brackets anywhere, sails straight through it. The general detector is the exec-record diff from Phase Blue: any rewrite fails the diff, whatever the decoy looks like. But the diff needs a pin for every process, and pins are the expensive part: execve auditing logs every process birth on the fleet, and a process born before the rule existed has no pin at all. The sweep also needs root to read every /proc/<pid>/cmdline; run it as an unprivileged user and you are blind to every other user's processes.

3

Prevent: pin exec-time argv immutably

No kernel control stops a process from writing its own memory; the write is the process's own store instruction, and prohibiting it would prohibit computation. So prevention here does not mean blocking the write. It means making the lie checkable: pin argv at exec in a place the process cannot rewrite, then diff every live cmdline against the pin, exactly as the blue take did with exec-record.txt. The production pin is the audit daemon's immutable execve log: -a always,exit -F arch=b64 -S execve -k exec_argv, with the config locked by auditctl -e 2 so it cannot be changed short of reboot, or the EDR's process-creation event shipped off-host where the local attacker cannot reach it.

bash
$ diff exec-record.txt <(tr '\0' '\n' < /proc/$P/cmdline | grep -v '^$') && echo 'no rewrite' || echo 'REWRITE: the live cmdline no longer matches the exec-time record'
1,3c1
< ./palimpsest
< PADDINGPADDINGPADDING
< GHOSTLIGHT-CANARY-027
---
> [kworker/u16:2]
REWRITE: the live cmdline no longer matches the exec-time record

Honest limit. The rewrite itself emits no event, so an immutable log that nobody diffs against detects nothing; the control is the diff, not the log. The audit daemon was not running in this lab (the tooling at /usr/sbin/auditctl was present, the daemon was not), which is why the lab ran the diff against the stand-in record instead of the real log. Execve auditing is also the noisiest rule in the audit subsystem, every exec on the fleet, so most shops scope it or sample it, and every sampled birth is a process with no pin. And a long-running process that started before the rule existed has no pin either, so its rewrite is invisible to the diff. You cannot prevent the write. You can only prevent the stealth, and only if the diff actually runs.

Countermeasures verified

The impostor dies to an ordinary kill once the evidence is captured. The bracket sweep finds its siblings fleet-wide with one loop. The immutable exec-time pin makes the next rewrite checkable. None of it stops a process from writing its own memory; all of it stops the lie from surviving contact with the kernel's records.

06

Debrief

TAKEAWAY

The command line is the process's own writable memory, not a record of its launch: any check that reads it once, at birth, loses to a rewrite that happens after, so believe only what the process cannot rewrite, the kernel's exe link and a pinned exec-time record.

IOC checklist: signs this technique was used

  • A process whose cmdline is wrapped in brackets, kernel-thread style, while /proc/<pid>/exe resolves to a file (real kernel threads have an empty cmdline and no exe)
  • comm/cmdline disagreement: the kernel's short name says one thing, the testimony says another
  • A cmdline that changed while the pid, start time, ppid, and exe stayed the same: the lifetime lie against the birth record
  • Kernel-thread names on pids that are not kernel threads: a ppid that is not kthreadd, an exe link that resolves

Reproducibility checklist

  • Verified on Ubuntu 24.04.5 LTS, gcc 13, x86-64, on 2026-10-05
  • Both recordings are real executions on that platform, not simulations
  • The attack runs fully unprivileged: a process may always write its own memory
  • Cleanup: kill the lab pid; rm -rf /tmp/gh027 (recorded); the namespace's death reaps every stray

Sources

MITRE ATT&CK T1036.011: Masquerading: Overwrite Process Arguments
MITRE ATT&CK T1036: Masquerading (the parent technique)
proc(5) (the /proc/<pid>/cmdline bytes and the exe symlink)
ps(1) (the comm and args output columns)
execve(2) (argv copied onto the new process's stack at exec)

Next file

GH-028 The Deaf Ear

The next file teaches a process to ignore the interrupt signal, then watches the usual kill bounce off.