GH-020 T1564.014 PHASE RED INSIDE

The Invisible Ink

Every Linux file carries a second namespace the default tools never list: extended attributes, name:value pairs glued to the inode, outside the file's bytes. This file plants a benign canary in one xattr and watches five standard inspections come back clean, then the defense asks the second namespace directly, sweeps the whole tree with one command, captures evidence before stripping the xattr, and installs the baseline diff that flags the next plant.

TechniqueExtended Attributes (T1564.014)
Target OSUbuntu 24.04.5 LTS
Toolchainattr 2.5 (setfattr/getfattr)
LevelBeginner
Time20 min

OBJECTIVES

  1. Plant a benign canary in a file's extended attributes and confirm that ls, cat, file, stat, and grep all report the file clean
  2. Reveal the xattr with getfattr, sweep the whole tree with one find one-liner, capture evidence, and strip the xattr
  3. Install the xattr baseline diff as the durable control, and state every control's bypass honestly
  4. Take the IOC checklist and the one-sentence lesson
01

Intel Brief

CONTEXT

MITRE ATT&CK T1564.014: adversaries hide artifacts in extended file attributes, a parallel namespace the standard inventory never reads. This file plants a benign canary string in one xattr on an innocent report, watches ls, cat, file, stat, and grep all come back clean, and retrieves the canary in one command. Then the defense: ask the xattr list directly, sweep the whole tree with one find one-liner, capture evidence before stripping, and install the baseline diff that flags the next plant. Two actors: the attacker, who owns setfattr and the planted user.dead-drop; and the defender, who owns the getfattr reads, the tree sweep, the evidence-first strip, and the baseline in the blue phase.

Why this technique. Every inspection tool enumerates two things: directory entries and byte streams. ls reads the directory; cat, grep, strings, and file read the bytes. Extended attributes are a third place: name:value metadata attached to the inode, stored outside the file's bytes, and no default tool lists them. An attacker who needs a small string on disk, a token, a marker, a dead-drop address, can store it where the inventory never looks. The hiding place is not a tool bug; it is storage the default tools were never written to enumerate.

Why not hide the string in the file body. The obvious alternative is the naive plant: append the canary to report.txt. Break it on the concrete input: cat prints the canary in plain sight, grep -r finds it, strings and every content scan read the body. The recording shows the measurement: after the append, cat prints GHOSTLIGHT-CANARY-020 as the fourth line of the report. The file body is the first place anyone looks; hiding data in the bytes fails against every content scan ever written.

Why not a dotfile. The next obvious alternative is .cache, the hidden-file dodge. Break it: ls -a lists it, find inventories it. Directory entries are always inventoried; the leading dot only hides the name from the laziest listing. The recording shows it: ls -a names .cache immediately. Both obvious hiding places die to the default tools, on the concrete inputs, in the recording.

The mechanism, in one line. An extended attribute (xattr) is a name:value metadata pair attached to a file's inode, the filesystem's per-file record, and stored outside the file's byte stream: the size, the owner, the timestamps, and the xattr list all hang off the inode, but only the bytes are what cat reads. The xattr namespace is the prefix before the dot: user., trusted., security., system. user.* is the unprivileged one, any file owner may set it; trusted.* needs privilege; security.* belongs to the Linux security modules (SELinux labels live there). setfattr writes an xattr; getfattr reads xattrs back. The xattr fixes exactly the failure both alternatives share: the bytes and the directory entry are the two things default tools enumerate, and the xattr is neither. Terms earned, no borrowing.

The concrete case, before the abstraction. In /tmp/gh020: report.txt, 52 bytes, a three-line capacity report. setfattr -n user.dead-drop -v GHOSTLIGHT-CANARY-020 report.txt: silent success. ls -l: still 52 bytes, the xattr adds zero bytes to the stream. cat: clean. file: ASCII text. stat -c '%s bytes': 52 bytes. grep -r CANARY .: no match. getfattr -n user.dead-drop --only-values report.txt: GHOSTLIGHT-CANARY-020. Stored, retrievable, invisible to the five standard reads. That gap, between what is stored and what the tools enumerate, is the whole technique.

Scope. T1564 covers hiding artifacts broadly: hidden files and directories, hidden users, extended attributes, alternate data streams on Windows. This file works the extended-attribute case end to end: the plant, the five-tool stealth sweep, the getfattr reveal, the tree sweep, the evidence-first strip, and the baseline diff. The canary is a benign token: it proves storage and retrieval and touches nothing else. The lab runs in a disposable namespace under /tmp because the blue phase plants and strips xattrs for real.

02

Target Environment

LOADOUT

Ubuntu 24.04.5 LTS, x86-64, in a disposable namespace used only for this lab. Runs as root: the lab plants its own xattrs, and every blue-phase read targets the live lab. Everything the lab touches lives inside /tmp/gh020, so cleanup is a single rm. The attr tools, setfattr and getfattr, ship in the attr package.

1

Build the lab

One disposable directory, built from scratch. printf writes the decoy report and the field notes (%% is printf's escape for a literal percent sign, which is why the file holds 61%); cp keeps a pristine copy of the report for the broken-alternative demos; the heredoc writes xattr-baseline.sh, the defender's snapshot tool, staged now and used in the blue phase; chmod +x makes it executable; ls -l shows the lab. The baseline script is shown in full, each line glossed after it.

xattr-baseline.sh
#!/bin/bash
# snapshot every xattr on every file under the watched tree, sorted
find . -type f -exec getfattr -d -m . {} + 2>/dev/null | grep -v '^$' | sort > "$1"

xattr-baseline.sh, the defender's snapshot tool, in full: find . -type f walks every regular file under the watched tree; getfattr -d -m . dumps every xattr on each file, -d for dump, -m . to match every xattr name, and files with no xattrs print nothing, so they contribute no lines; grep -v '^$' drops the blank separator lines getfattr prints between files; sort orders the snapshot so the diff is stable run to run; the snapshot lands in the file named by $1. Two snapshots and a diff flag any new xattr.

03

Phase Red: write in the second namespace

ATTACK

The attacker plants a canary in the file's second namespace, watches five standard inspections come back clean, and retrieves the canary in one command.

Real screen recording 98.3s
What you are watching: A canary is planted in a file's extended attributes. Five standard inspections report the file clean; one getfattr reads the canary back. Every command below is copy-pasteable.
1

Build the lab

rm -rf /tmp/gh020 starts clean; mkdir -p and cd set up the lab directory. printf writes report.txt, the three-line decoy, and notes.txt; cp keeps report.pristine; the heredoc writes xattr-baseline.sh; chmod +x; ls -l shows the lab. Everything the page shows is built here.

bash
$ rm -rf /tmp/gh020; mkdir -p /tmp/gh020; cd /tmp/gh020
printf 'Q3 capacity report\nRegion: us-east\nUtilization: 61%%\n' > report.txt
printf 'field notes\n' > notes.txt
cp report.txt report.pristine
cat > xattr-baseline.sh <<'EOF'
#!/bin/bash
# snapshot every xattr on every file under the watched tree, sorted
find . -type f -exec getfattr -d -m . {} + 2>/dev/null | grep -v '^$' | sort > "$1"
EOF
chmod +x xattr-baseline.sh
ls -l
total 16
-rw-rw---- 1 root root  12 Sep 24 15:19 notes.txt
-rw-rw---- 1 root root  52 Sep 24 15:19 report.pristine
-rw-rw---- 1 root root  52 Sep 24 15:19 report.txt
-rwxrwx--- 1 root root 164 Sep 24 15:19 xattr-baseline.sh
2

The obvious alternative, broken: the file body

echo 'GHOSTLIGHT-CANARY-020' >> report.txt appends the canary to the file body. cat report.txt prints it in plain sight, fourth line. The file body is the first place anyone looks; hiding data in the bytes fails against every content scan ever written.

bash
$ echo 'GHOSTLIGHT-CANARY-020' >> report.txt
cat report.txt
Q3 capacity report
Region: us-east
Utilization: 61%
GHOSTLIGHT-CANARY-020
3

The second obvious alternative, broken: the dotfile

cp report.pristine report.txt && rm report.pristine restores the clean report and removes the spare copy. echo 'GHOSTLIGHT-CANARY-020' > .cache writes the canary to a dotfile. ls -a lists it immediately: the leading dot only hides the name from the laziest listing. rm .cache removes it. Directory entries are inventoried; both obvious hiding places die to the default tools.

bash
$ cp report.pristine report.txt && rm report.pristine
echo 'GHOSTLIGHT-CANARY-020' > .cache
ls -a
rm .cache
.  ..  .cache  notes.txt  report.txt  xattr-baseline.sh
4

The attack: plant the xattr

setfattr -n user.dead-drop -v GHOSTLIGHT-CANARY-020 report.txt: -n names the attribute, -v sets the value, and the unprivileged user.* namespace needs no special privilege. Silent success: the command prints nothing. The echo line is the attacker's own note: one xattr planted, zero byte changes.

bash
$ setfattr -n user.dead-drop -v GHOSTLIGHT-CANARY-020 report.txt
echo 'planted: one xattr, zero byte changes'
planted: one xattr, zero byte changes
5

The stealth sweep: five tools, five clean answers

ls -l: still 52 bytes, the xattr adds nothing to the stream. cat: clean. file: ASCII text. stat -c '%s bytes': 52 bytes. grep -r CANARY .: no match, and the fallback echo confirms it. Five independent standard inspections, all blind: none of them queries the xattr list.

bash
$ ls -l report.txt
cat report.txt
file report.txt
stat -c '%s bytes' report.txt
grep -r CANARY . || echo 'grep: no match anywhere under .'
-rw-rw---- 1 root root 52 Sep 24 15:19 report.txt
Q3 capacity report
Region: us-east
Utilization: 61%
report.txt: ASCII text
52 bytes
grep: no match anywhere under .
6

The round trip: the attacker's retrieval

getfattr -n user.dead-drop --only-values report.txt prints the canary. The data is really stored; the standard tools just never ask the second namespace. Whoever knows to ask gets the value in one command.

bash
$ getfattr -n user.dead-drop --only-values report.txt
GHOSTLIGHT-CANARY-020
7

Stealth confirmed

One echo line, the attacker's summary: the canary is stored, and no standard tool sees it. The listing and the bytes are the wrong evidence to read, which is exactly what the blue phase exploits.

bash
$ echo 'stealth confirmed: the canary is stored, and no standard tool sees it'
stealth confirmed: the canary is stored, and no standard tool sees it
Stealth confirmed

The canary was planted in user.dead-drop with setfattr; ls, cat, file, stat, and grep all reported the file clean; getfattr retrieved the canary in one command. The attack works because every standard inspection enumerates the directory entry or the byte stream, and the xattr is neither.

04

Phase Blue: ask the second namespace

DEFENSE

The defender does not trust the listing. The defender asks the xattr list directly, sweeps the whole tree with one command, captures evidence before stripping, and installs the baseline that flags the next plant.

Here is the trap: running ls -la, reading the file, finding nothing, and concluding the box is clean. That is trusting the directory entry and the byte stream the attacker just bypassed. The detection starts by asking the namespace the listing never checks.

Real screen recording 71.3s
What you are watching: The defender reveals the planted xattr with getfattr, sweeps the whole tree with one command, captures evidence before stripping, and installs the baseline diff that flags the next plant. Every command below is copy-pasteable.
1

DETECTION: the naive view

cd /tmp/gh020, then ls -la: a clean lab, four files, nothing hidden. cat report.txt: a clean report. Stopping here is the attacker's win: the listing was never checking the xattr list, so a clean listing proves nothing.

bash
$ cd /tmp/gh020 && ls -la
cat report.txt
total 12
drwxrwx--- 2 root root 100 Sep 24 15:19 .
drwxrwxrwt 3 root root  60 Sep 24 15:19 ..
-rw-rw---- 1 root root  12 Sep 24 15:19 notes.txt
-rw-rw---- 1 root root  52 Sep 24 15:19 report.txt
-rwxrwx--- 1 root root 164 Sep 24 15:19 xattr-baseline.sh
Q3 capacity report
Region: us-east
Utilization: 61%
2

DETECTION: ask the second namespace

getfattr -d -m . report.txt: -d dumps, -m . matches every xattr name, so no prior knowledge of the xattr name is needed. The reveal: user.dead-drop="GHOSTLIGHT-CANARY-020". One command, asked of the right namespace.

bash
$ getfattr -d -m . report.txt
# file: report.txt
user.dead-drop="GHOSTLIGHT-CANARY-020"
3

DETECTION: the tree sweep, the runbook one-liner

find . -type f -exec getfattr -d -m . {} +: every regular file under the tree, dumped. getfattr prints nothing for files with no xattrs, so the output lists only files that carry xattrs, with their values. One command, the whole tree. The tell, concrete: good is a file carrying no user.* xattr, or one the deployment put there on purpose; bad is a file carrying a user.* xattr it should not have.

bash
$ find . -type f -exec getfattr -d -m . {} +
# file: ./report.txt
user.dead-drop="GHOSTLIGHT-CANARY-020"
4

DETECTION: the audit question

command -v auditctl || echo 'no auditd in this lab': the honest check first. Real output: no auditd in this lab. The rule for a real host is stated with its dependency, not demonstrated: auditctl -a always,exit -F arch=b64 -S setxattr -S lsetxattr -S fsetxattr -k xattr-write logs every xattr write, but it needs the audit subsystem enabled, and this lab, like many containers, lacks it. Where auditd runs, the good-versus-bad is concrete: good is a setxattr log line from a known deployment tool; bad is a setxattr from an unknown process on a user file.

bash
$ command -v auditctl || echo 'no auditd in this lab'
no auditd in this lab
5

MITIGATION: evidence first, then strip

getfattr --dump report.txt > evidence.txt captures the payload BEFORE the strip, because stripping destroys it; cat evidence.txt confirms the capture. setfattr -x user.dead-drop report.txt removes the xattr: the data lived only in the xattr, so removing the xattr removes the data. Verify: getfattr -d -m . report.txt prints nothing, and the tree sweep prints nothing. Scope: the sweep covered the whole tree, not just the known file.

bash
$ getfattr --dump report.txt > evidence.txt
cat evidence.txt
setfattr -x user.dead-drop report.txt
echo '--- after strip ---'
getfattr -d -m . report.txt
find . -type f -exec getfattr -d -m . {} +
# file: report.txt
user.dead-drop="GHOSTLIGHT-CANARY-020"

--- after strip ---
6

PREVENTION: the baseline diff, demonstrated live

The durable control: ./xattr-baseline.sh baseline.txt snapshots the cleaned tree; setfattr -n user.note -v GHOSTLIGHT-CANARY-020-B notes.txt plants a NEW canary on a different file; ./xattr-baseline.sh current.txt; diff baseline.txt current.txt flags notes.txt and names the xattr. Demonstrated live, against this lab: the next plant is caught by the diff. Honest limit, stated now and repeated in the countermeasures: the baseline must be taken on a known-clean tree and kept off the watched tree in production; the poll interval sets the detection floor; this watches the xattr hiding place, not the other T1564 variants.

bash
$ ./xattr-baseline.sh baseline.txt
setfattr -n user.note -v GHOSTLIGHT-CANARY-020-B notes.txt
./xattr-baseline.sh current.txt
diff baseline.txt current.txt
0a1,2
> # file: ./notes.txt
> user.note="GHOSTLIGHT-CANARY-020-B"
7

Verdict and cleanup

The summary, in the defender's own words: the xattr was found by asking the second namespace, stripped after the evidence was captured, and the baseline diff flags the next plant. rm -rf /tmp/gh020 removes the lab; the echo confirms it is gone.

bash
$ echo 'detection verified: the xattr is found, stripped, and baselined'
cd /tmp && rm -rf /tmp/gh020 && echo 'lab cleaned'
detection verified: the xattr is found, stripped, and baselined
lab cleaned
Detection verified

getfattr revealed the planted xattr with no prior knowledge of its name; the one-line tree sweep listed every xattr-carrying file in the tree; evidence was captured before the strip; the post-strip sweep came back clean; the baseline diff flagged a newly planted canary on a different file. The listing and the bytes still say nothing. The second namespace does not agree.

05

Countermeasures

DEFENSE

Three moves, in order: strip with evidence first, sweep on a schedule, baseline the xattr list. Each is one way, not the way.

1

Mitigate: capture, strip, re-sweep

Proven first against the live plant: getfattr --dump captures the payload into evidence.txt BEFORE the strip; setfattr -x removes the xattr, and with it the data, which lived only there; the per-file read and the tree sweep both confirm clean. A real response then hunts the delivery vector: how the xattr got set on the box is the incident's open question.

bash
$ getfattr --dump report.txt > evidence.txt
cat evidence.txt
setfattr -x user.dead-drop report.txt
echo '--- after strip ---'
getfattr -d -m . report.txt
find . -type f -exec getfattr -d -m . {} +
# file: report.txt
user.dead-drop="GHOSTLIGHT-CANARY-020"

--- after strip ---

Honest limit. Stripping destroys the payload, which is why the dump comes first; a response that strips before capturing has destroyed its own evidence. setfattr -x needs write permission on the file (ownership or root). The lab moves on after the strip for cleanliness; a real incident preserves evidence.txt and the original file for forensics instead.

2

Monitor: sweep the tree on a schedule

The scheduled form of the phase-blue read: the find/getfattr one-liner walks the watched tree, and the tell is any file carrying a user.* xattr it should not have. Plus the auditd setxattr rule, stated with its dependency: it needs the audit subsystem enabled, which this lab and many containers lack. D3FEND D3-FIM: File Integrity Monitoring is the production form of the baseline. Honest note: default FIM and hash configs cover file bytes only; the config must explicitly include xattrs, because a hash of the bytes never sees them.

bash
$ find . -type f -exec getfattr -d -m . {} +
# file: ./report.txt
user.dead-drop="GHOSTLIGHT-CANARY-020"

Honest limit. The sweep trusts the kernel to list xattrs honestly; a kernel-level rootkit can lie to getfattr, the GH-002 precedent, so this is one observation path, not the only one. The poll interval sets the detection floor: a plant that lands and is stripped between sweeps leaves no xattr behind, only the audit log, if auditd was watching. And the sweep watches the xattr hiding place, not the other T1564 variants.

3

Prevent: the baseline diff as a control

The demonstrated control: xattr-baseline.sh snapshots the xattr list of the whole tree, and the diff against the known-clean snapshot flags any new xattr, naming the file and the attribute. Run on a schedule, the next plant is caught by the diff, as the blue phase proved against this lab.

bash
$ ./xattr-baseline.sh baseline.txt
setfattr -n user.note -v GHOSTLIGHT-CANARY-020-B notes.txt
./xattr-baseline.sh current.txt
diff baseline.txt current.txt
0a1,2
> # file: ./notes.txt
> user.note="GHOSTLIGHT-CANARY-020-B"

Honest limit. The baseline must be taken on a known-clean tree: a snapshot of a dirty tree bakes the attacker's xattrs into "clean". Production copies of the baseline live off the watched tree, where the attacker cannot rewrite them. And the diff catches the xattr variant only; hidden files, hidden users, and the other T1564 hiding places need their own watches.

Countermeasures verified

The payload was captured before the strip, the strip removed the data with the xattr, the tree sweep confirmed clean; the scheduled sweep names its tell; the baseline diff flagged a newly planted canary on a different file. Every control names its bypass: the sweep trusts the kernel, the poll interval sets the floor, the baseline needs a known-clean start, and default FIM configs miss xattrs unless told to look.

06

Debrief

TAKEAWAY

When the listing and the bytes both say clean, ask the inode's second namespace: the xattr list is storage the default tools never inventory.

IOC checklist: signs this technique was used

  • A file carrying a user.* extended attribute it should not have, especially names that read like dead drops
  • setxattr syscalls from unknown processes (the auditd xattr-write key), on hosts where the audit subsystem is enabled
  • Baseline diffs flagging new xattrs on previously clean files
  • Xattr values holding tokens, URLs, or encoded blobs on ordinary documents
  • No xattr checks in the existing playbooks: the absence of the question is itself the gap

Reproducibility checklist

  • Verified on Ubuntu 24.04.5 LTS, x86-64, on 2026-09-24
  • Both recordings are real executions on that platform, not simulations
  • Runs as root in a disposable namespace (the lab plants its own canary; the assumed breach: something on the box set the xattr)
  • Cleanup: rm -rf /tmp/gh020; verify with ls /tmp

Sources

Next file

GH-021 The False Testimony

The next file forges its own argument vector and ps testifies it is ssh-agent.