GH-005 T1070.006 PHASE RED INSIDE

The Forged Clock

This file was last modified in 2019. It was created nine minutes ago. One command forged the date; one command catches the forgery. This file runs both.

TechniqueTimestomp (file timestamps)
Target OSUbuntu 24.04.5 LTS
Toolchaincoreutils
LevelBeginner
Time20 min

OBJECTIVES

  1. Backdate a new payload to 2019 with touch, and watch ls report it as old
  2. Catch the forgery in stat: the kernel's own timestamp still says today
  3. Hunt timestomped files with one find command
  4. Take the IOC checklist and the one-sentence lesson
01

Intel Brief

CONTEXT

MITRE ATT&CK T1070.006: adversaries rewrite file timestamps so a fresh payload looks years old. This file forges the date with the standard tool, then reads the timestamp the forgery cannot touch.

Why this technique. After a breach, the first question is "what changed recently," and the answer comes from timestamps. A responder sorts /tmp by date, and everything from 2019 scrolls past unexamined. Timestomping forges the answer to that first question: the payload sits in plain sight, wearing the date of an innocent era.

Why the default view loses. ls -l shows one timestamp, the modification time, and nothing else. The other timestamps exist, but you have to ask for them with stat. The forgery targets the default view, because the default view is what gets read at 3 AM.

Why one timestamp survives. A file on Linux carries four timestamps. atime is the last read. mtime is the last content write, and the owner may set it freely with the utimensat syscall (that is what touch -d calls). ctime is the last time the file's metadata changed, and the kernel sets it itself on every metadata write: there is no syscall that sets ctime to an arbitrary value. btime, the birth time, records creation where the filesystem supports it. Forging mtime is one syscall the owner is allowed to make; it updates ctime to right now as a side effect, and the kernel keeps the receipt.

The concrete case, before the abstraction. touch -d '2019-06-11 03:14:00' .systemd-cache backdates a file created today. ls -l reports 2019. stat reports Modify: 2019, Change: today. Same file, two stories; only the second one was written by the kernel.

Terms, earned. mtime is the modification timestamp, the one ls shows, settable by the file's owner. ctime is the change timestamp, set by the kernel whenever the file's metadata changes, not settable to an arbitrary value. btime is the birth timestamp, the file's creation time. Timestomp is T1070.006: rewriting timestamps to mislead forensic timelines.

Scope. T1070, Indicator Removal, has eight sub-techniques, from clearing logs to deleting files. This file works the timestamp one end to end: the forgery every responder's first sort is vulnerable to, and the receipt that survives it.

02

Target Environment

LOADOUT

Ubuntu 24.04.5 LTS, x86-64, in a disposable VM used only for this lab. The attack is one coreutils command and needs no privilege: any user can set the timestamps on their own files. The lab directory is /tmp/gh005.

1

Build the lab

There is nothing to compile. The payload is eighteen bytes of text with an inconspicuous name, because the filename and the date do all the work.

bash
$ mkdir -p /tmp/gh005 && cd /tmp/gh005
$ echo 'staged payload v3' > .systemd-cache

A dotfile named like a systemd cache entry, in /tmp. Nothing about it demands attention, and after Phase Red, nothing about its date will either.

03

Phase Red: backdate the evidence

ATTACK

One command reaches seven years into the past. Then ask the directory listing when the file was modified, and believe the answer the way a tired responder would.

Real screen recording 9.3s
What you are watching: A file created today is given a 2019 modification date. The directory listing reports it as seven years old. Every command below is copy-pasteable.
1

Forge the date

The payload was created minutes ago. After this command, every default listing will say 2019.

bash
$ echo 'staged payload v3' > .systemd-cache
$ touch -d '2019-06-11 03:14:00' .systemd-cache
$ ls -l --time-style=long-iso .systemd-cache
-rw-rw---- 1 root root 18 2019-06-11 03:14 .systemd-cache

June 2019. A responder sorting /tmp by modification date to find "what changed recently" scrolls straight past it; the file predates the incident window, the investigation, and possibly the responder's employment. The forgery is complete, it used a standard tool, and it left the file's contents untouched. Nothing about this file looks new, because new was the one attribute the attacker was allowed to rewrite.

Stealth confirmed

One touch command gave a minutes-old payload a seven-year-old date, and the standard directory listing vouches for it. The forgery is a legitimate syscall doing exactly what it was designed to do, which is why no permission was denied and no alarm fired.

04

Phase Blue: read the receipt

DEFENSE

ls showed the timestamp the file's owner chose. Now read all four timestamps, including the one the owner cannot choose.

Here is the trap: sorting by date, seeing 2019, and moving on. The modification time is the file's own story about itself, and the owner is allowed to edit their own story. The kernel keeps a separate receipt, and the receipt cannot be edited with touch.

Real screen recording 8.0s
What you are watching: stat prints all three timestamps. Modify says 2019; Change says today. The forgery is caught by the receipt. Every command below is copy-pasteable.
1

Ask for every timestamp

Same file ls just vouched for. Three timestamps, and they do not agree.

bash
$ stat -c 'access: %x' .systemd-cache
access: 2019-06-11 03:14:00.000000000 +0000
$ stat -c 'modify: %y' .systemd-cache
modify: 2019-06-11 03:14:00.000000000 +0000
$ stat -c 'change: %z' .systemd-cache
change: 2026-09-19 19:22:25.971542372 +0000

Modify says 2019, exactly as forged. Change says today, down to the nanosecond: the moment the touch command rewrote the metadata. The attacker set the clock on the file, and the kernel timestamped the act of setting it. A file whose modification date is years older than its change date is not old; it is edited. The full stat output adds a fourth witness, the birth time, also today. Two timestamps the owner set, two the kernel wrote, and the kernel's are the ones that matter.

Detection verified

One stat command exposed the forgery ls could not see. The check needs no baseline and no tooling: mtime is the claim, ctime is the receipt, and the receipt is written by the kernel.

05

Countermeasures

DEFENSE

Four moves, in order: hunt by the receipt, baseline the metadata, stop trusting the claim, freeze the evidence. Each is one way, not the way.

1

Hunt by change time, not modify time

If you are hunting the payload, do not sort by mtime; the attacker chose that sort order. Sort by ctime: the kernel's record of when the metadata was actually touched.

bash
$ find /tmp /var/tmp /dev/shm -newerct '2026-09-01' -type f -printf '%p change=%C+ modify=%T+\n' 2>/dev/null
/tmp/gh005/.systemd-cache change=2026-09-16+15:26:23.0247667980 modify=2019-06-11+03:14:00.0000000000

One line, and the "2019" file is the newest thing in /tmp. Printing change and modify side by side turns every timestomped file into a self-confession: the wider the gap, the louder the lie.

2

Prevent: baseline the metadata, not just the bytes

A hash-only baseline is blind to timestomping: the bytes never change, so the hash never changes. Record the metadata the attacker cannot forge instead: inode, size, mtime, and ctime. The check below is copy-pasteable.

bash
$ find /tmp /var/tmp /dev/shm -type f -printf '%p|%i|%s|%T@|%C@\n' 2>/dev/null | sort > /root/fim-baseline.txt
$ # ...later, after the window you care about...
$ find /tmp /var/tmp /dev/shm -type f -printf '%p|%i|%s|%T@|%C@\n' 2>/dev/null | sort > /root/fim-check.txt
$ diff /root/fim-baseline.txt /root/fim-check.txt

What a catch looks like (real output: baseline taken, file re-forged, baseline re-taken):

output
1c1
< .systemd-cache inode=3 size=18 mtime=2018-01-01 00:00:00.000000000 +0000 ctime=2026-09-19 19:22:25.989542372 +0000
---
> .systemd-cache inode=3 size=18 mtime=2019-06-11 03:14:00.000000000 +0000 ctime=2026-09-19 19:22:27.100542415 +0000

Inode and size identical, ctime moved: someone touched the metadata. An mtime-only check sees the same 2019 date before and after and reports nothing.

Good vs bad: a legitimately old file has change and modify dates close together; a timestomped file has them years apart, and a re-forged file has a ctime newer than its baseline entry. Alert on ctime newer than baseline with mtime unchanged or older.

Honest limit. FIM sees only what changed after the baseline was taken; a file timestomped before the first scan looks legitimately old to it. ctime trusts the system clock: an attacker who can set the clock (root, or the VM host) can narrow the gap. And ctime is per-filesystem: copying the file elsewhere mints fresh stamps, so a payload smuggled in as a copy carries no gap to find (verified: cp -p preserved the forged 2019 mtime with fresh birth and change stamps). The receipt is honest, not omniscient.

First principle: distrust the claim, read the receipt. mtime is the file's own story about itself; ctime is the kernel's record of the edit, and the two are written by different authors.

3

Prevent: nothing to prevent, everything to distrust

There is no prevention here, and that is the point. Setting timestamps is a legitimate syscall; touch is coreutils, utimensat is how backups and build tools preserve dates. You cannot remove the capability without breaking the system. The control is procedural: never let mtime alone decide what is old. Triage sorts by ctime, FIM baselines include metadata, and timelines are built from the receipt, not the claim.

4

Mitigate: freeze the metadata, then rebuild the timeline from elsewhere

Hunting finds the file; mitigation preserves what it proves. On a live box:

1. Capture the receipt before it ages: stat the suspect file now. ctime only tells you the last metadata change; every later touch overwrites it.

bash
$ stat /tmp/.systemd-cache > /root/evidence-stat.txt

2. Do not trust any local timeline built from mtime. Rebuild from sources the attacker could not rewrite with touch: the off-host log collector, network flow records, and the FIM baseline diff above.

3. Isolate the host from the network before cleanup. Deleting the file ends the payload but also ends the evidence; image or snapshot first if the incident warrants it.

What this does not do: it does not prevent the next forge. Prevention is the baseline above, run on a schedule. Mitigation buys you the true story of this one.

First principle: evidence has a half-life. ctime is overwritten by the next touch, so the containment step is capture, not analysis.

Countermeasures verified

The capability cannot be removed without breaking the system, so the forgery is seen through, not prevented. Hunting by ctime finds the payload despite its 2019 costume, FIM baselines catch the metadata change, and the procedural fix costs nothing: read the receipt, not the story.

06

Debrief

TAKEAWAY

mtime is the file's own story about itself. ctime is the kernel's receipt for the edit. touch cannot rewrite the receipt.

IOC checklist: signs this technique was used

  • Files whose mtime is far older than their ctime: the signature gap
  • Executables or dotfiles in /tmp, /var/tmp, /dev/shm with old-looking dates
  • Clusters of files sharing one identical forged timestamp (attackers backdate in bulk)
  • Birth times (btime) much newer than modification times
  • Timelines where the payload's mtime predates the intrusion window it was found in

Reproducibility checklist

  • Verified on Ubuntu 24.04.5 LTS, x86-64, on 2026-09-16
  • Both recordings are real executions on that platform, not simulations
  • The attack runs fully unprivileged: touch on your own files needs no privilege
  • Cleanup: rm -rf /tmp/gh005

Sources

MITRE ATT&CK T1070.006: Timestomp
utimensat(2) (the syscall touch uses; note what it cannot set)
stat(1) (reading all four timestamps)
MITRE D3FEND: D3-FIM

Next file

GH-006 The Missing Lines

The log says nothing happened. A second copy of the log, written as each event happened, disagrees.