A filename is a claim the kernel never verifies. This file renames a trusted utility aside with one mv, plants an impostor at the vacated path, and watches the name-based check report TRUSTED on the attacker's bytes. The defender stops trusting the name and starts reading the bytes: the hash baseline convicts the impostor, the renamed backup restores the real tool, and a read-only mount makes the next rename fail at the syscall.
MITRE ATT&CK T1036.003: adversaries rename legitimate system utilities, or move them aside and wear their names, so name-based trust keeps working for the attacker's bytes. This file renames a trusted lab utility to a backup name with mv, plants an impostor at the vacated path, watches the name-based check report TRUSTED, then convicts the impostor on its bytes. Two actors: the attacker, who owns the rename and the impostor; and the defender, who owns the baseline, the hunt, the restore, and the read-only mount in the blue phases.
Why this technique. Every allowlist, every detection rule keyed on a filename, and every operator habit runs on one assumption: that the name on a file describes the bytes inside it. The kernel never checks that assumption. execve() runs bytes; it does not ask whether the bytes match the name. A rename is the cheapest way to exploit the gap: move the real utility aside (one syscall, rename(2), the bytes untouched, the inode unchanged) and write your own bytes at the vacated path. The name keeps its history, its allowlist entries, its place in the admin's fingers. Nothing about the name changed, so nothing keyed on the name fires.
Why not the obvious alternative. The obvious move is a fresh innocent name: the attacker ships a renamed rundll32.exe proxying DLL execution from an unfamiliar directory, or an image of cmd.exe with a random name and a .tmpl extension. Break it on a concrete input: the name is one the OS never shipped. The defender runs the next file-inventory diff, the diff shows a stranger, and the question "what is this binary" answers itself: a brand-new name has no trust history to hide behind. A second alternative is a name that disagrees with its bytes, like quarterly-report.pdf.sh that executes as a shell script. The defender runs file(1), file reads the bytes instead of the name, and the output says shell script: the name's claim dies at the first byte check. A third alternative is a plant that sits earlier in the PATH than the real tool, so the bare name resolves to the attacker's copy. The defender invokes the absolute path /usr/bin/tool, the shell skips the PATH lookup entirely, and the real binary runs: the plant never executes. The false uniform survives all three breaks: the name is already trusted, the bytes claim nothing about type, and the impostor sits at the real path, so even the absolute-path invocation runs the attacker's bytes.
The mechanism, in one paragraph. mv is rename(2): the directory entry changes, the inode does not. After mv remotedebug remotedebug.bak, the original inode still holds the real bytes, now under a backup name. The attacker's write at the old path allocates a new inode with the attacker's bytes. Three checks still pass: the path exists, the file is executable, and it runs clean. Those are name-based checks, and the name never lied about anything except identity. The tells are all byte- or metadata-based: the trusted path's inode changed, its ctime jumped to the swap time, its sha256 no longer matches the baseline recorded before the swap, and a .bak file sits next to it wearing the old bytes. A baseline is the pre-compromise record of what the bytes should be: hashes, plus inode and size from stat, captured when the system was known good.
The concrete case, before the abstraction. PHASEJAM (S9014) is the worked case, straight from the ATT&CK procedure list: the actors renamed /home/bin/remotedebug to remotedebug.bak, then wrote a malicious /home/bin/remotedebug shell script at the vacated path. The real tool survived, intact, under a backup name; the trusted name ran the attacker's script. APT38 used the sibling form, renaming rundll32.exe and mshta.exe to dodge name-based detection, and menuPass renamed certutil and moved it so the tool's use would not trip on its famous name. Same idea at three widths: the name is the disguise.
Terms, earned. rename(2) is the syscall mv uses: it changes a file's name without touching its bytes or its inode. An inode is the filesystem's identity for a file's bytes; names point at inodes, so a rename moves the pointer, not the data. A baseline is a pre-compromise record of hashes and metadata, captured when the system was known good. Name-based trust is any check that passes on the name, path, or executability without reading the bytes.
Scope. T1036.003 covers renaming legitimate utilities on Linux, Windows, and macOS, in both directions: the tool renamed to hide, and the real tool renamed aside so the impostor can wear its name. This file works the second direction end to end on Linux, the PHASEJAM shape: the mv, the impostor at the trusted path, the hash, inode, and .bak tells, the evidence-first restore, and the read-only bind mount that makes the next rename fail. The canary is a benign token: it marks the impostor's bytes 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.
Ubuntu 24.04.5 LTS, x86-64, in a disposable PID and mount namespace used only for this lab. The attack needs no privilege beyond write access to the tool directory: rename(2) is an ordinary filesystem operation. The lab never touches a real system utility: remotedebug is a stand-in, and the host's /usr/bin and /bin are never written. Run it on a throwaway box anyway, because you are about to practice stealing a trusted name.
The recording starts from an empty private /tmp inside its own mount namespace, so every take begins identical. rm -rf /tmp/gh029 starts clean; mkdir -p and cd set up the lab directory. The heredoc writes remotedebug (quoted 'EOF', so the shell passes the source through untouched); chmod +x makes it executable. ./remotedebug runs the real utility: two lines, no canary. Then the defense-in-depth habit, done before anything hostile happens: sha256sum records the bytes into baseline.sha256, stat records the inode and size into baseline.stat. A baseline captured after the compromise is the attacker's alibi; this one predates it.
$ rm -rf /tmp/gh029 && mkdir -p /tmp/gh029/lab/bin && cd /tmp/gh029/lab/bin cat > remotedebug <<'EOF' #!/bin/bash # remotedebug: vendor device-debug utility. # Lab stand-in for a trusted tool at a fixed path. echo "remotedebug: dumping device state" echo "device: OK" EOF chmod +x remotedebug ./remotedebug sha256sum remotedebug | tee baseline.sha256 stat -c 'inode=%i size=%s' remotedebug | tee baseline.stat remotedebug: dumping device state device: OK b318a9c35e0d486238fbe082f77ddf4a040adb441b97dc089a499d7f2a6796ec remotedebug inode=5 size=166
Five lines. The shebang picks bash; the comment names it as a stand-in, because the lab never touches a real system utility. Two echo lines are the whole behavior: a status line and device: OK. The blue phase will run these exact bytes again after the restore and get these exact lines back, with no canary.
#!/bin/bash # remotedebug: vendor device-debug utility. # Lab stand-in for a trusted tool at a fixed path. echo "remotedebug: dumping device state" echo "device: OK"
Four lines. Same shebang, same first echo line, so a casual run looks identical. The second line prints GHOSTLIGHT-CANARY-029, the benign token that proves whose bytes ran. Nothing else differs: the uniform is the whole attack.
#!/bin/bash # Wears the trusted name. Runs the attacker's bytes. echo "remotedebug: dumping device state" echo "GHOSTLIGHT-CANARY-029"
The attacker renames the real utility aside with mv and plants the impostor at the vacated path. The operator then runs the trusted name three ways, and the name-based check reports TRUSTED on the attacker's bytes. Only the hash baseline disagrees.
The lab directory, the real utility, and the pre-compromise baseline: the hash of the bytes and the inode of the file, recorded while the system is known good.
$ rm -rf /tmp/gh029 && mkdir -p /tmp/gh029/lab/bin && cd /tmp/gh029/lab/bin cat > remotedebug <<'EOF' #!/bin/bash # remotedebug: vendor device-debug utility. # Lab stand-in for a trusted tool at a fixed path. echo "remotedebug: dumping device state" echo "device: OK" EOF chmod +x remotedebug ./remotedebug sha256sum remotedebug | tee baseline.sha256 stat -c 'inode=%i size=%s' remotedebug | tee baseline.stat remotedebug: dumping device state device: OK b318a9c35e0d486238fbe082f77ddf4a040adb441b97dc089a499d7f2a6796ec remotedebug inode=5 size=166
mv is rename(2): the real bytes keep their inode under remotedebug.bak. The heredoc writes the impostor at the vacated path; chmod +x dresses it. ls -l shows the uniform is back on: remotedebug exists again, executable, same directory. The name changed hands and nothing announced it.
$ cd /tmp/gh029/lab/bin U=/tmp/gh029/lab/bin/remotedebug mv "$U" "$U.bak" cat > "$U" <<'EOF' #!/bin/bash # Wears the trusted name. Runs the attacker's bytes. echo "remotedebug: dumping device state" echo "GHOSTLIGHT-CANARY-029" EOF chmod +x "$U" ls -l echo 'the trusted name is back on; the bytes are not' total 16 -rw-rw---- 1 root root 78 Oct 5 12:10 baseline.sha256 -rw-rw---- 1 root root 17 Oct 5 12:10 baseline.stat -rwxrwx--- 1 root root 135 Oct 5 12:10 remotedebug -rwxrwx--- 1 root root 166 Oct 5 12:10 remotedebug.bak the trusted name is back on; the bytes are not
"$U" runs the trusted path: the first line matches the real utility, the second line is the canary, proof the bytes are the attacker's. The name-based check, present plus executable plus runs clean, reports TRUSTED. Then the byte-based check: sha256sum -c baseline.sha256 answers FAILED, rc=1. Same file, two verdicts: the name trusts, the bytes convict.
$ cd /tmp/gh029/lab/bin U=/tmp/gh029/lab/bin/remotedebug echo '--- the operator runs the trusted tool:' "$U" echo '--- the name-based check:' [ -x "$U" ] && "$U" >/dev/null 2>&1 && echo 'remotedebug: present, executable, runs clean -> TRUSTED' echo '--- the byte-based check:' sha256sum -c baseline.sha256; echo "rc=$?" --- the operator runs the trusted tool: remotedebug: dumping device state GHOSTLIGHT-CANARY-029 --- the name-based check: remotedebug: present, executable, runs clean -> TRUSTED --- the byte-based check: remotedebug: FAILED sha256sum: WARNING: 1 computed checksum did NOT match rc=1
stat shows the .bak keeping the original inode while the trusted name carries a new one. The rename moved a pointer; the plant allocated new bytes. The footprint is small, but it is all metadata the attacker cannot avoid leaving.
$ cd /tmp/gh029/lab/bin stat -c '%n inode=%i' remotedebug remotedebug.bak echo 'the .bak keeps the original inode; the trusted name got a new one' echo 'stealth confirmed: rename(2) moved the real utility aside and the impostor took its name' remotedebug inode=8 remotedebug.bak inode=5 the .bak keeps the original inode; the trusted name got a new one stealth confirmed: rename(2) moved the real utility aside and the impostor took its name
The trusted path, the trusted name, and the name-based check all survived the swap. The operator's verification passed on the attacker's bytes; only a pre-compromise hash baseline could see the change, and the attacker is counting on nobody having one.
The defender never saw the swap; the blue take opens on the swapped directory. The triad, at runbook quality. Detection: sweep the trusted names against the pre-swap baseline and hunt backup-name strays; convict on the hash mismatch and the inode break, and prove the .bak is the real utility renamed aside. Mitigation: capture evidence first, then restore the real bytes by renaming the backup home and quarantining the impostor. Prevention: mount the trusted directory read-only so the next rename fails at the syscall, and keep the baseline where the attacker cannot rewrite it.
Sweep one hashes every trusted name against the baseline: FAILED, rc=1. Sweep two lists backup-name strays next to trusted names: remotedebug.bak. stat gives the tell in numbers: the trusted path's inode changed, its size changed. Then the exoneration that completes the conviction: the .bak's hash matches the pre-swap baseline exactly. The real utility was never modified; it was moved aside. The attacker needed the name, not the bytes.
$ cd /tmp/gh029/lab/bin echo '--- sweep 1: hash every trusted name against the pre-swap baseline' sha256sum -c baseline.sha256; echo "rc=$?" echo '--- sweep 2: strays wearing backup names next to trusted names' ls *.bak *.old *.orig 2>/dev/null echo '--- the tell, in numbers:' stat -c '%n inode=%i size=%s' remotedebug remotedebug.bak echo '--- the .bak is the real utility, only renamed:' cut -d' ' -f1 baseline.sha256 > /tmp/gh029/want.hash sha256sum remotedebug.bak | cut -d' ' -f1 > /tmp/gh029/bak.hash diff /tmp/gh029/want.hash /tmp/gh029/bak.hash && echo 'MATCH: the trusted bytes survived under a backup name' --- sweep 1: hash every trusted name against the pre-swap baseline remotedebug: FAILED sha256sum: WARNING: 1 computed checksum did NOT match rc=1 --- sweep 2: strays wearing backup names next to trusted names remotedebug.bak --- the tell, in numbers: remotedebug inode=8 size=135 remotedebug.bak inode=5 size=166 --- the .bak is the real utility, only renamed: MATCH: the trusted bytes survived under a backup name
Evidence before action: both files copied with cp -a, stat and sha256 outputs timestamped into evidence/. Then the restore, which is the attack in reverse: the impostor moves to remotedebug.quarantined, the .bak moves home to remotedebug, the original inode restored. sha256sum -c answers OK. ./remotedebug prints the real utility's two lines, no canary: the bytes match the baseline and the behavior matches the source.
$ cd /tmp/gh029/lab/bin TS=$(date -u +%Y%m%dT%H%M%SZ) mkdir -p /tmp/gh029/evidence cp -a remotedebug remotedebug.bak /tmp/gh029/evidence/ stat -c '%n inode=%i size=%s mtime=%y' remotedebug remotedebug.bak > /tmp/gh029/evidence/stat-$TS.txt sha256sum remotedebug remotedebug.bak > /tmp/gh029/evidence/sha256-$TS.txt echo '--- evidence captured:'; ls /tmp/gh029/evidence mv remotedebug remotedebug.quarantined mv remotedebug.bak remotedebug sha256sum -c baseline.sha256 ./remotedebug --- evidence captured: remotedebug sha256-20261005T121046Z.txt remotedebug.bak stat-20261005T121046Z.txt remotedebug: OK remotedebug: dumping device state device: OK
Prevention here is mechanical: rename(2) needs write permission on the containing directory. mount --bind the trusted directory onto itself, then remount read-only. One subtlety, kept honest because it bites in real response work: the shell's working directory was entered before the bind, so it still resolves relative paths through the pre-bind writable instance, and a relative mv from there silently bypasses the read-only mount. The step re-enters the path with cd so the rename resolves through the new read-only mount, and then the attacker's replayed mv fails with Read-only file system, rc=1. The control remounts read-write and the rename succeeds, proving the ro mount was the blocker; cd /tmp steps out (umount refuses while the cwd is inside), and umount releases the bind. The packaged-utility anchor, read-only: dpkg -V coreutils verifies every packaged byte against the dpkg database, and empty output means nothing the OS shipped was renamed or modified. That covers /usr/bin; the baseline covers the vendor tools dpkg never knew.
$ cd /tmp/gh029/lab/bin echo '--- durable control: the trusted directory, mounted read-only' mount --bind /tmp/gh029/lab/bin /tmp/gh029/lab/bin mount -o remount,ro,bind /tmp/gh029/lab/bin cd /tmp/gh029/lab/bin echo '--- the attacker replays the rename:' mv remotedebug remotedebug.bak 2>&1; echo "rc=$?" echo '--- control: remount read-write, the rename works, so the ro mount was the blocker' mount -o remount,rw,bind /tmp/gh029/lab/bin mv remotedebug remotedebug.bak && mv remotedebug.bak remotedebug && echo 'control: rename works again under rw' cd /tmp umount /tmp/gh029/lab/bin echo '--- the packaged-utility anchor, read-only:' dpkg -V coreutils | head -3 echo '(no output above: every packaged coreutils byte still matches the dpkg database)' --- durable control: the trusted directory, mounted read-only --- the attacker replays the rename: mv: cannot move 'remotedebug' to 'remotedebug.bak': Read-only file system rc=1 --- control: remount read-write, the rename works, so the ro mount was the blocker control: rename works again under rw --- the packaged-utility anchor, read-only: (no output above: every packaged coreutils byte still matches the dpkg database)
The same sweep, after remediation: sha256sum -c passes, SWEEP CLEAN, no backup-name strays. The monitor is the detector on a timer. rm -rf /tmp/gh029 removes the lab; the namespace's death reaps every stray.
$ cd /tmp/gh029/lab/bin echo '--- the scheduled sweep, after remediation:' sha256sum -c baseline.sha256 && echo 'SWEEP CLEAN: every trusted name wears its own bytes' ls *.bak 2>/dev/null || echo 'no backup-name strays' cd /tmp && rm -rf /tmp/gh029 echo 'lab removed; the namespace dies with every stray' --- the scheduled sweep, after remediation: remotedebug: OK SWEEP CLEAN: every trusted name wears its own bytes no backup-name strays lab removed; the namespace dies with every stray
The baseline convicted the impostor before anything was moved: FAILED against the pre-swap hash, the inode break, the .bak stray. The .bak's hash proved the real bytes survived, the restore returned them exactly, and the read-only mount made the replayed rename fail at the syscall.
Three moves, in order: restore the real bytes, sweep for the next swap, make the rename fail. Each is one way, not the way.
The order is the procedure: copy both files with cp -a before touching anything, save stat and sha256 with timestamps, then move the impostor to a quarantine name and rename the backup home. Restore by rename, not by copy: the rename returns the original inode, and the re-verified hash proves the bytes. If the impostor is running, end the process by exact PID first; restoring the file does not evict a running impostor, and the next scheduled run of the tool would re-launch the attacker's bytes. The blue take ran this order: evidence/ first, quarantine second, restore third, re-verify fourth.
$ mv remotedebug remotedebug.quarantined mv remotedebug.bak remotedebug sha256sum -c baseline.sha256 remotedebug: OK
Honest limit. The restore returns the bytes; it does not scope the incident. If the impostor ran, its effects live outside the file: check what the tool did while wearing the uniform (its logs, its child processes, its network), because the file was the disguise, not the damage. And the quarantine name must not be executable from any PATH: a quarantined impostor that can still be executed is a relocated implant, not a contained one.
The fleet form of the blue hunt: every trusted path hashed against its baseline, every tool directory listed for backup-name strays. Two loops, no agent. Wire the nonzero exit to the alert: rc=1 on the hash check is the page, not a log line.
$ sha256sum -c baseline.sha256; echo "rc=$?" ls *.bak *.old *.orig 2>/dev/null remotedebug: FAILED sha256sum: WARNING: 1 computed checksum did NOT match rc=1 remotedebug.bak
Run it across the fleet and you have the whole monitor; production versions add alerting, not new ideas.
Honest limit. The sweep only covers paths someone baselined. A rename in a directory nobody inventoried is invisible to it, which is why the baseline list itself is the asset: enumerate the trusted tool paths first, then hash them. The baseline must predate the compromise and live where the attacker cannot rewrite it: a read-only share, an append-only store, offline media. A baseline the attacker can edit is the attacker's alibi, and the sweep will bless the impostor with a straight face. Timestamps help but do not replace hashes: mtime is one touch command away from lying.
rename(2) needs write permission on the containing directory, so take it away: mount --bind the tool directory onto itself and remount read-only. Legitimate updates go through a remount window, which doubles as the audit point: every window is logged, every change re-baselined before the mount goes read-only again. For packaged utilities, dpkg -V (rpm -V on RPM systems) is the standing verifier against the package database. On the enterprise side, an audit watch (auditctl -w on the tool directory, -p wa) logs every rename at the syscall: the detective complement to the ro mount's preventive block.
$ mount --bind /tmp/gh029/lab/bin /tmp/gh029/lab/bin mount -o remount,ro,bind /tmp/gh029/lab/bin cd /tmp/gh029/lab/bin mv remotedebug remotedebug.bak 2>&1; echo "rc=$?" mv: cannot move 'remotedebug' to 'remotedebug.bak': Read-only file system rc=1
Honest limit. The ro mount needs privilege to set up, and it taxes operations: every legitimate patch needs a remount window, and a forgotten window is an outage. It does not stop an attacker who already holds the privilege to remount; at that point the directory's permissions are not your problem anymore. Watch the mount-instance subtlety from the blue take: a shell whose working directory predates the bind still resolves through the writable instance, so responders must re-enter the path before trusting the block. Audit watches have the mirror limit: they log the rename faithfully and prevent nothing, and on a busy build host the log volume needs its own pipeline. Neither control protects the trust decision itself: if the baseline lives on storage the attacker can rewrite, the sweep passes the impostor.
The evidence-first restore returned the exact pre-swap bytes. The sweep convicts the next swap on a timer. The read-only mount makes the rename fail at the syscall. None of it trusts the name; all of it reads the bytes.
A filename is a claim the kernel never verifies: execve runs bytes, not names, so verify trusted tools by hash against a pre-compromise baseline, and treat a backup-name stray next to a trusted name as the rename it is.
IOC checklist: signs this technique was used
Reproducibility checklist
Sources
MITRE ATT&CK T1036.003: Masquerading: Rename System Utilities (procedure examples: PHASEJAM S9014, APT38 G0082, menuPass G0045)
rename(2) (the syscall behind the swap)
sha256sum(1) (the byte-level check)
stat(1) (inode, size, and times)
mount(8) (bind mounts and the read-only remount)
The next file hides a filesystem in plain sight and asks what the listing is not showing.