A payload sits on this box with a 45-second fuse and one job: phone home once, then exit. The sandbox watches for 20 seconds, sees nothing, and stamps it clean. This file waits out the clock with the payload, then reads the next sleeper's schedule off its own command line and kills it before the appointment.
MITRE ATT&CK T1678: adversaries schedule the malicious act in the future, so any defense that stops watching first sees nothing. This file runs a 45-second fuse against a 20-second watch, then shows the read that beats it. Two actors: the attacker, who owns the payload and its listener, and the defender, who owns the sandbox, the scans, and every inventory in the blue phase.
Why this technique. A verdict costs money by the minute. An automated sandbox rents each sample a fixed time budget: run it, watch it, stamp it, move on. The attacker knows the budget and simply waits it out. Nothing about the payload has to be clever. It does not hide, it does not encrypt itself, it does not check whether it is being watched. It sleeps. At second 21, or minute 6, or next Tuesday, it wakes and does the one thing it came to do. The defense did not fail to look; it stopped looking before there was anything to see.
Why not hide the payload instead. The obvious alternative is obfuscation: pack it, encrypt it, scramble the strings. Break it on the concrete input: the sandbox still runs it. Obfuscation slows the human analyst, but a detonated sample shows its behavior anyway, and the verdict comes from behavior, not from reading the binary. Delay attacks the verdict itself: the verdict is a function of the observation window, and the attacker picks a window the sandbox cannot afford.
Why not detect the sandbox. The other obvious alternative is fingerprinting: check for a VM, a debugger, a short uptime, and stay quiet only there. Break it: fingerprinting is an arms race, it is brittle (one wrong check and the payload never fires on the real target), and the checks themselves are detectable in turn. Delay needs no fingerprint. It works on every box with a clock, real or virtual, because the clock is the one thing the sandbox cannot take away.
The mechanism, in one line. Delay execution is scheduling the malicious act in the future through a legitimate wait: here, one time.sleep call, which is one nanosleep syscall underneath. The fuse is the wait between launch and the act. The observation window is how long the defender watches. A sandbox is automated analysis that runs a sample for a fixed time budget and stamps a verdict. The beacon is the payload's one network act: a TCP connect and a single line. The wchan, the kernel wait channel, is what a sleeping process is parked in, readable at /proc/PID/wchan. Terms earned, no borrowing.
The concrete case, before the abstraction. delayer.py --wait 45 --beacon 4100. The sandbox watches 20 seconds: beacon.log stays empty, verdict CLEAN. At 45 seconds the beacon lands on port 4100. One sleep, one connect, one line.
Scope. T1678 covers time-based evasion broadly: sleeps, scheduled tasks, far-future trigger dates. This file works the sleep-fuse case end to end: the wait, the appointment, and the schedule read that catches the next one. The constants are compressed for the lab: real sandboxes typically detonate a sample for 2 to 5 minutes, and real payloads sleep 10 or more minutes or aim at a far-future date. The mechanism is window length, not the specific value.
Ubuntu 24.04.5 LTS, x86-64, in a disposable namespace used only for this lab. Everything runs as the current user; no root needed. The lab is lab-local: 127.0.0.1 only, nothing leaves the box.
One disposable directory, plus a pre-flight that kills any stray payload or listener on the lab ports from an earlier run. Everything the lab touches lives inside /tmp/gh014, so cleanup is a single rm.
$ pkill -f 'delayer\.py' 2>/dev/null; pkill -f 'nc -l 127.0.0.1 41' 2>/dev/null; rm -rf /tmp/gh014 && mkdir -p /tmp/gh014 && echo "lab built: /tmp/gh014" lab built: /tmp/gh014
Line by line. #!/usr/bin/env python3 runs the file under python3. The docstring says what the file is: sleep, then beacon. The three imports: socket for the beacon connect, sys for reading the command line, time for the fuse. WAIT reads the fuse length off the process's own command line: sys.argv.index('--wait') finds the flag, plus one is its value. PORT does the same for --beacon. This is the detail the blue phase exploits: the schedule is printed on the process for anyone who looks. time.sleep(WAIT) is the fuse: one syscall, nothing happens until it returns. socket.create_connection(('127.0.0.1', PORT), timeout=10) is the one malicious act: a TCP connect to the listener, lab-local only. sendall(b'GH-014 beacon ') sends the beacon line. close() ends the connect, and the process exits. The technique is the clock.
$ cat > /tmp/gh014/delayer.py <<'EOF'
#!/usr/bin/env python3
"""GH-014 lab payload: sleeps --wait seconds, then beacons to 127.0.0.1:PORT.
The delay is the whole technique (T1678): any observer whose watch window
is shorter than the fuse sees nothing."""
import socket
import sys
import time
WAIT = int(sys.argv[sys.argv.index('--wait') + 1])
PORT = int(sys.argv[sys.argv.index('--beacon') + 1])
time.sleep(WAIT) # the fuse: nothing happens until this returns
s = socket.create_connection(('127.0.0.1', PORT), timeout=10)
s.sendall(b'GH-014 beacon\n') # the payload's one malicious act
s.close()
EOF
chmod +x /tmp/gh014/delayer.py && echo "payload written: $(wc -l < /tmp/gh014/delayer.py) lines"
payload written: 16 lines
timeout 90 nc -l 127.0.0.1 4100 is the attacker's listener: it holds port 4100 and writes the first connect's bytes to beacon.log, then exits. timeout 90 is a backstop so a failed take never hangs the lab. python3 /tmp/gh014/delayer.py --wait 45 --beacon 4100 & launches the payload in the background; $! is its pid, kept in DELAYER. The fuse is 45 seconds; the beacon goes to port 4100.
$ timeout 90 nc -l 127.0.0.1 4100 > /tmp/gh014/beacon.log 2>&1 & LISTENER=$!; sleep 1; python3 /tmp/gh014/delayer.py --wait 45 --beacon 4100 & DELAYER=$!; echo "payload pid=$DELAYER (fuse: 45s, beacon port 4100)" [1] 12 [2] 15 payload pid=15 (fuse: 45s, beacon port 4100)
First the sandbox's view: 20 seconds of silence, then a verdict. Then the appointment the sandbox missed.
sleep 20 is the sandbox: a fixed observation window, then a verdict. beacon.log is empty: nothing arrived. The verdict is CLEAN, honestly observed for 20 seconds. The honest part matters: the sandbox did its job. Its job was just shorter than the fuse.
$ echo "--- the sandbox watches for 20 seconds ---"; sleep 20; echo "--- sandbox watch ends ---"; [ -s /tmp/gh014/beacon.log ] && cat /tmp/gh014/beacon.log || echo "(beacon.log empty: nothing arrived)"; echo "sandbox verdict: CLEAN (observed 20s)" --- the sandbox watches for 20 seconds --- --- sandbox watch ends --- (beacon.log empty: nothing arrived) sandbox verdict: CLEAN (observed 20s)
wait $LISTENER blocks until the listener exits, which happens when the beacon arrives. At t+45s the log shows one line: GH-014 beacon. The payload kept its appointment; nobody was watching.
$ echo "--- waiting for the appointment (t+45s) ---"; wait $LISTENER; echo "--- the listener exited: the beacon arrived ---"; cat /tmp/gh014/beacon.log --- waiting for the appointment (t+45s) --- --- the listener exited: the beacon arrived --- GH-014 beacon
wait $DELAYER reaps the payload; ps -p confirms it exited after firing. The 20-second watch looked away too early, and the fuse kept burning to t+45s.
$ wait $DELAYER 2>/dev/null; ps -p $DELAYER >/dev/null 2>&1 && echo "payload still alive (unexpected)" || echo "payload exited after firing"; echo "stealth confirmed: the 20s watch looked away too early, the fuse kept burning to t+45s" payload exited after firing stealth confirmed: the 20s watch looked away too early, the fuse kept burning to t+45s
The sandbox watched for 20 seconds, saw nothing, and stamped the payload clean. At 45 seconds the payload woke, connected, sent its beacon, and exited. A verdict with a time limit is a bet the attacker can outwait, and the attacker sets the odds.
The defender does not wait out the fuse; the defender reads it. A sleeper's start time plus its delay is its fire time, and both are on the box right now.
Here is the trap: watching the specimen until it fires and calling the beacon the detection. That is the sandbox's mistake with a human watching. The detection is the schedule read: start time plus delay, computed in seconds, while the fuse is still burning.
timeout 400 nc -l 127.0.0.1 4101 is the defender's listener this time: it must exist so the specimen's beacon would be caught, which makes the beacon's absence the proof the kill worked. The specimen launches with --wait 300 --beacon 4101. ps -eo pid,etime,stat,args shows it parked in S state, elapsed time ticking, the full command line visible. Good versus bad, concrete: good is a known updater sleeping on a documented schedule; bad is an unknown python binary from /tmp parked in a sleep with a 300-second fuse and a beacon target on its own command line.
$ echo "--- DETECTION: a sleeper with a schedule ---"; timeout 400 nc -l 127.0.0.1 4101 > /tmp/gh014/specimen-beacon.log 2>&1 & BLIST=$!; SPEC_START=$(date +%s); python3 /tmp/gh014/delayer.py --wait 300 --beacon 4101 & SPEC=$!; sleep 2; echo "specimen pid=$SPEC"; ps -eo pid,etime,stat,args | grep "[d]elayer"; echo "good: a known updater sleeping on a documented schedule"; echo "bad: an unknown python from /tmp parked in S with a 300s fuse and a beacon target on its command line"
--- DETECTION: a sleeper with a schedule ---
[1] 19
[2] 22
specimen pid=22
22 00:02 S python3 /tmp/gh014/delayer.py --wait 300 --beacon 4101
good: a known updater sleeping on a documented schedule
bad: an unknown python from /tmp parked in S with a 300s fuse and a beacon target on its command line
ps -o lstart= gives the process start time: the wall-clock moment the fuse started burning. date -d turns it into epoch seconds, plus 300 is the fire time, formatted back for a human. No waiting involved: the appointment is computed while the specimen sleeps. /proc/PID/wchan shows hrtimer_nanosleep: the kernel's own word for what the process is parked in. ATT&CK's detection guidance for T1678 names exactly this shape: a sleep-class wait in a short-lived chain with no user interaction.
$ echo "--- read the schedule, without waiting for it ---"; echo "process start: $(ps -o lstart= -p $SPEC)"; START=$(date -d "$(ps -o lstart= -p $SPEC)" +%s); echo "fires at: $(date -d "@$((START + 300))" "+%F %T %Z")"; echo "--- what the kernel says it is parked in ---"; cat /proc/$SPEC/wchan; echo --- read the schedule, without waiting for it --- process start: Mon Sep 21 00:06:09 2026 fires at: 2026-09-21 00:11:09 UTC --- what the kernel says it is parked in --- hrtimer_nanosleep
/proc/PID/cmdline names the appointment (--wait 300) and the messenger (--beacon 4101): the schedule and the target, in the open. /proc/PID/exe points at /usr/bin/python3.12: that is how it runs. /proc/PID/cwd shows /tmp, the working directory it was launched from; the payload file itself sits in /tmp/gh014. The appointment, the messenger, and the launch site, all without touching the binary.
$ echo "--- correlate: the appointment, the messenger, the launch site ---"; tr "\0" " " < /proc/$SPEC/cmdline; echo; ls -l /proc/$SPEC/exe; readlink /proc/$SPEC/cwd --- correlate: the appointment, the messenger, the launch site --- python3 /tmp/gh014/delayer.py --wait 300 --beacon 4101 lrwxrwxrwx 1 root root 0 Sep 21 00:06 /proc/22/exe -> /usr/bin/python3.12 /tmp
kill $SPEC stops the specimen before the fuse burns; ps -p confirms it is dead, never assumed. kill $BLIST stops the defender's listener. specimen-beacon.log is empty: the appointment was cancelled, proven by absence. The window is scoped: the specimen lived a few seconds of its 300-second fuse, so nothing fired inside it. The persistence sweep checks the three places a respawn hides: crontab -l, the systemd units, and stray files in /tmp. The honest detail: crontab is not installed on this lab box, so there is nothing to check there; on a real host this is where the sweep matters.
$ echo "--- MITIGATION: kill the sleeper before the fuse burns ---"; kill $SPEC; sleep 1; ps -p $SPEC >/dev/null 2>&1 && echo "STILL ALIVE" || echo "specimen dead"; kill $BLIST 2>/dev/null; [ -s /tmp/gh014/specimen-beacon.log ] && echo "BEACON ARRIVED (bad)" || echo "no beacon: the appointment was cancelled"; echo "--- scope the window ---"; echo "specimen lived $(( $(date +%s) - SPEC_START ))s of its 300s fuse; nothing fired"; echo "--- persistence sweep ---"; crontab -l 2>&1 | head -3; ls /etc/systemd/system/ 2>/dev/null | grep -iE 'delayer|gh014' || echo 'no gh014 systemd units'; ls /tmp | grep gh014 --- MITIGATION: kill the sleeper before the fuse burns --- specimen dead no beacon: the appointment was cancelled --- scope the window --- specimen lived 3s of its 300s fuse; nothing fired --- persistence sweep --- bash: crontab: command not found no gh014 systemd units gh014
ps -eo args | grep finds no delayer processes. ss -tln shows no listener on 4101. The beacon log is empty. Three independent confirmations: the process is gone, the port is dark, the act never happened.
$ echo "--- confirm ---"; ps -eo args | grep "[d]elayer" || echo "no delayer processes"; ss -tln | grep ":4101 " || echo "no listener on 4101"; [ -s /tmp/gh014/specimen-beacon.log ] || echo "specimen-beacon.log empty: no beacon ever arrived" --- confirm --- no delayer processes no listener on 4101 specimen-beacon.log empty: no beacon ever arrived
Two durable controls. First, application control: only approved binaries run, so a python beaconer from /tmp never launches in the first place. Second, the scheduled inventory: snapshot ss -tlnp known-good, and diff it on a timer; the check is one diff. The honest limits, stated plainly: ATT&CK says T1678 cannot be easily mitigated with preventive controls, because it abuses legitimate system features; sleep is a legitimate syscall, so behavior alone cannot be blocked without breaking normal software. And polling has a floor: a sleeper that wakes between polls is missed, which is the observation-window problem again, in defender form.
$ echo "--- PREVENTION: application control plus a scheduled inventory ---"; echo "allowlist: only approved binaries run, a /tmp python beaconer never launches"; ss -tlnp > /tmp/gh014/listeners.baseline && echo "known-good baseline snapshot saved: $(wc -l < /tmp/gh014/listeners.baseline) lines"; echo "the scheduled check runs: diff listeners.baseline <(ss -tlnp)" --- PREVENTION: application control plus a scheduled inventory --- allowlist: only approved binaries run, a /tmp python beaconer never launches known-good baseline snapshot saved: 1 lines the scheduled check runs: diff listeners.baseline <(ss -tlnp)
The schedule was on the command line the whole time. The defender read it instead of waiting for it.
$ echo "detection verified: the sleeper was read, not waited out"; echo "the schedule was on the command line the whole time: start plus 300s" detection verified: the sleeper was read, not waited out the schedule was on the command line the whole time: start plus 300s
The sleeper was read, not waited out. Its start time plus its delay was its fire time, and both were on the box the whole time. The specimen died before the appointment, the beacon never arrived, and the window was scoped to seconds.
Kill any stray payload, remove the lab, confirm it is gone: no directory, no listeners on 4100 or 4101. The namespace dies with the session regardless; the cleanup keeps the record honest.
$ pkill -f 'delayer\.py' 2>/dev/null; sleep 1; rm -rf /tmp/gh014; ls /tmp | grep gh014 || echo "lab gone"; ss -tln | grep -E ":(4100|4101) " || echo "no fuse listeners on the box" lab gone no fuse listeners on the box
Three moves, in order: kill the sleeper before its timer fires, inventory the sleepers on a schedule, allowlist what may run. Each is one way, not the way.
Proven first against the live specimen: kill by pid, confirm dead, confirm the beacon never arrived. Scope the window from process start to kill: that is when the act could have happened. Sweep persistence: cron, systemd, /tmp strays. Remove the binary.
$ echo "--- MITIGATION: kill the sleeper before the fuse burns ---"; kill $SPEC; sleep 1; ps -p $SPEC >/dev/null 2>&1 && echo "STILL ALIVE" || echo "specimen dead"; kill $BLIST 2>/dev/null; [ -s /tmp/gh014/specimen-beacon.log ] && echo "BEACON ARRIVED (bad)" || echo "no beacon: the appointment was cancelled"; echo "--- scope the window ---"; echo "specimen lived $(( $(date +%s) - SPEC_START ))s of its 300s fuse; nothing fired"; echo "--- persistence sweep ---"; crontab -l 2>&1 | head -3; ls /etc/systemd/system/ 2>/dev/null | grep -iE 'delayer|gh014' || echo 'no gh014 systemd units'; ls /tmp | grep gh014 --- MITIGATION: kill the sleeper before the fuse burns --- specimen dead no beacon: the appointment was cancelled --- scope the window --- specimen lived 3s of its 300s fuse; nothing fired --- persistence sweep --- bash: crontab: command not found no gh014 systemd units gh014 $ echo "--- confirm ---"; ps -eo args | grep "[d]elayer" || echo "no delayer processes"; ss -tln | grep ":4101 " || echo "no listener on 4101"; [ -s /tmp/gh014/specimen-beacon.log ] || echo "specimen-beacon.log empty: no beacon ever arrived" --- confirm --- no delayer processes no listener on 4101 specimen-beacon.log empty: no beacon ever arrived
Honest limit. Killing stops this specimen; it does not find the launcher, and it does not undo anything a previous specimen already did. A kill without a window scope is an anecdote; the scope is what tells you whether the appointment was kept.
The scheduled form of the phase-blue read: snapshot the process inventory known-good, and diff it on a timer. The tell is an unknown binary parked in a sleep with a long fuse and a network target on its command line.
$ echo "--- DETECTION: a sleeper with a schedule ---"; timeout 400 nc -l 127.0.0.1 4101 > /tmp/gh014/specimen-beacon.log 2>&1 & BLIST=$!; SPEC_START=$(date +%s); python3 /tmp/gh014/delayer.py --wait 300 --beacon 4101 & SPEC=$!; sleep 2; echo "specimen pid=$SPEC"; ps -eo pid,etime,stat,args | grep "[d]elayer"; echo "good: a known updater sleeping on a documented schedule"; echo "bad: an unknown python from /tmp parked in S with a 300s fuse and a beacon target on its command line"
--- DETECTION: a sleeper with a schedule ---
[1] 19
[2] 22
specimen pid=22
22 00:02 S python3 /tmp/gh014/delayer.py --wait 300 --beacon 4101
good: a known updater sleeping on a documented schedule
bad: an unknown python from /tmp parked in S with a 300s fuse and a beacon target on its command line
$ echo "--- PREVENTION: application control plus a scheduled inventory ---"; echo "allowlist: only approved binaries run, a /tmp python beaconer never launches"; ss -tlnp > /tmp/gh014/listeners.baseline && echo "known-good baseline snapshot saved: $(wc -l < /tmp/gh014/listeners.baseline) lines"; echo "the scheduled check runs: diff listeners.baseline <(ss -tlnp)"
--- PREVENTION: application control plus a scheduled inventory ---
allowlist: only approved binaries run, a /tmp python beaconer never launches
known-good baseline snapshot saved: 1 lines
the scheduled check runs: diff listeners.baseline <(ss -tlnp)
Honest limit. ps shows the current truth only. A sleeper that wakes between polls is missed, so the poll interval sets the detection floor. Process-start audit logs are the backstop: the kernel remembers what ps forgot.
The durable form: execution prevention, so unapproved binaries never launch. A /tmp python beaconer is stopped at exec, not at fire time. Demonstrated above as the baseline snapshot plus the scheduled diff; the production form is the allowlist policy.
$ echo "--- PREVENTION: application control plus a scheduled inventory ---"; echo "allowlist: only approved binaries run, a /tmp python beaconer never launches"; ss -tlnp > /tmp/gh014/listeners.baseline && echo "known-good baseline snapshot saved: $(wc -l < /tmp/gh014/listeners.baseline) lines"; echo "the scheduled check runs: diff listeners.baseline <(ss -tlnp)" --- PREVENTION: application control plus a scheduled inventory --- allowlist: only approved binaries run, a /tmp python beaconer never launches known-good baseline snapshot saved: 1 lines the scheduled check runs: diff listeners.baseline <(ss -tlnp)
Honest limit. Allowlisting is a program, not a switch: it needs an inventory, an approval flow, and exceptions that attackers will study. And sleep itself must keep working for legitimate software, which is why ATT&CK says this technique cannot be easily mitigated with preventive controls. The allowlist stops the unknown binary; it does not stop a signed one from sleeping.
The specimen was killed by pid with its window scoped and persistence swept. The sleepers are inventoried on a schedule, and unapproved binaries never launch. The fuse still burns on an unwatched box; on a watched box it is just a line in the inventory.
A verdict with a time limit is a bet the attacker can outwait: read the schedule, don't trust the silence.
IOC checklist: signs this technique was used
Reproducibility checklist
Sources
MITRE ATT&CK T1678: Delay Execution
ps(1) (the sleeper inventory: etime, stat, lstart)
proc(5) (wchan, cmdline, exe, cwd)
date(1) (the fire-time arithmetic)
No D3FEND defender is modeled for T1678 in D3FEND 1.6.0, so the blue procedure comes from lab work plus ATT&CK's detection guidance; no D3FEND link is invented.
The next file hides a directory in plain sight with a bind mount.