Two files sit in this directory. The listing shows one name. One space, invisible at the end of a line, is the whole difference between them, and the defense is to stop reading names with eyes and start measuring them byte by byte.
MITRE ATT&CK T1036.006: adversaries add a space to the end of a filename, so the deceptive name renders identically to the real one in listings and defeats exact-match checks. This file plants "report.txt " beside the real report.txt, watches a plain ls read them as one name, watches a routine cat confirm the real file and miss the impostor, then measures the names byte by byte until the second file has nowhere left to hide. Two actors: the attacker, who owns the deceptive name and the planted content; and the defender, who owns every read, hunt, quarantine, and gate in the blue phases.
Why this technique. A filename is a byte string, but nobody reads bytes: operators read the listing, and the listing renders the bytes for human eyes. A space at the end of a line is the one byte that renders as nothing. Two different byte strings, report.txt and "report.txt ", produce one visible name, so the operator counting files by eye counts one. The hiding place is not a tool bug; it is the gap between the bytes the system stores and the picture the listing paints.
Why not just trust ls. The obvious alternative is the plain listing: run ls -1, read the names, move on. Break it on the concrete input from this file: ls prints report.txt and 'report.txt '. Modern ls quotes the trailing blank, so the tell is technically on screen: two single-quote characters. The eye still reads one name twice, because quotes are typography and the operator came to read names. The listing was never checking the bytes, so a listing that looks clean proves nothing. That is the failure the byte-exact checks below are built to fix.
The mechanism, in one line. A filename is the exact byte string the filesystem stores in the directory entry. The displayed name is what ls renders from those bytes, and rendering is lossy: trailing blanks collapse into nothing visible. ls -b prints non-graphic and trailing characters as backslash escapes, so the invisible byte becomes the visible two characters \ . find -name '* ' matches the stored bytes exactly, with no rendering at all. The inode is the file itself: two directory entries with two different byte strings point at two different inodes, no matter how alike they render.
The concrete case, before the abstraction. In /tmp/gh024: report.txt, 61 bytes of quarterly figures; and "report.txt ", 66 bytes, holding GHOSTLIGHT-CANARY-024. ls -1 prints two lines the eye reads as one name. cat report.txt prints the real figures. ls -b prints report.txt\ : the escaped space. find . -name '* ' prints [./report.txt ]: the exact bytes, bracketed so the space shows. The two sha256sum hashes differ. Same-looking name, two files, two contents.
Terms, earned. The trailing space is the literal 0x20 byte at the end of the filename, the whole payload. A byte-exact check compares the stored bytes, never the rendered picture. Quoting is ls wrapping an odd name in single quotes; it marks the name as unusual without saying why. Quarantine is moving the suspect file aside with its evidence, not deleting it.
Scope. T1036 covers masquerading broadly: matched names or locations, right-to-left override, fake icons, double extensions, faked magic bytes. This file works the space-after-filename case end to end: the plant, the listing deception, the routine read that misses, the byte-exact reveal, the evidence-first quarantine, and the deploy gate. The canary is a benign token: it proves which file got read and touches nothing else. The lab runs in a disposable namespace under /tmp because the blue phase plants, quarantines, and sweeps for real.
Ubuntu 24.04.5 LTS, x86-64, in a disposable namespace used only for this lab. Runs as root: the lab plants its own files, and every blue-phase read targets the live lab. Everything the lab touches lives inside /tmp/gh024, so cleanup is a single rm. No compiler, no packages: the whole technique is one byte in a filename, so the toolchain is coreutils and bash.
The recording starts from an empty private /tmp inside its own mount namespace, so every take begins identical. rm -rf /tmp/gh024 starts clean; mkdir -p and cd set up the lab directory. The two printf lines below write the real report and the impostor; ls -l shows the lab. The attacker needs no privilege: any user who can write to a directory can plant a trailing-space twin of any file in it.
The whole attack is the second line's quoted filename. printf writes the three-line quarterly report into report.txt; the second printf writes the canary into "report.txt ", the quotes protecting the trailing space from the shell. \n is printf's newline escape. The only difference between the two files is one 0x20 byte in the name, and the file contents differ too, so the hash measurement later has something real to catch.
printf 'Q3 revenue: $1.4M (draft)\nReviewed by: finance\nStatus: final\n' > report.txt printf 'GHOSTLIGHT-CANARY-024\nDo not trust this file. It is the impostor.\n' > "report.txt "
The attacker plants the twin, watches the listing read two files as one name, and lets the operator's routine read confirm the real file and walk away satisfied, the impostor untouched.
rm -rf /tmp/gh024 starts clean; mkdir -p and cd set up the lab. The two printf lines write the real report and the impostor; the quotes around "report.txt " protect the trailing space. ls -l shows the lab: two rows, 61 and 66 bytes, with near-identical names. The size difference is already a lead, if anyone is reading closely.
$ rm -rf /tmp/gh024; mkdir -p /tmp/gh024; cd /tmp/gh024 printf 'Q3 revenue: $1.4M (draft)\nReviewed by: finance\nStatus: final\n' > report.txt printf 'GHOSTLIGHT-CANARY-024\nDo not trust this file. It is the impostor.\n' > "report.txt " ls -l total 8 -rw-rw---- 1 root root 61 Sep 26 12:21 report.txt -rw-rw---- 1 root root 66 Sep 26 12:21 'report.txt '
ls -1: two lines. The second is wrapped in single quotes, the only mark ls puts on the trailing blank, and the eye reads one name twice. This is the concrete breakage of the trust-ls alternative from the intel brief: the tell is on screen and still missed.
$ ls -1 report.txt 'report.txt '
cat report.txt prints the legitimate quarterly figures. The operator asked for the report, got the report, and concludes all is well. The shell resolved the bare name to the real file; the impostor was never opened, never hashed, never counted. This is the moment the technique wins: not by hiding from the read, but by making the read unnecessary.
$ cat report.txt Q3 revenue: $1.4M (draft) Reviewed by: finance Status: final
ls -b prints trailing blanks as backslash escapes: report.txt\ . The invisible byte is now two visible characters. No new tool, no new privilege, just the flag that refuses to render.
$ ls -b report.txt report.txt\
find . -name '* ' matches the stored bytes exactly, no rendering involved; -printf '[%p]\n' brackets the path so the trailing space shows inside the brackets: [./report.txt ]. This is the runbook form: match bytes, display bytes.
$ find . -name '* ' -printf '[%p]\n' [./report.txt ]
sha256sum over both files: the hashes differ (5f9d2f49... vs 87247e7c...), while the displayed names look the same. cat "report.txt " prints the impostor's content: GHOSTLIGHT-CANARY-024, the benign token proving which file was read. One visible name, two files, two contents: the measurement says what the listing could not.
$ sha256sum report.txt "report.txt " cat "report.txt " echo 'stealth confirmed: one visible name, two files' 5f9d2f49eaf615aae8472078e78da19c3850b28d590337eeed7927d1059b4869 report.txt 87247e7c7e4bb7c6a1415fc14f53146b6ed3ab3703491cd38781e9923d4686df report.txt GHOSTLIGHT-CANARY-024 Do not trust this file. It is the impostor. stealth confirmed: one visible name, two files
One trailing space made two files read as one name. The plain listing showed the quotes and the eye skipped them; the routine read confirmed the real file and never touched the impostor; ls -b and the byte-exact find exposed the second file, and the hashes proved the contents differ. The deception lived entirely in one 0x20 byte: no privilege was touched, no byte was hidden.
The defender stops reading names with eyes and starts measuring them byte by byte: the escape, the inode, the hash, the audit log. Then the impostor is quarantined with its evidence preserved, and the gate goes in where files arrive.
Here is the trap: reading the listing, seeing the report, and moving on. That is trusting the rendered picture the attacker chose. The detection starts by asking the stored bytes, which the attacker did not choose.
cd /tmp/gh024 && ls -l: the defender's starting view. Two rows, near-identical names, 61 vs 66 bytes. The size difference is the lead; the quotes around the second name are the mark. Stopping here is the attacker's win: the listing was never checking the bytes, so a quick glance proves nothing.
$ cd /tmp/gh024 && ls -l total 8 -rw-rw---- 1 root root 61 Sep 26 12:21 report.txt -rw-rw---- 1 root root 66 Sep 26 12:21 'report.txt '
ls -b shows the escaped space: report.txt\ . The one-liner find . \( -name '* ' -o -name ' *' \) -printf '[%p]\n' matches leading or trailing spaces in the stored bytes and brackets every hit: [./report.txt ]. One command, the whole tree. The tell, concrete: good is a name whose displayed form equals its stored bytes; bad is a name carrying invisible bytes.
$ ls -b find . \( -name '* ' -o -name ' *' \) -printf '[%p]\n' report.txt report.txt\ [./report.txt ]
ls -li: inodes 3 and 4. Two directory entries, two inodes, two files, whatever the names look like. sha256sum over both: 5f9d2f49... vs 87247e7c..., different contents behind the same-looking name. The name is a label; the inode is the file; the hash is the content. All three get checked, because the technique forges only the first.
$ ls -li sha256sum report.txt "report.txt " total 8 3 -rw-rw---- 1 root root 61 Sep 26 12:21 report.txt 4 -rw-rw---- 1 root root 66 Sep 26 12:21 'report.txt ' 5f9d2f49eaf615aae8472078e78da19c3850b28d590337eeed7927d1059b4869 report.txt 87247e7c7e4bb7c6a1415fc14f53146b6ed3ab3703491cd38781e9923d4686df report.txt
command -v auditctl answers /usr/sbin/auditctl: the audit tools are present in this lab. The rule for a real host is stated with its dependency, not demonstrated: auditctl -a always,exit -F arch=b64 -S openat -k fileopens records the exact path bytes of every file open, trailing space included, but it needs the audit subsystem enabled and its rules loaded. Where it runs, the good-versus-bad is concrete: good is an openat path whose bytes match the displayed name; bad is a path carrying bytes the listing never showed.
$ command -v auditctl || echo 'no auditd in this lab' /usr/sbin/auditctl
mkdir -p evidence quarantine; sha256sum "report.txt " | tee evidence/hash.txt and cp "report.txt " evidence/impostor.txt capture the hash and the bytes BEFORE the move, because quarantine comes next. mv "report.txt " quarantine/ moves the impostor aside; it is not deleted, it is preserved with its original name for forensics. D3FEND calls this D3-CQ: Content Quarantine. Verify: the hunt now returns 1, not 0, because the deceptive name still exists exactly where the defender put it, inside quarantine/; the working tree holds none. cat report.txt confirms the real file is untouched.
$ mkdir -p evidence quarantine sha256sum "report.txt " | tee evidence/hash.txt cp "report.txt " evidence/impostor.txt mv "report.txt " quarantine/ find . -name '* ' -o -name ' *' | wc -l cat report.txt 87247e7c7e4bb7c6a1415fc14f53146b6ed3ab3703491cd38781e9923d4686df report.txt 1 Q3 revenue: $1.4M (draft) Reviewed by: finance Status: final
The heredoc writes gate.sh: find "${1:-.}" searches the target tree, defaulting to the current directory, and the \( -name '* ' -o -name ' *' \) test keeps only names with leading or trailing spaces; any hit prints and exits 1. chmod +x; a fresh impostor "staging/invoice.pdf " is planted; ./gate.sh staging fails with GATE FAIL, demonstrated live; ./gate.sh clean passes. D3FEND calls the policy form D3-CV: Content Validation: verify the name complies before the file lands.
$ cat > gate.sh <<'EOF'
#!/bin/sh
# deploy gate: reject filenames with leading or trailing spaces
bad=$(find "${1:-.}" \( -name '* ' -o -name ' *' \) -printf '[%p]\n')
if [ -n "$bad" ]; then echo 'GATE FAIL: deceptive names:'; echo "$bad"; exit 1; fi
echo 'GATE PASS'
EOF
chmod +x gate.sh
mkdir -p staging clean
printf 'GHOSTLIGHT-CANARY-024\n' > "staging/invoice.pdf "
printf 'ok\n' > clean/notes.txt
./gate.sh staging
./gate.sh clean
GATE FAIL: deceptive names:
[staging/invoice.pdf ]
GATE PASS
command -v aide answers honestly: no AIDE in this lab. The production control is stated with its dependency, not demonstrated: a D3-FIM: File Integrity Monitoring baseline (AIDE, or OSQuery scheduled) records exact filenames, so "report.txt " appears as an unknown new file, never as the known report.txt. It needs a baseline taken before the incident and a scheduled run; the poll interval sets the detection floor.
$ command -v aide || echo 'no aide in this lab: integrity baseline needs a scheduled AIDE or OSQuery run' no aide in this lab: integrity baseline needs a scheduled AIDE or OSQuery run
The summary, in the defender's own words: the name is a claim, the bytes are evidence. rm -rf /tmp/gh024 removes the lab.
$ echo 'detection verified: the name is a claim, the bytes are evidence' cd /tmp && rm -rf /tmp/gh024 && ls /tmp detection verified: the name is a claim, the bytes are evidence
ls -b exposed the escaped space; the byte-exact find bracketed the impostor; ls -li showed two inodes and sha256sum showed two hashes; the impostor was hashed and copied before quarantine, and the working tree verified clean; the deploy gate failed the planted arrival live and passed the clean tree; the integrity baseline is stated with its dependency. The name is a claim; the bytes are evidence.
Three moves, in order: quarantine with evidence first, hunt on a schedule, reject deceptive names where files arrive. Each is one way, not the way.
Proven first against the live twin: sha256sum | tee and cp capture the hash and the bytes into evidence/ BEFORE the move; mv quarantines the impostor with its original name intact for forensics; the re-sweep returns 1 because the deceptive name now lives in quarantine/, and the working tree holds none; cat report.txt proves the real file untouched. A real response then hunts the delivery vector: how the twin arrived is the incident's open question.
$ mkdir -p evidence quarantine sha256sum "report.txt " | tee evidence/hash.txt cp "report.txt " evidence/impostor.txt mv "report.txt " quarantine/ find . -name '* ' -o -name ' *' | wc -l cat report.txt 87247e7c7e4bb7c6a1415fc14f53146b6ed3ab3703491cd38781e9923d4686df report.txt 1 Q3 revenue: $1.4M (draft) Reviewed by: finance Status: final
Honest limit. Quarantine is not understanding arrival: a second twin elsewhere still hides, which is why the hunt covers the whole tree. mv needs write permission on the directory. The lab removes the tree for cleanliness; a real incident preserves evidence/ and quarantine/ for forensics instead of deleting them.
The scheduled form of the phase-blue read: the one-liner runs over arrival, download, and staging trees, and the tell is any name whose stored bytes carry leading or trailing spaces. Plus the openat auditd rule, stated with its dependency: it needs the audit subsystem enabled and its rules loaded, which this lab has (auditctl is present) but many containers lack. The heavier production form is D3FEND D3-FIM: File Integrity Monitoring: an exact-filename baseline that reports the twin as an unknown new file.
$ find . \( -name '* ' -o -name ' *' \) -printf '[%p]\n' [./report.txt ]
Honest limit. The hunt matches ASCII space only; a trailing tab or a non-breaking space slips past, and the poll interval sets the detection floor: a twin that lands and is removed between sweeps leaves no name behind, only the audit log, if auditd was watching. The baseline needs to predate the incident; a baseline taken after the plant bakes the twin in as known-good.
The demonstrated gate detects at arrival time; the durable form is the same test enforced as policy where files land: the deployment pipeline, the upload handler, the mail gateway. D3FEND D3-CV: Content Validation is the policy name for it: verify the name complies before the file is accepted. Honest note, repeated because it matters: the gate rejects deceptive names; only the integrity baseline plus the hash check proves the accepted files are the right ones.
$ cat > gate.sh <<'EOF'
#!/bin/sh
# deploy gate: reject filenames with leading or trailing spaces
bad=$(find "${1:-.}" \( -name '* ' -o -name ' *' \) -printf '[%p]\n')
if [ -n "$bad" ]; then echo 'GATE FAIL: deceptive names:'; echo "$bad"; exit 1; fi
echo 'GATE PASS'
EOF
chmod +x gate.sh
mkdir -p staging clean
printf 'GHOSTLIGHT-CANARY-024\n' > "staging/invoice.pdf "
printf 'ok\n' > clean/notes.txt
./gate.sh staging
./gate.sh clean
GATE FAIL: deceptive names:
[staging/invoice.pdf ]
GATE PASS
Honest limit. The gate as written matches the ASCII space; an attacker who reads the rule switches to a trailing tab, a non-breaking space, or drops the space for a homoglyph, which is T1036.005 territory and a different file's problem. The gate is also a point-in-time check: it says nothing about files that arrive by paths it does not guard. This control raises the cost of the trick; it does not remove the trick. The byte-exact hunt in Phase Blue works regardless of which invisible byte the attacker chose, which is why detection outlives prevention here.
The twin was hashed and copied before quarantine, the quarantine preserved the original name, the working tree verified clean, the scheduled hunt names its tell and its floor, and the deploy gate failed the planted arrival live while passing the clean tree. Every control names its bypass: the hunt sees ASCII spaces only, the poll interval sets the floor, the baseline must predate the plant, and only detection at the byte level outlives the attacker's choice of invisible byte.
The listing shows you what the name looks like; only a byte-exact comparison shows you what the name is.
IOC checklist: signs this technique was used
Reproducibility checklist
Sources
The next file severs a process from its parent and watches where the orphan goes.