Permission bits are the door, not the file. This file plants a benign canary in a secret readable only by its owner, watches a second user get denied, watches one chmod hand that user the key with no copy and no changed bytes, then the defense hunts the single changed mode column, captures evidence before restoring the lock, and installs the sweep that flags the next permission drift.
MITRE ATT&CK T1222.002: adversaries modify file and directory permissions to grant a second identity access it should not have. This file locks a benign canary to its owner with mode 600, watches a second user get Permission denied, flips one bit with chmod o+r, and watches the same user read the secret. No copy, no new process, no changed bytes. Then the defense: read the mode column, hunt the drift across the tree with one find command, capture evidence before restoring the lock, and install the scheduled sweep that flags the next drift. Two actors: the attacker, who owns the file and the chmod; and the defender, who owns the reads, the drift hunt, the evidence-first mitigation, and the sweep in the blue phase.
Why this technique. Access control lives in metadata, not in the file. The kernel checks the permission bits before it ever reads a byte, so changing who may read a secret does not require touching the secret. An attacker who already owns a file, or has write access to its metadata, can hand it to a partner identity quietly: no new file to find, no content change for integrity monitoring to flag. The hiding place is not a hidden file; it is the assumption that a file that was locked yesterday is locked today.
Why not the copy. The obvious alternative is copying the secret somewhere world-readable. Break it on the concrete check: the copy is a new artifact with a new name, visible to any listing and any integrity baseline, and it doubles the places the secret lives. The chmod leaves the file in place, same name, same bytes, same size. The attack surface is exactly one metadata column, and that column is the whole story.
The mechanism, in one line. Permission bits are the rwx triple for user, group, and other, stored with the file, not in it. The octal mode is the compact number: 600 means the owner reads and writes and nobody else does anything; 604 adds read for everyone else. chmod o+r sets that other-read bit. The second identity here is the nobody user, uid 65534, standing in for a compromised low-privilege account: the kernel checks its access against the same bits. Terms earned, no borrowing.
The concrete case, before the abstraction. In /tmp/gh019: backup.key, 22 bytes, mode 600. runuser -u nobody -- cat: Permission denied. chmod o+r: mode 604. runuser -u nobody -- cat: GHOSTLIGHT-CANARY-019. Same file, same user, same command, a different answer. That one changed column is the whole technique.
Scope. T1222.002 covers permission modification on Linux and macOS: widening access as shown here, and the harder slice of setuid/setgid bits, which let an executed binary run with the file owner's privileges. This file works the widening-access case end to end: the lock, the denial, the chmod, the read, the drift hunt, the evidence-first mitigation, and the scheduled sweep. The setuid/setgid slice is named as the harder case, and the blue drift hunt already flags -perm -4000/-2000 for it. The canary is a benign token: it proves the read and does nothing else. The lab runs in a disposable namespace under /tmp because the blue phase plants, sweeps, and cleans 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/gh019, so cleanup is a single rm. The second identity is the nobody user, uid 65534, present on every standard Linux install. Everything else is coreutils and findutils.
One disposable directory, built from scratch. rm -rf /tmp/gh019 starts clean; mkdir -p and cd set up the lab; chmod 755 /tmp/gh019 keeps the directory traversable so the denial below proves the file's own bits did the work. printf writes the canary: \n is printf's newline escape, which is why the 21-character token lands as 22 bytes. chmod 600 backup.key locks the file to its owner: read and write for root, nothing for anyone else; ls -l shows the locked door: -rw-------.
GHOSTLIGHT-CANARY-019
GHOSTLIGHT-CANARY-019: the benign canary, a token that proves a read happened and does nothing else. One file, one lock, one secret. Everything below measures this file's bits.
The attacker locks a secret to its owner, confirms the second user is denied, then opens the door with one chmod.
rm -rf /tmp/gh019; mkdir -p /tmp/gh019; chmod 755 /tmp/gh019; cd /tmp/gh019 rebuilds the lab. printf writes the canary; chmod 600 backup.key locks it to the owner. ls -l shows the locked door: -rw-------, read and write for the owner, nothing for anyone else. The directory stays traversable on purpose: whatever happens next is the file's own bits doing the work.
$ rm -rf /tmp/gh019; mkdir -p /tmp/gh019; chmod 755 /tmp/gh019; cd /tmp/gh019 printf 'GHOSTLIGHT-CANARY-019\n' > backup.key; chmod 600 backup.key; ls -l total 4 -rw------- 1 root root 22 Sep 26 23:19 backup.key
runuser -u nobody -- cat /tmp/gh019/backup.key: cat: /tmp/gh019/backup.key: Permission denied, recorded honestly with rc 1. The nobody user, uid 65534, stands in for a compromised low-privilege account: the kernel checked its access against the file's bits and said no. The denial is the baseline; everything after it measures what one chmod changes.
$ runuser -u nobody -- cat /tmp/gh019/backup.key cat: /tmp/gh019/backup.key: Permission denied
chmod o+r backup.key sets the other-read bit: the one metadata column flips. ls -l shows the open door: -rw----r--, mode 604. Same name, same size, same bytes; the only thing that changed is the third character of the mode.
$ chmod o+r backup.key; ls -l total 4 -rw----r-- 1 root root 22 Sep 26 23:19 backup.key
The same user, the same command, a different answer: runuser -u nobody -- cat /tmp/gh019/backup.key prints GHOSTLIGHT-CANARY-019. The secret crossed the boundary without a copy, without a new process, without a changed byte. The canary is benign: it proves the read and does nothing else.
$ runuser -u nobody -- cat /tmp/gh019/backup.key GHOSTLIGHT-CANARY-019
One echo line, the attacker's summary: one chmod, the file is everyone's. The attack left no new artifact for a listing to find and no content change for integrity monitoring to flag: the only signal is the mode column.
$ echo "stealth confirmed: one chmod, the file is everyone's" stealth confirmed: one chmod, the file is everyone's
The locked file denied the second user; one chmod opened it. Same name, same size, same bytes; the second user read the secret with no copy and no new process. The whole attack lived in one permission bit.
The defender reads the mode column the attacker changed, hunts the drift across the tree, captures evidence before restoring the lock, and installs the sweep that flags the next drift.
Here is the trap: reading the listing, seeing backup.key sitting where it always sat, and moving on. The name, the size, and the bytes are all unchanged, so a content-based check finds nothing. The detection starts in the one column the attacker touched.
cd /tmp/gh019 && ls -l: backup.key, 22 bytes, sitting where the red phase left it. Stopping here is the attacker's win: the name, size, and date are all innocent. The tell is one column left of the name.
$ cd /tmp/gh019 && ls -l total 4 -rw----r-- 1 root root 22 Sep 26 23:19 backup.key
stat -c '%a %U %G %n' backup.key reads the file's metadata, not its bytes: 604 root root backup.key. Six: read and write for the owner. Zero: nothing for the group. Four: read for everyone else. The number is the evidence: the baseline was 600, and the last column is the whole incident.
$ stat -c '%a %U %G %n' backup.key 604 root root backup.key
find /tmp/gh019 -type f \( -perm -4000 -o -perm -2000 -o -perm -o+r -o -perm -o+w \) -ls flags every file carrying drift: setuid, setgid, world-readable, world-writable. It catches backup.key by its world-read bit, and it also catches the harder slice, the -perm -4000/-2000 setuid/setgid bits that turn execution into the owner's privileges. One command, the whole tree.
$ find /tmp/gh019 -type f \( -perm -4000 -o -perm -2000 -o -perm -o+r -o -perm -o+w \) -ls
3 4 -rw----r-- 1 root root 22 Sep 26 23:19 /tmp/gh019/backup.key
command -v auditctl answers with an empty line, recorded honestly with rc 1: no auditd in this lab. The rule for a real host is stated with its dependency, not demonstrated: auditctl -w /path/to/backup.key -p wa -k perm-change records who flipped the bit, but it needs the audit subsystem enabled and its rules loaded, which this lab and many containers lack. Where it runs, the good-versus-bad is concrete: good is the owner changing their own file; bad is a mode flip nobody announced.
$ command -v auditctl
The heredoc writes sweep.sh: the drift one-liner wrapped in a script, running over a directory given as an argument and defaulting to the current one. chmod +x; ./sweep.sh /tmp/gh019 flags backup.key. The sweep watches metadata, not names or bytes: it catches the attack class the content checks miss.
$ cat > sweep.sh <<'EOF'
#!/bin/sh
# flag permission drift: setuid/setgid bits, world read/write on files
find "${1:-.}" -type f \( -perm -4000 -o -perm -2000 -o -perm -o+r -o -perm -o+w \) -ls
EOF
chmod +x sweep.sh && ./sweep.sh /tmp/gh019
3 4 -rw----r-- 1 root root 22 Sep 26 23:19 /tmp/gh019/backup.key
mkdir -p evidence && sha256sum backup.key | tee evidence/hash.txt && cp backup.key evidence/ captures the hash (044d04c9fc2247165b1f01a504d021bea81264fe9812020107d3e11e02c326ad) and the file BEFORE the fix, because restoring the lock comes next. chmod o-r backup.key takes the other-read bit back off. Verify: ls -l shows -rw------- again. The drift is closed; the evidence is preserved. Scope: the drift hunt covered the tree.
$ mkdir -p evidence && sha256sum backup.key | tee evidence/hash.txt && cp backup.key evidence/ && chmod o-r backup.key && ls -l 044d04c9fc2247165b1f01a504d021bea81264fe9812020107d3e11e02c326ad backup.key total 8 -rw------- 1 root root 22 Sep 26 23:19 backup.key drwxrwx--- 2 root root 80 Sep 26 23:19 evidence -rwxrwx--- 1 root root 169 Sep 26 23:19 sweep.sh
The same user, the same command, the baseline answer: runuser -u nobody -- cat /tmp/gh019/backup.key fails with cat: /tmp/gh019/backup.key: Permission denied, recorded honestly. ./sweep.sh /tmp/gh019 runs clean, printing nothing: the drift is gone, and the sweep agrees.
$ runuser -u nobody -- cat /tmp/gh019/backup.key; ./sweep.sh /tmp/gh019 cat: /tmp/gh019/backup.key: Permission denied
The summary, in the defender's own words: the mode is the evidence. rm -rf /tmp/gh019 removes the lab.
$ echo "detection verified: the mode is the evidence"; rm -rf /tmp/gh019 detection verified: the mode is the evidence
stat read the changed mode, 604 against the 600 baseline; the one-line drift hunt flagged the file and covers setuid/setgid; evidence was hashed and copied before the lock was restored; the second user was denied again; the sweep ran clean. The mode is the evidence.
Three moves, in order: restore the lock with evidence first, sweep on a schedule, deny by default. Each is one way, not the way.
Proven first against the live plant: sha256sum | tee and cp capture the hash and the file into evidence/ BEFORE the fix; chmod o-r restores the 600 lock; the denied re-read (Permission denied, rc 1 on the read itself) and the clean sweep confirm scope. A real response then asks how the bit got flipped: the chmod is the incident's open question.
$ mkdir -p evidence && sha256sum backup.key | tee evidence/hash.txt && cp backup.key evidence/ && chmod o-r backup.key && ls -l 044d04c9fc2247165b1f01a504d021bea81264fe9812020107d3e11e02c326ad backup.key total 8 -rw------- 1 root root 22 Sep 26 23:19 backup.key drwxrwx--- 2 root root 80 Sep 26 23:19 evidence -rwxrwx--- 1 root root 169 Sep 26 23:19 sweep.sh
Honest limit. Restoring the lock is not the same as understanding the flip: anyone who could chmod once can chmod again, which is why the hunt covers the whole tree and the sweep runs on a schedule. The lab removes the tree for cleanliness; a real incident preserves evidence/ and the original file for forensics instead.
The scheduled form of the phase-blue read: sweep.sh runs the drift one-liner over sensitive trees, and the tell is any mode that widened since the baseline: world-read, world-write, setuid, setgid. Plus the file-watch auditd rule, stated with its dependency: it needs the audit subsystem enabled and its rules loaded, which this lab lacks but production hosts can have. D3FEND D3-LFP: Local File Permissions is the production form of "the lock is the policy", and D3FEND D3-FAPA: File Access Pattern Analysis covers the odd read after the drift. Honest note: these are the natural defensive coverage for this attack, not a claimed direct mapping to T1222.002.
$ find "${1:-.}" -type f \( -perm -4000 -o -perm -2000 -o -perm -o+r -o -perm -o+w \) -ls
3 4 -rw----r-- 1 root root 22 Sep 26 23:19 /tmp/gh019/backup.key
Honest limit. The sweep catches drift against a known baseline only; a file that was born world-readable never trips it. The poll interval sets the detection floor: a bit flipped and flipped back between sweeps leaves no trace, only the audit log, if auditd was watching. The sweep reports the mode; it does not know whether the owner meant it.
The demonstrated sweep detects; only the ownership policy prevents. The durable control is a default-deny permission posture on sensitive files, 600 or 640, enforced at creation by umask and verified by the scheduled sweep: a file that can never be world-readable cannot be opened this way. Honest note, repeated because it matters: the sweep detects; only the deny-by-default posture prevents.
Honest limit. A strict umask is the strongest control here and the heaviest to operate: every legitimate shared file needs an explicit grant, and the grants need ownership. The audit rule only covers paths it watches; a file arriving outside the watched tree flips its bits unwatched.
The file was hashed and copied before the lock was restored, the restore closed the drift (Permission denied on re-read), the scheduled sweep names its tell and ran clean after the fix, and the prevention control is stated with its dependency. Every control names its bypass: the sweep needs a baseline; the poll interval sets the floor; the audit rule needs auditd; and only a deny-by-default posture prevents.
The bytes never changed; the lock did. Read the mode column, not just the content.
IOC checklist: signs this technique was used
Reproducibility checklist
Sources
MITRE ATT&CK T1222.002: File and Directory Permissions Modification: Linux and Mac File and Directory Permissions Modification
MITRE ATT&CK T1222: File and Directory Permissions Modification (the parent technique)
chmod(1), stat(1), find(1), runuser(1)
D3FEND D3-LFP: Local File Permissions
D3FEND D3-FAPA: File Access Pattern Analysis
The next file hides a payload where the listing never looks.