GH-030 T1564.005 PHASE RED INSIDE

The Hidden Basement

The directory is empty. The mount table agrees. Both are telling the truth about the wrong namespace. This file mounts a live filesystem where the host cannot look, then finds it anyway: every namespace has its own table, and the defender reads all of them.

TechniqueHidden File System (T1564.005)
Target OSUbuntu 24.04.5 LTS
Toolchainutil-linux 2.39, coreutils 9.4
LevelIntermediate
Time25 min

OBJECTIVES

  1. Mount a private volume inside a fresh mount namespace and watch the host inventory report an empty directory
  2. Hunt the hidden volume across every mount namespace and read its bytes through /proc/PID/root
  3. Seize the evidence before killing the holder, inventory namespaces on a timer, gate the mount capability
  4. Take the IOC checklist and the one-sentence lesson
01

Intel Brief

CONTEXT

MITRE ATT&CK T1564.005: adversaries use their own abstracted file system, separate from the standard file system on the machine, hiding malicious components and file input/output from users and security tools. Documented implementations include a file system kept in reserved disk space and a portable partition image dropped as a file on top of the standard file system. This file works one Linux construction end to end: a real tmpfs volume mounted inside a private mount namespace, invisible to the host's ls, find, and mount table, held alive by a sleeper process. Two actors: the attacker, who owns the hidden mount and the holder process; and the defender, who owns the namespace enumeration, the evidence seizure, and the capability gate in the blue phases.

Why this technique. The file inventory is the defender's map of the machine: ls, find, du, every SIEM file feed, every "list every file" sweep. Operators trust the map the way they trust the process list, and the map has the same flaw: it is drawn from one vantage point. On Linux there is no single mount table. Every process carries its own, and unshare -m forks a private copy in one syscall. A filesystem mounted after the fork exists fully, superblock and inodes and dentries, readable and writable by every process inside that namespace, and the host's inventory never lists it. The map is not wrong. It is drawn from the wrong room.

Why not the obvious alternatives. The attacker hides the staging files as dotfiles or down a deep path. The defender runs find / -type f and the files are listed anyway: the trick fools a person glancing at a directory, not a tool walking the disk. Or the attacker covers the staging directory with a bind mount. The defender greps the mount table and the cover is listed as an entry, because the mount was made in the shared table the defender reads. Or the attacker deletes the staging data when done. Then there is nothing to find, but also nothing to use: the operator needs the data live, writable, and reachable, and deletion is one-way. This file's technique keeps the volume live and fully usable while the defender's table stays empty: the mount lands in a forked copy of the table, so the defender's own copy never learns about it. Usable from inside the namespace, invisible from outside it.

The mechanism, in one paragraph. unshare -m gives the child a private copy of the calling process's mount table. mount --make-rprivate / detaches mount propagation, so new mounts in the child do not leak back to the parent. mount -t tmpfs vaultfs /tmp/gh030/vault then puts a real filesystem at that path: a superblock, inodes, dentries, the whole structure, living in memory. exec -a vault-holder sleep 600 parks a sleeper under a recognizable name; the private namespace survives as long as any process lives in it. The parent's /proc/self/mountinfo never lists the volume, because mountinfo is per-namespace, and the parent is in a different namespace. The independent observation paths are /proc/<pid>/mountinfo, the table as seen by each process, and /proc/<pid>/root, a path into that process's own filesystem view, which follows its mount namespace.

The concrete case, before the abstraction. In /tmp/gh030, the vault directory is empty and the host's mount table shows zero hits for its path: one namespace, one table, nothing to see. One unshare -m later, a tmpfs is mounted at that same path and GHOSTLIGHT-CANARY-030 is written into it. From the host: ls -A still prints nothing, the table still shows zero hits. From the holder's view: cat /proc/11/root/tmp/gh030/vault/ledger.txt prints the canary, and grep on /proc/11/mountinfo shows the tmpfs entry. Same path, two namespaces, two answers. Only the second table lists the filesystem.

Terms, earned. A mount namespace is a process's private view of what is mounted where; unshare -m forks one. The mount table is /proc/<pid>/mountinfo, the kernel's per-namespace list of mounts; /proc/self/mountinfo is only your own namespace's. tmpfs is a filesystem that lives in memory: real inodes and directory entries, no disk underneath. The holder is the sleeper process parked in the private namespace; the namespace, and the hidden volume with it, dies with its last process. /proc/<pid>/root is a path into a process's own filesystem view, following its mount namespace.

Scope. T1564.005 covers hidden and virtual file systems broadly: reserved disk space, partition images, fragmented storage. This file works one Linux construction end to end: a tmpfs volume mounted in a private mount namespace, invisible to host inventory, held alive by a sleeper. The loop-device variant (a partition image mounted with mount -o loop) is the closer match to the documented implementations, and it is unavailable in this lab (losetup finds no free loop device), recorded honestly; the mechanism demonstrated, a mounted filesystem the host's table does not list, is the same. The canary is a benign token: it marks the hidden bytes and touches nothing else. The lab runs in a disposable PID and mount namespace with a private /tmp; teardown kills the holder and removes the directory, and the namespace's death reaps every stray.

02

Target Environment

LOADOUT

Ubuntu 24.04.5 LTS, x86-64, util-linux 2.39 (unshare, mount, lsns) and coreutils 9.4, in a disposable PID and mount namespace with a private /tmp used only for this lab. The attack needs CAP_SYS_ADMIN for the mount syscall; the lab runs as root inside its namespace. On a real host the attacker needs that capability outright or a user namespace that grants it. The lab never mounts over a real host path: every mount lands under /tmp/gh030, inside the private namespace.

1

Build the lab

The recording starts from an empty private /tmp inside its own mount namespace, so every take begins identical. rm -rf /tmp/gh030 starts clean; mkdir -p builds the vault directory and the evidence directory. The vault is an ordinary empty directory. Nothing is mounted, nothing is hidden, yet.

bash
$ rm -rf /tmp/gh030 && mkdir -p /tmp/gh030/vault /tmp/gh030/evidence && cd /tmp/gh030
echo 'an ordinary directory. nothing mounted, nothing hidden. yet.'
ls -A vault
echo 'lab built'
an ordinary directory. nothing mounted, nothing hidden. yet.
lab built
2

The before view: the host inventory, before

The baseline the blue phase will compare against. ls -A and find print nothing: the vault is empty. grep -c on /proc/self/mountinfo reports zero hits for the vault path: the host table lists nothing there. lsns -t mnt shows one mount namespace. One namespace, one table, nothing to see. This is what normal looks like.

bash
$ echo '--- the host file inventory, before:'
ls -A /tmp/gh030/vault
find /tmp/gh030 -type f
echo "host mount-table hits: $(grep -c ' /tmp/gh030/vault ' /proc/self/mountinfo)"
lsns -t mnt -o NS,NPROCS,COMMAND
echo 'one namespace, one table, nothing to see'
--- the host file inventory, before:
host mount-table hits: 0
        NS NPROCS COMMAND
4026532441      2 bash --norc --noprofile
one namespace, one table, nothing to see
03

Phase Red: the basement under the house

ATTACK

The attacker forks a private mount namespace, mounts a live filesystem where the host cannot look, writes the canary into it, and parks a sleeper to keep the namespace alive. The host's tools keep reporting an empty directory, because they are reading the wrong table.

Real screen recording 116.1s
What you are watching: A private volume is mounted in a forked namespace and the host inventory keeps reporting an empty directory. Every command below is copy-pasteable.
1

Fork the namespace and mount the hidden volume

The whole attack is one backgrounded line. unshare -m forks a private mount namespace. mount --make-rprivate / detaches propagation so the new mount cannot leak to the parent. mount -t tmpfs vaultfs /tmp/gh030/vault puts a real filesystem at the vault path, inside the child namespace only. The canary goes in, and exec -a vault-holder sleep 600 parks the holder: the namespace survives as long as this process lives. $! names the holder pid; ps shows it. Then the host view, after the mount: ls -A prints nothing, the host table still shows zero hits. The host inventory says: empty directory, nothing mounted. It is reading the wrong table.

bash
$ unshare -m bash -c 'mount --make-rprivate / >/dev/null && mount -t tmpfs -o size=64m,nr_inodes=1k vaultfs /tmp/gh030/vault && echo GHOSTLIGHT-CANARY-030 > /tmp/gh030/vault/ledger.txt && echo "vault mounted: visible only inside this namespace" && exec -a vault-holder sleep 600' &
sleep 1
HOLDER=$!
echo "holder pid: $HOLDER"
ps -o pid,comm,args -p $HOLDER
echo '--- the host view, after the mount:'
ls -A /tmp/gh030/vault
echo "host mount-table hits: $(grep -c ' /tmp/gh030/vault ' /proc/self/mountinfo)"
echo 'the host inventory says: empty directory, nothing mounted'
[1] 11
vault mounted: visible only inside this namespace
holder pid: 11
    PID COMMAND         COMMAND
     11 sleep           vault-holder 600
--- the host view, after the mount:
host mount-table hits: 0
the host inventory says: empty directory, nothing mounted
2

The attacker's confirmation: read the hidden view

The attacker does not trust the host tools either; they check through the holder's own namespace. cat /proc/$HOLDER/root/tmp/gh030/vault/ledger.txt prints the canary: the hidden bytes are live and readable. grep on /proc/$HOLDER/mountinfo shows the tmpfs entry with its size and inode options. Same path, two namespaces, two answers.

bash
$ echo "--- the hidden view: the holder process and its own mount table:"
cat /proc/$HOLDER/root/tmp/gh030/vault/ledger.txt
grep ' /tmp/gh030/vault ' /proc/$HOLDER/mountinfo
echo 'stealth confirmed: a live, writable filesystem the host tools cannot see'
--- the hidden view: the holder process and its own mount table:
GHOSTLIGHT-CANARY-030
2320 2006 0:68 / /tmp/gh030/vault rw,relatime - tmpfs vaultfs rw,size=65536k,nr_inodes=1024,uid=131072,gid=131072,inode64
stealth confirmed: a live, writable filesystem the host tools cannot see
Stealth confirmed

A live, writable filesystem now sits at /tmp/gh030/vault, and the host's ls, find, and mount table all report an empty directory. The hiding is structural: no host-side enumeration can list what the host's namespace never mounted. The attacker is counting on nobody reading any table but the host's.

04

Phase Blue: read every table

DEFENSE

The defender never saw the mount; the blue take opens on the "empty" directory. The triad, at runbook quality. Detection: take the naive view first (empty dir, clean table), then the independent path: enumerate every mount namespace with lsns and hunt every process's mountinfo for the vault path. Mitigation: record the hidden table, seize the bytes through /proc/PID/root, check persistence, then kill the holder, because the hidden volume dies with its last process and the evidence must be copied first. Prevention: gate the mount capability and inventory namespaces on a timer.

Real screen recording 192.4s
What you are watching: The defender finds the hidden volume by reading every namespace's table, seizes the bytes before killing the holder, and gates the mount capability. Every command below is copy-pasteable.
1

DETECTION: the naive view, then the independent path

The naive view first, so the failure is on the record: ls -A prints nothing, the host table shows zero hits. Looks clean. It is not. The independent path: lsns -t mnt lists two mount namespaces, and the second one has no business existing on this inventory. The hunt reads every process's table: grep -l over /proc/[0-9]*/mountinfo names /proc/11/mountinfo, the holder's. The pid comes out of the path with cut; the holder's table shows the tmpfs entry at the vault path. Then the read that proves it: cat /proc/$HPID/root/tmp/gh030/vault/ledger.txt prints the canary through the holder's own view. Good versus bad, concrete: good is every namespace's table matching the documented inventory; bad is a filesystem mounted at a path the host's own table does not list.

bash
$ echo '--- the naive view first:'
ls -A /tmp/gh030/vault
echo "host mount-table hits: $(grep -c ' /tmp/gh030/vault ' /proc/self/mountinfo)"
echo '(looks clean. it is not.)'
echo '--- the independent path: every mount namespace gets its own table:'
lsns -t mnt -o NS,NPROCS,COMMAND
echo '--- the hunt: whose table lists the vault?'
grep -l ' /tmp/gh030/vault ' /proc/[0-9]*/mountinfo 2>/dev/null
HPID=$(grep -l ' /tmp/gh030/vault ' /proc/[0-9]*/mountinfo 2>/dev/null | head -1 | cut -d/ -f3)
echo "holder pid: $HPID"
grep ' /tmp/gh030/vault ' /proc/$HPID/mountinfo
echo "--- read the hidden bytes through the holder process view:"
cat /proc/$HPID/root/tmp/gh030/vault/ledger.txt
--- the naive view first:
host mount-table hits: 0
(looks clean. it is not.)
--- the independent path: every mount namespace gets its own table:
        NS NPROCS COMMAND
4026532441      2 bash --norc --noprofile
4026532445      1 └─vault-holder 600
--- the hunt: whose table lists the vault?
/proc/11/mountinfo
holder pid: 11
2320 2006 0:68 / /tmp/gh030/vault rw,relatime - tmpfs vaultfs rw,size=65536k,nr_inodes=1024,uid=131072,gid=131072,inode64
--- read the hidden bytes through the holder process view:
GHOSTLIGHT-CANARY-030
2

MITIGATION: record, seize, then lift

Evidence before action, because the next command destroys the crime scene. The hidden table entry is saved with a UTC timestamp; the canary file is copied out through /proc/$HPID/root with cp -a and hashed with sha256sum. The persistence sweep is read-only: grep -r gh030 across /etc/fstab and the systemd unit directories finds nothing, so the volume is not coming back on reboot. Then the lift: kill $HPID. The hidden filesystem dies with its last process; the hunt comes back empty and lsns shows one namespace again. The order is the procedure: copy first, kill second. A responder who kills first seizes nothing.

bash
$ TS=$(date -u +%Y%m%dT%H%M%SZ)
grep ' /tmp/gh030/vault ' /proc/$HPID/mountinfo | tee /tmp/gh030/evidence/mountinfo-$TS.txt
cp -a /proc/$HPID/root/tmp/gh030/vault/ledger.txt /tmp/gh030/evidence/
sha256sum /tmp/gh030/evidence/ledger.txt | tee /tmp/gh030/evidence/sha256-$TS.txt
echo '--- persistence sweep (read-only):'
grep -r gh030 /etc/fstab /etc/systemd/system/ 2>/dev/null || echo 'no fstab/systemd persistence'
echo '--- lift: the hidden filesystem dies with its last process:'
kill $HPID
sleep 1
echo "hunt now: [$(grep -l ' /tmp/gh030/vault ' /proc/[0-9]*/mountinfo 2>/dev/null)]"
lsns -t mnt -o NS,NPROCS,COMMAND
echo 'evidence was copied BEFORE the kill: the order is the evidence'
2320 2006 0:68 / /tmp/gh030/vault rw,relatime - tmpfs vaultfs rw,size=65536k,nr_inodes=1024,uid=131072,gid=131072,inode64
0a826ad849510240e8050f37db113ef74ccbe93c629243cb646acebcdbabd4de  /tmp/gh030/evidence/ledger.txt
--- persistence sweep (read-only):
no fstab/systemd persistence
--- lift: the hidden filesystem dies with its last process:
hunt now: []
        NS NPROCS COMMAND
4026532441      2 bash --norc --noprofile
evidence was copied BEFORE the kill: the order is the evidence
3

PREVENTION: the capability gate and the inventory

Mounting needs CAP_SYS_ADMIN. capsh --drop=cap_sys_admin replays the mount without it: permission denied, rc nonzero. The control mounts with the capability intact and succeeds, proving the capability was the blocker, then unmounts. The durable control is the namespace inventory: lsns -t mnt captured to mntns.baseline; the scheduled check diffs it, and a new namespace is the alert. D3FEND names the heavier forms Data Inventory (D3-DI), which records the volumes and locations of data on the architecture, and Asset Vulnerability Enumeration (D3-AVE), which enriches inventory items: the hidden volume is an uninventoried volume, and the inventory is what convicts it.

bash
$ echo '--- the capability gate: mounting needs CAP_SYS_ADMIN:'
capsh --drop=cap_sys_admin -- -c 'mount -t tmpfs vaultfs /tmp/gh030/vault' 2>&1; echo "rc=$?"
echo '--- control: with the capability, the mount succeeds:'
mount -t tmpfs ctlfs /tmp/gh030/vault && echo 'control: mount works with CAP_SYS_ADMIN' && umount /tmp/gh030/vault
echo '--- the namespace inventory baseline:'
lsns -t mnt -o NS,NPROCS,COMMAND | tee /tmp/gh030/evidence/mntns.baseline
echo 'the scheduled check diffs this file; a new namespace is the alert'
--- the capability gate: mounting needs CAP_SYS_ADMIN:
mount: /tmp/gh030/vault: permission denied.
       dmesg(1) may have more information after failed mount system call.
rc=32
--- control: with the capability, the mount succeeds:
control: mount works with CAP_SYS_ADMIN
--- the namespace inventory baseline:
        NS NPROCS COMMAND
4026532441      3 bash --norc --noprofile
the scheduled check diffs this file; a new namespace is the alert
4

Confirm the basement is gone

After remediation: the vault directory is empty, the host table shows zero hits, and the evidence directory holds the seized canary, the hidden table entry, the hash, and the namespace baseline. rm -rf /tmp/gh030 removes the lab; the namespace's death already reaped the holder.

bash
$ echo '--- after remediation:'
ls -A /tmp/gh030/vault
echo "host mount-table hits: $(grep -c ' /tmp/gh030/vault ' /proc/self/mountinfo)"
echo 'seized evidence:'; ls /tmp/gh030/evidence
cd /tmp && rm -rf /tmp/gh030
echo 'lab removed; every stray dies with the namespace'
--- after remediation:
host mount-table hits: 0
seized evidence:
ledger.txt	mountinfo-20261005T124224Z.txt
mntns.baseline	sha256-20261005T124224Z.txt
lab removed; every stray dies with the namespace
Detection verified

The host's inventory never saw the volume; the per-namespace hunt found it in one grep. The bytes were seized through /proc/PID/root before the holder died, the table entry was recorded with its hash, and the capability gate made the replayed mount fail. The basement is gone and the evidence survived it.

05

Countermeasures

DEFENSE

Three moves, in order: seize the bytes before the holder dies, hunt every table on a timer, gate the mount capability. Each is one way, not the way.

1

Mitigate: seize first, kill second

The hidden volume is memory-backed and namespace-bound: killing the holder destroys the bytes. So the mitigation order is fixed: record the holder's mountinfo entry, copy every file out through /proc/<pid>/root, hash what you copied, and only then end the holder process. Sweep persistence read-only (fstab, systemd mount units, cron, container runtimes) before the kill, because a volume that remounts itself on reboot turns the seizure into theater. If the holder is a production process you cannot kill, copy the bytes and remount the evidence read-only instead: mount -o remount,ro inside the namespace freezes the volume without destroying it. The blue take ran the simple order: record, copy, hash, sweep, kill, verify the hunt is empty.

bash
$ grep ' /tmp/gh030/vault ' /proc/$HPID/mountinfo | tee evidence/mountinfo.txt
cp -a /proc/$HPID/root/tmp/gh030/vault/ledger.txt evidence/
sha256sum evidence/ledger.txt
kill $HPID
2320 2006 0:68 / /tmp/gh030/vault rw,relatime - tmpfs vaultfs rw,size=65536k
0a826ad849510240e8050f37db113ef74ccbe93c629243cb646acebcdbabd4de  evidence/ledger.txt

Honest limit. The seizure copies what the holder's namespace shows now; it does not recover what was deleted inside the hidden volume earlier, and it does not tell you when the volume was mounted. The table says what, not when: the mount-syscall audit log is the production backstop, stated not shown, because audit is not functional inside the lab namespace. And if the holder respawns (a supervisor outside your view), the kill buys minutes; the persistence sweep is the mitigation, the kill is the cleanup.

2

Monitor: hunt every table on a timer

The fleet form of the blue hunt: enumerate mount namespaces, then diff every table against the documented inventory. Two loops, no agent. The tell is a filesystem mounted at a path the host's own table does not list, especially a tmpfs at an application path. Wire a new namespace to the alert, not the mount itself.

bash
$ lsns -t mnt -o NS,TYPE > mntns.baseline
# on the timer:
diff mntns.baseline <(lsns -t mnt -o NS,TYPE) && echo "no new namespaces"
no new namespaces

Run it across the fleet and you have the whole monitor; production versions add alerting, not new ideas.

Honest limit. A mount created and removed between polls is missed entirely; shorten the interval or add the mount-syscall audit watch to close the gap. Namespaces are legitimate at scale: containers fork them constantly, so the signal is "undocumented", never "present", and the inventory must know which namespaces belong to which workloads. The per-process mountinfo hunt is O(processes) per poll; on a large host, sample or scope it to namespaces the inventory does not recognize.

3

Prevent: gate the mount capability

The mount syscall needs CAP_SYS_ADMIN. Drop it from every workload that does not mount filesystems, and the hidden-volume construction fails at the syscall. Containers get this almost for free: a default Docker or Kubernetes pod without added capabilities cannot mount. The audit complement is a host-level watch on the mount syscall (auditctl -a always,exit -S mount): it logs the attempt whether or not it succeeds, which is the detective record the timer-based monitor can miss.

bash
$ capsh --drop=cap_sys_admin -- -c 'mount -t tmpfs vaultfs /tmp/gh030/vault' 2>&1; echo "rc=$?"
mount: /tmp/gh030/vault: permission denied.
       dmesg(1) may have more information after failed mount system call.
rc=32

Honest limit. Unprivileged user namespaces can re-grant CAP_SYS_ADMIN inside a new namespace where the kernel allows it, so the gate holds only where user-namespace creation is itself restricted. The mount syscall cannot be blocked outright without breaking containers and installers, which is why the control is capability-scoping, not syscall-blocking. And the gate does nothing about volumes mounted before it was applied: pair it with the monitor, which finds the basements that predate the lock.

Countermeasures verified

The bytes were seized before the holder died, with hashes. The namespace inventory turns the next hidden volume into an alert. The capability gate makes the mount fail at the syscall. None of it reads the host's table and stops there.

06

Debrief

TAKEAWAY

Every process has its own mount table, and the host's file inventory only reads one of them: a filesystem mounted in a private namespace is invisible to ls, find, and the host's mountinfo alike. When the directory is empty and the table is clean, enumerate the namespaces before believing either.

IOC checklist: signs this technique was used

  • A mount namespace lsns cannot attribute to a documented workload
  • A filesystem mounted at a path the host's own mountinfo does not list
  • A long-lived sleeper whose /proc/<pid>/mountinfo differs from the host's
  • Files readable via /proc/<pid>/root that have no host-visible path
  • Round-sized image files (the partition-image variant) with no documented purpose

Reproducibility checklist

  • Verified on Ubuntu 24.04.5 LTS, util-linux 2.39 (unshare, mount, lsns), coreutils 9.4, x86-64, on 2026-10-05
  • Both recordings are real executions on that platform, not simulations
  • The attack needs CAP_SYS_ADMIN for the mount syscall; the lab runs as root inside its namespace
  • nsenter is blocked in this lab (EPERM on setns), so the cross-namespace read path is /proc/<pid>/root, recorded honestly
  • The loop-device variant (partition image, mount -o loop) is unavailable in this lab: losetup -f finds no free loop device, recorded honestly
  • Cleanup: kill the holder, rm -rf /tmp/gh030 (recorded); the namespace's death reaps every stray

Sources

MITRE ATT&CK T1564.005: Hide Artifacts: Hidden File System
mount_namespaces(7) (per-process mount tables)
proc(5) (the mountinfo and root entries)
unshare(1) (forking a private namespace)
MITRE D3FEND: D3-DI, D3-AVE

The archive

Back to the case-files index

Thirty files, thirty techniques reproduced and checked. The index is where the next reader starts.