GH-015 T1564.013 PHASE RED INSIDE

The False Floor

A stash sits on this box with two files the attacker needs to keep: a payload stand-in and a staging manifest. One bind mount lays an empty directory over the stash, and every path-based tool reports the cover. This file runs that cover, then reads the mount table the attacker hoped nobody would read, lifts the cover, and seizes what was underneath.

TechniqueBind Mounts (T1564.013)
Target OSUbuntu 24.04.5 LTS
Toolchainbash, coreutils, util-linux, libcap2-bin
LevelIntermediate
Time25 min

OBJECTIVES

  1. Lay an empty bind-mount cover over a populated directory and watch ls, find, and du report nothing
  2. Detect the cover from the mount table, record it, lift it, and quarantine what was underneath
  3. Gate bind mounts behind CAP_SYS_ADMIN, inventory the mount table on a schedule, sweep persistence
  4. Take the IOC checklist and the one-sentence lesson
01

Intel Brief

CONTEXT

MITRE ATT&CK T1564.013: adversaries mount an existing directory over a populated path, so path-based tools see the cover while the files sit untouched on disk. This file runs that cover end to end, then shows the table read that sees through it. Two actors: the attacker, who owns the lab directory, the stash files, and the cover mount; and the defender, who owns the mount table reads, the unmount, and every inventory in the blue phase.

Why this technique. The attacker has two needs that fight each other. The files must stay on disk: notes.txt is the staging manifest, and the payload has to remain deployable. And no directory listing may show them: any inventory that lists them burns the stash. Deletion satisfies the second need and fails the first. A bind mount satisfies both. The files are untouched on disk, and the path no longer resolves to them. The cover reverses with one umount, which is the operational point: nothing is destroyed, so nothing is lost if the attacker needs the stash back.

Why not delete the evidence. The obvious alternative is rm: the attacker deletes the files. Break it on the concrete input: the attacker still needs notes.txt, and deletion is one-way. Worse, the bytes stay on disk until they are overwritten: the defender images the disk and runs a carver, and the deleted notes.txt comes back. The bind mount keeps everything intact and reverses with one umount.

Why not hide in the listing. The other obvious alternative is hiding inside the listing: the attacker names the files with leading dots or buries them in deep paths. Break it: the defender runs a recursive find, and the inventory lists the hidden files, because the files are still reachable through the path. The bind mount removes the files from directory listings at the VFS layer: no enumeration can find what the path no longer resolves to.

Why not hook readdir. The third alternative is a readdir hook through LD_PRELOAD: the attacker filters directory listings by preloading a shim into dynamically linked programs. Break it: the hook only affects dynamically linked binaries that honor the variable. The defender runs a statically linked ls, and the hidden files show up in the output. The bind mount is enforced by kernel path resolution for every process and every tool, because the mount table is consulted while the path is resolved.

The mechanism, in one line. A bind mount is mounting an existing directory tree at a second path, so both paths show the same contents: here the empty decoy is mounted at the stash's path, so the stash's path shows the decoy's contents (nothing). The mount table, readable at /proc/mounts and /proc/self/mountinfo, is the kernel's list of what is mounted where: the independent observation path, because listings consult the table during resolution and the table itself cannot be covered by a mount. A mount namespace is each process's own view of the table: mounts made in one namespace are invisible in another, which is why the blue phase enumerates namespaces. VFS path resolution is the kernel step that turns a path into a file; the mount table is consulted during resolution, which is why the cover works against every tool that opens a path. Terms earned, no borrowing.

The concrete case, before the abstraction. mount --bind /tmp/gh015/decoy /tmp/gh015/stash. Before: ls -A shows implant.sh notes.txt, and find agrees. After: ls -A shows nothing, find shows nothing, du reports 0. The attacker's own confirmation comes from the table: findmnt -T shows the stash's SOURCE is tmpfs[/gh015/decoy], the giveaway in plain sight. One mount, total cover, one table read to see through it.

Scope. T1564.013 covers bind mounts broadly: hiding files, redirecting paths, and container breakouts lean on the same primitive. This file works the concealment case end to end: the cover, the table read, the lift, the capability gate, and the inventory. The lab runs as root in a disposable mount namespace because the mount syscall requires CAP_SYS_ADMIN; the prevention step shows the gate refusing the same call without the capability, which is the whole point.

02

Target Environment

LOADOUT

Ubuntu 24.04.5 LTS, x86-64, in a disposable mount namespace used only for this lab. Runs as root: the mount syscall needs CAP_SYS_ADMIN, and the capability gate in the blue phase is demonstrated, not described. Everything the lab touches lives inside /tmp/gh015, so cleanup is a single rm.

1

Build the lab

One disposable directory, built from scratch. rm -rf /tmp/gh015 clears any earlier take; mkdir -p makes the stash and the empty decoy. The two stash files go in through heredocs. implant.sh is the stand-in for the payload the attacker needs on disk: kept, never run. One umount brings it back into view; that is the point. notes.txt is the staging manifest: what the payload is, when the drop window opens, who carries it. The final ls -A proves the lab built: implant.sh, notes.txt.

bash
$ rm -rf /tmp/gh015 && mkdir -p /tmp/gh015/stash /tmp/gh015/decoy && cat > /tmp/gh015/stash/implant.sh <<'EOF'
#!/bin/sh
# Stand-in for the payload the attacker needs on disk: kept, never run.
# One umount brings it back into view; that is the point.
echo "this file is never executed"
exit 0
EOF
cat > /tmp/gh015/stash/notes.txt <<'EOF'
staging manifest
- implant.sh : payload stand-in (kept on disk, never executed)
- drop window: after the next reboot
- carrier: whoever reads this path first
EOF
echo "lab built: /tmp/gh015"; ls -A /tmp/gh015/stash
lab built: /tmp/gh015
implant.sh  notes.txt
2

The before view

This is what normal looks like, recorded before the cover goes down. ls -A shows both files; find -mindepth 1 lists both full paths. Both tools agree, because nothing is hidden yet. The blue phase will compare this against the after view.

bash
$ echo "--- the before view: what normal looks like ---"; ls -A /tmp/gh015/stash; echo; find /tmp/gh015/stash -mindepth 1
--- the before view: what normal looks like ---
implant.sh  notes.txt

/tmp/gh015/stash/notes.txt
/tmp/gh015/stash/implant.sh
03

Phase Red: lay the false floor

ATTACK

First the before view, then the cover goes down, then the attacker's own confirmation from the mount table.

Real screen recording 123.3s
What you are watching: An empty directory is bind-mounted over a populated stash. ls, find, and du report the cover; the mount table tells the truth. Every command below is copy-pasteable.
1

The attack

mount --bind /tmp/gh015/decoy /tmp/gh015/stash lays the empty cover over the stash. The command is silent on success: the evidence is what the listings say after. ls -A shows nothing, with the (ls: empty) marker. find -mindepth 1 shows nothing. du -sh reports 0 for the path. Three path-based tools, three empty answers, and the files are untouched on disk.

bash
$ echo "--- the attack: lay the empty cover over the stash ---"; mount --bind /tmp/gh015/decoy /tmp/gh015/stash; echo "--- the after view ---"; ls -A /tmp/gh015/stash; echo '(ls: empty)'; find /tmp/gh015/stash -mindepth 1; echo '(find: nothing)'; du -sh /tmp/gh015/stash
--- the attack: lay the empty cover over the stash ---
--- the after view ---
(ls: empty)
(find: nothing)
0	/tmp/gh015/stash
2

The attacker's confirmation

The attacker reads the same table the defender will read, to confirm the cover holds. findmnt -T /tmp/gh015/stash shows TARGET /tmp/gh015/stash with SOURCE tmpfs[/gh015/decoy]: the path is a mountpoint whose source is the decoy. grep gh015 /proc/mounts shows the table entry: tmpfs on /tmp/gh015/stash. The giveaway is in the table the whole time; the attack works because almost nobody reads it.

bash
$ echo "--- the attacker confirms the cover holds ---"; findmnt -T /tmp/gh015/stash; echo; grep gh015 /proc/mounts
--- the attacker confirms the cover holds ---
TARGET          SOURCE             FSTYPE OPTIONS
/tmp/gh015/stash
                tmpfs[/gh015/decoy]
                                   tmpfs  rw,relatime,uid=131072,gid=131072,inod

tmpfs /tmp/gh015/stash tmpfs rw,relatime,uid=131072,gid=131072,inode64 0 0
3

Stealth confirmed

Three echo lines, the attacker's summary: ls, find, du all report the cover; the files are untouched on disk; the path now resolves to the empty decoy. Only the mount table tells the truth, and the attacker is counting on nobody reading it.

bash
$ echo "stealth confirmed: ls, find, du all report the cover"; echo "the files are untouched on disk; the path now resolves to the empty decoy"; echo "only the mount table tells the truth, and the attacker is counting on nobody reading it"
stealth confirmed: ls, find, du all report the cover
the files are untouched on disk; the path now resolves to the empty decoy
only the mount table tells the truth, and the attacker is counting on nobody reading it
Stealth confirmed

The empty decoy went over the stash with one mount, and every path-based tool reported the cover: empty listings, zero bytes. The files sat untouched on disk the whole time. The mount table named the cover from the first second, and the attack bet that nobody would read it.

04

Phase Blue: read the table

DEFENSE

The defender does not trust the listing. The defender reads the table: detect from the independent path, record before touching, lift the cover, quarantine what was underneath, then gate the capability and inventory the table.

Here is the trap: running ls, seeing nothing, and calling the directory clean. That is trusting the same path resolution the attacker just subverted. The detection is the table read: a mountpoint check and a source column, while the cover is still live.

Real screen recording 238.2s
What you are watching: The defender finds the cover from the mount table, records the table, lifts the cover, and quarantines what was underneath, then demonstrates the capability gate and the table inventory. Every command below is copy-pasteable.
1

DETECTION: the naive view, then the independent path

ls -A shows nothing: the naive view says clean. Then the independent path. mountpoint -q /tmp/gh015/stash exits true: stash IS a mountpoint, and a plain directory is not. findmnt -T shows SOURCE tmpfs[/gh015/decoy]: the path resolves to the decoy. grep gh015 /proc/mounts shows the table entry. lsns -t mnt enumerates the mount namespaces: one here, with the lab's bash in it. On a real host, read every namespace's table, because a mount made in another namespace is invisible in this one. Good versus bad, concrete: good is a documented mount with an owner; bad is an undocumented bind of an empty directory over a populated path.

bash
$ echo "--- DETECTION: the naive view first ---"; ls -A /tmp/gh015/stash; echo '(looks clean)'; echo "--- the independent path: the mount table ---"; mountpoint -q /tmp/gh015/stash && echo "stash IS a mountpoint (a plain directory is not)"; findmnt -T /tmp/gh015/stash; grep gh015 /proc/mounts; echo "--- every mount namespace keeps its own table ---"; lsns -t mnt; echo "good: a documented mount with an owner"; echo "bad: an undocumented bind of an empty directory over a populated path"
--- DETECTION: the naive view first ---
(looks clean)
--- the independent path: the mount table ---
stash IS a mountpoint (a plain directory is not)
TARGET          SOURCE             FSTYPE OPTIONS
/tmp/gh015/stash
                tmpfs[/gh015/decoy]
                                   tmpfs  rw,relatime,uid=131072,gid=131072,inod
tmpfs /tmp/gh015/stash tmpfs rw,relatime,uid=131072,gid=131072,inode64 0 0
--- every mount namespace keeps its own table ---
        NS TYPE NPROCS PID USER COMMAND
4026532390 mnt       2   1 root bash --norc --noprofile
good: a documented mount with an owner
bad: an undocumented bind of an empty directory over a populated path
2

Record, then lift

grep gh015 /proc/mounts goes into mount-evidence.txt BEFORE anything is touched: unmounting disturbs the scene, so the table is recorded first. Then umount /tmp/gh015/stash lifts the cover, and ls -A shows implant.sh notes.txt back. The mount was the only thing hiding them.

bash
$ echo "--- record the table BEFORE touching anything ---"; grep gh015 /proc/mounts > /tmp/gh015/mount-evidence.txt && cat /tmp/gh015/mount-evidence.txt; echo "--- lift the cover ---"; umount /tmp/gh015/stash; ls -A /tmp/gh015/stash; echo "the mount was the only thing hiding them"
--- record the table BEFORE touching anything ---
tmpfs /tmp/gh015/stash tmpfs rw,relatime,uid=131072,gid=131072,inode64 0 0
--- lift the cover ---
implant.sh  notes.txt
the mount was the only thing hiding them
3

MITIGATION: hash and quarantine

sha256sum hashes the revealed files: evidence hashes, taken before the files move. mkdir quarantine, mv both files in: seized, not deleted. Then the persistence sweep, the three places a remount hides: grep gh015 /etc/fstab (no entry), the systemd units (none), crontab (none). The honest scope note: the table says WHAT was hidden, not WHEN it was mounted. The mount time is not in the table.

bash
$ echo "--- MITIGATION: hash and quarantine what was underneath ---"; sha256sum /tmp/gh015/stash/implant.sh /tmp/gh015/stash/notes.txt; mkdir -p /tmp/gh015/quarantine && mv /tmp/gh015/stash/implant.sh /tmp/gh015/stash/notes.txt /tmp/gh015/quarantine/ && ls -A /tmp/gh015/quarantine; echo "--- persistence sweep ---"; grep gh015 /etc/fstab 2>/dev/null || echo 'no gh015 entry in /etc/fstab'; ls /etc/systemd/system/ 2>/dev/null | grep -i gh015 || echo 'no gh015 systemd units'; crontab -l 2>/dev/null | grep -i gh015 || echo 'no gh015 crontab entries'; echo "honest scope note: the table says WHAT was hidden, not WHEN it was mounted"
--- MITIGATION: hash and quarantine what was underneath ---
f67666cc128f2471db26fe6626b4464efeb081c96eadede8453f9b5c851bd602  /tmp/gh015/stash/implant.sh
4b550b1f2a285164dbb7e0d0552b70c78b0a1c26a897e256c51ed6755debacf3  /tmp/gh015/stash/notes.txt
implant.sh  notes.txt
--- persistence sweep ---
no gh015 entry in /etc/fstab
no gh015 systemd units
no gh015 crontab entries
honest scope note: the table says WHAT was hidden, not WHEN it was mounted
4

Confirm the cover is gone

mountpoint -q now says stash is NOT a mountpoint. findmnt lists no gh015 binds left. ls quarantine shows the seized files. Three independent confirmations: the path is a plain directory again, the table is clean, the files are in custody.

bash
$ echo "--- confirm the cover is gone ---"; mountpoint -q /tmp/gh015/stash && echo "STILL A MOUNTPOINT (bad)" || echo "stash is NOT a mountpoint"; findmnt -rn -o TARGET | grep gh015 || echo "no gh015 binds left in the table"; ls -A /tmp/gh015/quarantine
--- confirm the cover is gone ---
stash is NOT a mountpoint
no gh015 binds left in the table
implant.sh  notes.txt
5

PREVENTION: the capability gate

capsh --drop=cap_sys_admin runs the same mount --bind without the capability, and the kernel refuses it: mount: /tmp/gh015/demo: permission denied. Bind mounts need CAP_SYS_ADMIN; without it the mount syscall is refused at the gate. This is the durable control: the technique's prerequisite is a capability, and capabilities can be taken away. D3FEND D3-SCP: System Configuration Permissions names exactly this shape: restricting system configuration changes to the principals that need them.

bash
$ echo "--- PREVENTION: the capability gate ---"; mkdir -p /tmp/gh015/demo && capsh --drop=cap_sys_admin -- -c 'mount --bind /tmp/gh015/decoy /tmp/gh015/demo' 2>&1; echo "(mount refused: bind mounts need CAP_SYS_ADMIN)"; rmdir /tmp/gh015/demo
--- PREVENTION: the capability gate ---
mount: /tmp/gh015/demo: permission denied.
       dmesg(1) may have more information after failed mount system call.
(mount refused: bind mounts need CAP_SYS_ADMIN)
6

PREVENTION: the mount-table inventory

findmnt -rn -o TARGET,SOURCE snapshots the table into mounts.baseline: 72 lines on this box. The scheduled check is one diff against a fresh read: clean means no drift. The tell is an undocumented bind, especially an empty directory over a populated path. D3FEND D3-CI: Configuration Inventory is the inventory discipline behind the check.

bash
$ echo "--- PREVENTION: the mount-table inventory ---"; findmnt -rn -o TARGET,SOURCE > /tmp/gh015/mounts.baseline && echo "baseline saved: $(wc -l < /tmp/gh015/mounts.baseline) lines"; echo "the scheduled check runs: diff mounts.baseline <(findmnt -rn -o TARGET,SOURCE)"; diff /tmp/gh015/mounts.baseline <(findmnt -rn -o TARGET,SOURCE) && echo 'clean: no drift'
--- PREVENTION: the mount-table inventory ---
baseline saved: 72 lines
the scheduled check runs: diff mounts.baseline <(findmnt -rn -o TARGET,SOURCE)
clean: no drift
7

Verdict

The summary, in the defender's own words: the naive view said clean, the table said mountpoint. The cover was recorded, lifted, and what was underneath was hashed and quarantined.

bash
$ echo "detection verified: the naive view said clean, the table said mountpoint"; echo "the cover was recorded, lifted, and what was underneath was hashed and quarantined"
detection verified: the naive view said clean, the table said mountpoint
the cover was recorded, lifted, and what was underneath was hashed and quarantined
Detection verified

The listing said clean and the table said mountpoint, and the table was right. The cover was recorded before it was touched, lifted with one umount, and the files underneath were hashed and quarantined. The capability gate refused the same mount without CAP_SYS_ADMIN, and the table inventory diffs clean.

8

Cleanup

rm -rf /tmp/gh015 removes the lab; ls confirms the directory is gone; grep gh015 /proc/mounts confirms no mounts remain. The namespace dies with the session regardless; the cleanup keeps the record honest.

bash
$ rm -rf /tmp/gh015; ls /tmp | grep gh015 || echo "lab gone"; grep gh015 /proc/mounts || echo "no gh015 mounts in the table"
lab gone
no gh015 mounts in the table
05

Countermeasures

DEFENSE

Three moves, in order: record and lift the cover, inventory the table on a schedule, gate the capability. Each is one way, not the way.

1

Mitigate: record, lift, hash, quarantine

Proven first against the live cover: record the mount table before touching anything, unmount the cover, hash the revealed files, move them to quarantine, sweep persistence: fstab, systemd mount units, cron. D3FEND D3-SICA: System Init Config Analysis is the discipline behind the fstab and systemd sweep.

bash
$ echo "--- record the table BEFORE touching anything ---"; grep gh015 /proc/mounts > /tmp/gh015/mount-evidence.txt && cat /tmp/gh015/mount-evidence.txt; echo "--- lift the cover ---"; umount /tmp/gh015/stash; ls -A /tmp/gh015/stash; echo "the mount was the only thing hiding them"
--- record the table BEFORE touching anything ---
tmpfs /tmp/gh015/stash tmpfs rw,relatime,uid=131072,gid=131072,inode64 0 0
--- lift the cover ---
implant.sh  notes.txt
the mount was the only thing hiding them
$ echo "--- MITIGATION: hash and quarantine what was underneath ---"; sha256sum /tmp/gh015/stash/implant.sh /tmp/gh015/stash/notes.txt; mkdir -p /tmp/gh015/quarantine && mv /tmp/gh015/stash/implant.sh /tmp/gh015/stash/notes.txt /tmp/gh015/quarantine/ && ls -A /tmp/gh015/quarantine; echo "--- persistence sweep ---"; grep gh015 /etc/fstab 2>/dev/null || echo 'no gh015 entry in /etc/fstab'; ls /etc/systemd/system/ 2>/dev/null | grep -i gh015 || echo 'no gh015 systemd units'; crontab -l 2>/dev/null | grep -i gh015 || echo 'no gh015 crontab entries'; echo "honest scope note: the table says WHAT was hidden, not WHEN it was mounted"
--- MITIGATION: hash and quarantine what was underneath ---
f67666cc128f2471db26fe6626b4464efeb081c96eadede8453f9b5c851bd602  /tmp/gh015/stash/implant.sh
4b550b1f2a285164dbb7e0d0552b70c78b0a1c26a897e256c51ed6755debacf3  /tmp/gh015/stash/notes.txt
implant.sh  notes.txt
--- persistence sweep ---
no gh015 entry in /etc/fstab
no gh015 systemd units
no gh015 crontab entries
honest scope note: the table says WHAT was hidden, not WHEN it was mounted

Honest limit. Unmounting disturbs the scene, so the table is recorded first and treated as the evidence. Open file descriptors into the hidden tree survive the unmount: a process that opened the stash before the cover went down still reads the real files, so hunt /proc/*/fd for handles into the path too. The table tells what was hidden, not when it was mounted; mount-syscall audit logs are the production backstop for the when. Stated, not shown: audit is not functional inside the lab namespace.

2

Monitor: diff the table against a baseline

The scheduled form of the phase-blue read: snapshot findmnt -rn -o TARGET,SOURCE known-good, and diff it on a timer. The tell is an undocumented bind, especially an empty directory over a populated path.

bash
$ echo "--- PREVENTION: the mount-table inventory ---"; findmnt -rn -o TARGET,SOURCE > /tmp/gh015/mounts.baseline && echo "baseline saved: $(wc -l < /tmp/gh015/mounts.baseline) lines"; echo "the scheduled check runs: diff mounts.baseline <(findmnt -rn -o TARGET,SOURCE)"; diff /tmp/gh015/mounts.baseline <(findmnt -rn -o TARGET,SOURCE) && echo 'clean: no drift'
--- PREVENTION: the mount-table inventory ---
baseline saved: 72 lines
the scheduled check runs: diff mounts.baseline <(findmnt -rn -o TARGET,SOURCE)
clean: no drift

Honest limit. Enumerate every mount namespace: lsns -t mnt, then read each namespace's table. A mount created and removed between polls is missed, so the poll interval sets the detection floor. Bind mounts are legitimate: containers use them constantly, so the signal is undocumented, never present. An allowlist of expected mounts is what makes the diff meaningful.

3

Prevent: restrict CAP_SYS_ADMIN

The durable form: only the mount paths that need the capability keep it. Without CAP_SYS_ADMIN the mount syscall is refused, as demonstrated above. Container runtimes and service managers can drop the capability per workload.

bash
$ echo "--- PREVENTION: the capability gate ---"; mkdir -p /tmp/gh015/demo && capsh --drop=cap_sys_admin -- -c 'mount --bind /tmp/gh015/decoy /tmp/gh015/demo' 2>&1; echo "(mount refused: bind mounts need CAP_SYS_ADMIN)"; rmdir /tmp/gh015/demo
--- PREVENTION: the capability gate ---
mount: /tmp/gh015/demo: permission denied.
       dmesg(1) may have more information after failed mount system call.
(mount refused: bind mounts need CAP_SYS_ADMIN)

Honest limit. User namespaces can re-grant the capability inside a new namespace where the kernel allows unprivileged user namespaces: the gate holds at the host boundary, not inside a namespace the attacker was allowed to create. And the mount syscall itself cannot be blocked outright without breaking containers, which is why the inventory in step 2 is the backstop, not the afterthought.

Countermeasures verified

The cover was recorded, lifted, and quarantined with its hashes; the table is inventoried on a schedule with every namespace enumerated; the capability is gated so the mount is refused without it. The listing still lies to whoever only reads listings. The table does not lie to whoever reads it.

06

Debrief

TAKEAWAY

When the listing and the mount table disagree, the table is the truth: read the mounts, not the directory.

IOC checklist: signs this technique was used

  • A directory that reads empty but answers yes to mountpoint -q
  • findmnt showing a path whose SOURCE is an unrelated directory, especially an empty one
  • An undocumented bind of an empty directory over a populated path in /proc/mounts or /proc/self/mountinfo
  • Files reappearing under a path immediately after an umount
  • Mount-syscall audit events with no matching change record

Reproducibility checklist

  • Verified on Ubuntu 24.04.5 LTS, x86-64, on 2026-09-21
  • Both recordings are real executions on that platform, not simulations
  • Runs as root in a disposable mount namespace (the mount syscall requires CAP_SYS_ADMIN; the assumed breach: something on the box holds the capability)
  • Cleanup: umount /tmp/gh015/stash, rm -rf /tmp/gh015; verify with findmnt -T and grep gh015 /proc/mounts

Sources

Next file

GH-016 The Erased Anchor

The next file wipes the traces that say it was ever here.