One trick fools one observer. This file stacks four, a tracer gate, a hidden directory, a borrowed name, and a sleeper, then peels each one with a different observer. Every layer defeats exactly one way of looking.
MITRE ATT&CK T1622: adversaries check whether a debugger or tracer is watching, and change behavior when one is. This file builds a four-layer stack around that check, then takes the defender's side with a different observer per layer.
The stack idea in one sentence. Each layer defeats exactly one way of looking, and every new layer is a new surface a different way of looking can see.
Why it matters. A tracer (strace) is how an analyst watches a program's system calls. A payload that can tell it is being watched can save its real behavior for when nobody is looking. The check here is cheap and direct: every Linux process has a status file at /proc/self/status, and its TracerPid field names the tracing process, or 0 when none is. One file read, no privilege, and the payload knows what the analyst hoped it could not: whether anyone is watching.
Why not just look harder. Staring longer at the process list cannot beat a borrowed name, because the borrowed name was built for exactly that stare. The fix is never a harder look through the same observer. It is a different observer.
| Layer | Defeats this observer | Falls to this observer |
|---|---|---|
| 1. Tracer gate: the payload reads its own TracerPid and exits silently if nonzero | The analyst's tracer (strace) | None: it dies. The death is the tell. |
| 2. Hidden directory: the payload lives in .sys-cache | The default listing (ls) | ls -a, find |
| 3. Borrowed name: argv[0] set to syslog-helper at launch | The process-table glance (pgrep) | /proc/PID/cmdline, /proc/PID/exe |
| 4. Sleeper: the payload sleeps 900 seconds after running | Nothing; it buys inspection time | pkill, once found |
Terms, earned where they first appear. A tracer attaches with the ptrace system call; the kernel records its process id in the tracee's TracerPid field. /proc/self is the current process's own /proc entry, so /proc/self/status is the payload reading its own record. The read must happen in the payload itself: a child process would report the child's own TracerPid, which is why the script uses a shell loop instead of delegating to awk or grep. argv[0] is the process's self-reported name, set by whatever launched it; exec -a overrides it. The kernel keeps two facts that do not consult that story: /proc/PID/cmdline, the full command line including the real script path, and /proc/PID/exe, a link to the actual executable file. A dot-directory is a name starting with a period, hidden from plain ls by a display convention from the 1970s, not by any filesystem enforcement.
The concrete case. /tmp/gh010 holds one visible file, notes.txt, and one hidden directory, .sys-cache, holding sync.sh. Under strace the payload reads a nonzero TracerPid and exits before touching its marker file. Launched clean under a borrowed name, it runs, touches .marker, and sleeps. Plain ls prints one name. pgrep prints a boring one. /proc prints the truth.
Scope. T1622 Debugger Evasion covers every way a program detects analysis: TracerPid checks, timing checks, breakpoint scans. This file works the TracerPid case end to end on Linux, then stacks it with T1564.001 (the hidden directory) and T1036 (the borrowed name) to show how layers compose: each new layer defeats one observer and exposes a new surface.
Ubuntu 24.04.5 LTS, bash 5.2, x86-64, strace. No privilege, no network, no persistence. The lab is one directory (/tmp/gh010), one decoy file (notes.txt), one hidden directory (.sys-cache), one payload script (sync.sh).
One directory, one decoy, one hidden directory. notes.txt is the boring visible file the casual listing sees.
$ rm -rf /tmp/gh010; mkdir -p /tmp/gh010/.sys-cache && cd /tmp/gh010 && touch notes.txt && ls notes.txt
Fresh lab, decoy inside, shell moved into it. Now the payload, written into the hidden directory. The quoted 'EOF' keeps the shell from expanding anything in the heredoc.
$ cat > .sys-cache/sync.sh <<'EOF' > #!/bin/sh > # GH-010 lab payload. Benign: reads TracerPid, touches one > # marker, then sleeps. No network, no persistence, no privilege. > # Layer 1 (T1622): the payload reads its own TracerPid. > # Tracer attached? Exit silently. No tracer? Run. > tpid=0 > while read -r key val _; do > if [ "$key" = "TracerPid:" ]; then tpid=$val; break; fi > done < /proc/self/status > if [ "$tpid" != "0" ]; then > exit 0 > fi > cd "$(dirname "$0")" || exit 1 > touch .marker > sleep 900 > EOF
Fifteen lines. The tracer gate lives or dies in this file, so every line is glossed.
#!/bin/sh # GH-010 lab payload. Benign: reads TracerPid, touches one # marker, then sleeps. No network, no persistence, no privilege. # Layer 1 (T1622): the payload reads its own TracerPid. # Tracer attached? Exit silently. No tracer? Run. tpid=0 while read -r key val _; do if [ "$key" = "TracerPid:" ]; then tpid=$val; break; fi done < /proc/self/status if [ "$tpid" != "0" ]; then exit 0 fi cd "$(dirname "$0")" || exit 1 touch .marker sleep 900
tpid=0 assumes unwatched until proven otherwise. The while loop reads /proc/self/status line by line in the shell itself, no child process, so /proc/self is the payload (delegating to awk or grep would read the child's own status). On the TracerPid: line the value is saved and the loop stops. Nonzero means a tracer is attached, and exit 0 dies silently: an error message would itself be evidence. cd "$(dirname "$0")" moves into the script's own directory so the marker lands beside the payload wherever it was launched from. touch .marker is the only write the script ever makes, and the proof it executed. sleep 900 keeps the process alive fifteen minutes so the defender has something to find.
Watch the attack succeed first. Then watch it disappear three ways.
One command launches the payload in the background, wearing a false name.
$ exec -a syslog-helper bash ./.sys-cache/sync.sh & [1] 10999
exec -a sets argv[0], the process's self-reported name, to syslog-helper before launching. A real bash binary runs the script, so the borrowed name survives (a shebang launch would re-execute the interpreter and drop it). The [1] line is the shell confirming the background job and its process id.
One check proves the payload executed. The marker file is the proof: only a running payload creates it.
$ sleep 1; test -e .sys-cache/.marker && echo "payload ran: marker created" payload ran: marker created
That line is the whole attack succeeding. No tracer was attached, TracerPid read 0, the gate passed, the payload touched its marker and went to sleep. Everything after this is the attacker making that success hard to see.
Same directory, two questions.
$ ls; echo ---; ls -a notes.txt --- . .. .sys-cache notes.txt
ls shows the decoy. ls -a shows the hidden directory. Nothing changed between the commands except the question asked. Layer two defeats the default listing and nothing else.
Ask the process table who is running.
$ pgrep -af syslog-helper 10999 syslog-helper ./.sys-cache/sync.sh
One process, wearing a boring name. pgrep matched the borrowed argv[0] against the pattern. The process table repeats the name; it never checks whether it is true. Layer three defeats the casual glance and nothing else.
Now try to watch it. The payload is copied aside and run under strace, the standard way to observe a program's system calls.
$ mkdir -p /tmp/t; cp .sys-cache/sync.sh /tmp/t/; chmod +x /tmp/t/sync.sh; strace -f -o /dev/null /tmp/t/sync.sh; echo "rc=$?" rc=0
rc=0. That is a quiet death, not a crash. strace attached, the payload read a nonzero TracerPid, and it exited before its first write. The copy keeps the live lab untouched.
$ test ! -e /tmp/t/.marker && echo "no marker: it saw the tracer and played dead"; rm -rf /tmp/t no marker: it saw the tracer and played dead
No marker: the gate held. The payload never ran, so there is nothing to analyze. Layer one defeats the tracer and nothing else. Three layers, three observers defeated, and the attack from step 2 is still sleeping where you cannot see it.
The attack ran and proved it with a marker. The default listing shows one decoy file, the process table shows a boring name, and a tracer sees the payload die before it does anything. The hiding cost one leading dot, one borrowed name, one /proc read.
Detection is changing the observer, not looking harder. Then removal.
Triage that stops at the default listing closes the case here.
$ cd /tmp/gh010 && ls notes.txt
One boring text file. The payload keeps sleeping.
First observer change: ask ls to skip its dotfile courtesy.
$ ls -a . .. .sys-cache notes.txt
There is the hidden directory. Same observer, different question, and layer two is gone.
The process table, as the attacker wants you to read it.
$ pgrep -af syslog-helper 10999 syslog-helper ./.sys-cache/sync.sh
One sleeper with an unremarkable name. Nothing here says attack. So change the observer again.
argv[0] is a story the process tells. These two are facts the kernel keeps.
$ P=$(pgrep -f '[s]yslog-helper'); echo "pid=$P" pid=10999
That pid goes into two kernel files that never consult argv[0].
$ tr '\0' ' ' < /proc/$P/cmdline; echo; readlink /proc/$P/exe syslog-helper ./.sys-cache/sync.sh /usr/bin/bash
/proc/PID/cmdline is the full command line: the borrowed name first, then the real script path it was launched with. /proc/PID/exe is a link to the actual executable file, /usr/bin/bash, which no argv[0] can rewrite. Two kernel facts against one self-reported name: that is what changing the observer buys. Layer three is gone.
find walks the tree at the filesystem level, where a leading dot is just another character. The dotfile courtesy does not exist down here.
$ find /tmp/gh010 -name '.*' | sort /tmp/gh010/.sys-cache /tmp/gh010/.sys-cache/.marker
Two hidden paths, by their real names, marker included. The marker is the proof the payload executed in this directory. -name '.*' matches names starting with a dot; the quotes keep the shell from expanding the pattern first; sort orders the output.
The tracer gate was the attacker's defense. Turned around, it is a confession. Attach strace and watch what happens.
$ rm -f /tmp/gh010/.sys-cache/.marker && chmod +x /tmp/gh010/.sys-cache/sync.sh; strace -f -o /dev/null /tmp/gh010/.sys-cache/sync.sh; echo "rc=$?" rc=0
rc=0, same quiet death as the red phase. The marker was removed first, so check whether the payload ran.
$ test ! -e /tmp/gh010/.sys-cache/.marker && echo "no marker: it saw the tracer" no marker: it saw the tracer
No marker. A process that dies the moment a tracer attaches is telling you it checks for tracers, and that confession costs the defender nothing: no payload execution, no risk. This is the T1622 tell. Layer one is gone.
Detection done. Stop the process, then remove the files.
$ pkill -f '[s]yslog-helper'; sleep 0.5; pgrep -af syslog-helper || echo "process gone" process gone
pkill signals by name pattern. The [s] bracket keeps pkill from matching its own command line and killing the shell that runs it. "process gone" is the confirmation: no matching processes remain.
Before the files go, scope the incident: persistence, timeline, ownership. The layered guest earned its name by stacking evasions; assume the visible layer is not the only one until the persistence sweep and the timeline say so.
$ stat -c '%y %U %n' /tmp/gh010/.sys-cache/* # when it arrived, who owns it $ crontab -l 2>/dev/null; systemctl --user list-units --all 2>/dev/null | grep -i -E 'sync|cache|syslog' $ grep -rl 'sys-cache\|syslog-helper' ~/.bashrc ~/.profile /etc/cron* /etc/systemd/system 2>/dev/null
$ rm -rf /tmp/gh010; ls /tmp/gh010 2>/dev/null || echo "lab directory gone" lab directory gone
rm -rf removes the whole tree, hidden names included: rm never asked the display either. The error is the confirmation. No process, no files, no marker. Nothing persists.
Every layer fell to a different observer, the tracer gate confessed without the payload ever running, and the lab directory is gone.
Three moves, in order: change the observer, watch the writes, decide what may run. Each is one way, not the way.
Stop asking any single tool and start cross-examining them. Compare cmdline against exe, minus the known-benign classes: a login shell reads argv[0]="-bash" against exe /bin/bash; a shebang script reads argv[0]="/path/script" against the interpreter in exe, the normal interpreter case; busybox applets and distro exec -a wrappers rename on purpose too. Without those exclusions, comparing cmdline against exe as a standing check pages the team for every login shell on the fleet. Compare the process table against the filesystem too: anything executing from a dot-directory earns a closer look.
$ tr '\0' ' ' < /proc/$P/cmdline; echo; readlink /proc/$P/exe syslog-helper ./.sys-cache/sync.sh /usr/bin/bash
The standing-check form, narrowed so the benign classes stay quiet. This is the fleet form of the blue phase: the idea does not change, only the coverage.
$ for d in /proc/[0-9]*/; do
pid=${d#/proc/}; pid=${pid%/}
a0=$(tr '\0' '\n' < "$d/cmdline" 2>/dev/null | head -1); [ -n "$a0" ] || continue
exe=$(readlink "$d/exe" 2>/dev/null); [ -n "$exe" ] || continue
base=${exe##*/}
case "$a0" in
"$base"|"$exe"|/*|-"$base") continue ;; # real name, full path, script path, login shell
esac
echo "pid=$pid argv0=[$a0] exe=[$exe]"
done
pid=5 argv0=[syslog-helper] exe=[/usr/bin/bash]
Tested: in the lab this flagged only the syslog-helper process against /usr/bin/bash. The tracer tell gets the same treatment in reverse: you cannot strace every process, so sample a suspicious one under strace in a sandbox and watch for the quiet death, exactly the blue phase's step 6, labeled as sampling rather than monitoring.
Honest limit. Comparison only works when both answers are trustworthy. A rootkit underneath (T1014) hides from /proc and the process table alike: no observer comparison helps when every view is mediated.
A hidden file is still a created file, and a borrowed name still belongs to a real exec. File integrity monitoring (D3-FIM) notices the marker appearing in a watched directory regardless of its first character. Software inventory (D3-SWI) flags binaries that were never supposed to be on the machine, whatever their names start with. Creation-time telemetry records the image path and the argv array as separate fields of the same execve event. The theater is not hidden from the log; it is in it, as a0. Detection is the join: image path says what ran, a0 says what it claimed to be.
$ auditctl -a exit,always -F arch=b64 -S execve -k exec-all $ auditctl -a exit,always -F arch=b32 -S execve -k exec-all $ ausearch -k exec-all --start recent -m EXECVE,SYSCALL 2>/dev/null | grep -B2 'a0='
Read each hit as a pair: type=SYSCALL ... exe="/real/image" plus type=EXECVE ... a0="claimed-name". Good versus bad: good is exe="/usr/bin/bash" a0="-bash" (a login shell), exe="/usr/bin/python3" a0="/opt/app/main.py" (a shebang script), or a busybox applet. Bad is exe="/usr/bin/bash" a0="syslog-helper", or any a0 with no path relationship to exe and no benign explanation. Sysmon for Linux users get the same pair as Event 1 fields Image and CommandLine.
Honest limit. FIM sees the write only if it was already watching that path. Nobody watches all of /tmp by default. And the join trusts the log: a rootkit under /proc (T1014) defeats every observer comparison.
Hiding is free, so prevention targets execution instead. Executable allowlisting means an unknown script dropped into a hidden directory never runs, whatever its name. Nothing here persists unless something runs it, so the inventory that matters is the process table, taken regularly, not the directory listing.
Honest limit. The tracer gate itself is not preventable by policy: any process may read its own status. And an allowlist is only as good as its list. TracerPid can also be masked by a careful tracer, so the gate is a tripwire, not a guarantee.
Observers are cross-examined instead of trusted, writes are watched at the kernel's layer, execution is decided by policy, and every control's bypass is stated above.
Stealth is a stack: every layer defeats one observer and exposes a new surface, so the defender wins by changing observers, not by looking harder through the same one.
IOC checklist: signs this technique was used
Reproducibility checklist
Sources
MITRE ATT&CK T1622: Debugger Evasion
T1564.001: Hidden Files and Directories, T1036: Masquerading, T1014: Rootkit
strace(1), proc(5), pgrep(1), pkill(1), find(1)
D3FEND 1.6.0 models no defender for T1622, so the wired defenders cover the stacked layers: D3-FIM: File Integrity Monitoring, D3-SWI: Software Inventory for the hidden-directory layer, the two that add real coverage there
The command line lies by omission. The next file seals the order shut, and shows how the defender opens it.