Before it does anything, the payload asks where it is. A sandbox looks different from a real machine, and the question costs four reads of public system facts. This file runs the interrogation, then tries to lie to it.
MITRE ATT&CK T1497.001: before running its payload, malware checks whether it is inside a virtualized or sandbox analysis environment, and stays quiet if it is. This file runs that check end to end, then takes the defender's side of the same question.
Why this technique. A payload that detonates inside an analyst's sandbox burns the sample: the analysts capture the binary, its command-and-control addresses, and the fingerprints of the whole campaign's tooling. So the payload asks one question before it acts: am I being watched. The cheapest form of the question is reading facts the machine volunteers about itself. Four reads, no privilege, nothing written anywhere, and the answer decides whether the payload runs at all.
Why not just one check. The obvious attempt is a single indicator: read product_name, or test one rule like "hypervisor flag means sandbox". Break it on a concrete input: this very lab machine answers systemd-nspawn to systemd-detect-virt and cloud-hypervisor to the firmware reads. One check names only half the machine: a container running inside a VM. And a single string is a single lie to tell: whoever built the sandbox chooses what product_name says. So the working check layers overlapping reads, the firmware's strings, the CPU's own report, and the init system's detector, and the verdict is an OR across all of them. They overlap: the init system's detector re-reads the same DMI files the script reads (verified with strace), so the fourth read is a second opinion plus one genuinely separate source, the CPUID hypervisor bit. That layering is also what makes the defense hard: a convincing lie has to falsify every evidence source, not one.
The mechanism, with terms earned. DMI is the firmware's self-description: the machine's firmware ships tables naming the vendor and the product, and the Linux kernel exposes them as plain text files under /sys/class/dmi/id. sys_vendor names who made the machine; product_name names which machine. The hypervisor flag in /proc/cpuinfo is the CPU reporting, through the kernel, that a hypervisor is present beneath this OS. systemd-detect-virt is systemd's own answer to the same question, built from several of these channels plus container clues. An indicator is one such fact that suggests virtualization. The verdict is the script's final print: indicators present, or none found.
The concrete case, before the abstraction. ./sandbox-check.sh on this lab prints: sys_vendor: Cloud Hypervisor; product_name: cloud-hypervisor; cpu flag: hypervisor; detect-virt: systemd-nspawn; verdict: VM/sandbox indicators present. Four channels, four answers, and they do not even agree with each other: the firmware names a VM, the init system names a container. The machine is both, a container inside a VM, and the layered check is the only reason the verdict sees the whole thing.
Scope. T1497 Virtualization/Sandbox Evasion covers three sub-techniques: .001 System Checks (this file), .002 User Activity Based Checks, .003 Time Based Evasion. This file works the system-checks case end to end: the standard indicators, the verdict logic, and what a defender can and cannot do about a program reading its own environment.
Ubuntu 24.04.5 LTS with bash 5.2, x86-64, itself running virtualized, which is the point: the lab machine is the specimen. The check needs no privilege: every read is a public system fact. The lab stands in for the payload with one script.
One directory, one script. The script is the whole payload: it asks where it is, then prints its verdict.
$ mkdir -p /tmp/gh008 $ cat > /tmp/gh008/sandbox-check.sh <<'EOF' > #!/bin/sh > # GH-008 lab: the interrogation. A payload's pre-execution check. > # Reads only public system facts. Nothing is planted, nothing hidden, > # nothing persists, no privilege needed. > vendor=$(cat /sys/class/dmi/id/sys_vendor) > product=$(cat /sys/class/dmi/id/product_name) > cpuflag=$(grep -m1 -o 'hypervisor' /proc/cpuinfo || echo absent) > virt=$(systemd-detect-virt) > echo "sys_vendor: $vendor" > echo "product_name: $product" > echo "cpu flag: $cpuflag" > echo "detect-virt: $virt" > blob="$vendor $product $virt $cpuflag" > case $blob in > *[Qq][Ee][Mm][Uu]*|*[Kk][Vv][Mm]*|*VMware*|*VirtualBox*|*Xen*|*[Hh]ypervisor*|*nspawn*) > echo "verdict: VM/sandbox indicators present" ;; > *) > if [ "$virt" != "none" ]; then > echo "verdict: VM/sandbox indicators present" > else > echo "verdict: no VM indicators found" > fi ;; > esac > EOF $ chmod +x /tmp/gh008/sandbox-check.sh
Twenty-three lines. Every line glossed, because the whole technique lives in this file.
#!/bin/sh
# GH-008 lab: the interrogation. A payload's pre-execution check.
# Reads only public system facts. Nothing is planted, nothing hidden,
# nothing persists, no privilege needed.
vendor=$(cat /sys/class/dmi/id/sys_vendor)
product=$(cat /sys/class/dmi/id/product_name)
cpuflag=$(grep -m1 -o 'hypervisor' /proc/cpuinfo || echo absent)
virt=$(systemd-detect-virt)
echo "sys_vendor: $vendor"
echo "product_name: $product"
echo "cpu flag: $cpuflag"
echo "detect-virt: $virt"
blob="$vendor $product $virt $cpuflag"
case $blob in
*[Qq][Ee][Mm][Uu]*|*[Kk][Vv][Mm]*|*VMware*|*VirtualBox*|*Xen*|*[Hh]ypervisor*|*nspawn*)
echo "verdict: VM/sandbox indicators present" ;;
*)
if [ "$virt" != "none" ]; then
echo "verdict: VM/sandbox indicators present"
else
echo "verdict: no VM indicators found"
fi ;;
esac
Line by line. #!/bin/sh runs the file under the system shell. The comment lines say what the file is for; they do nothing. vendor=$(cat /sys/class/dmi/id/sys_vendor) reads the firmware's vendor string; $(...) captures a command's output into a variable. product=... reads the firmware's product string. cpuflag=$(grep -m1 -o 'hypervisor' /proc/cpuinfo || echo absent) searches the kernel's CPU report for the hypervisor flag: -m1 stops at the first match, -o prints only the matched word, and the || echo absent runs only if grep finds nothing, so the variable always has a value. virt=$(systemd-detect-virt) asks systemd for its one-word virtualization verdict. The four echo lines print the four indicators: this is the interrogation, the asking, done in public. blob="$vendor $product $virt $cpuflag" concatenates every indicator into one string so a single match tests all channels at once. case $blob in is shell pattern matching against that string: the long pattern lists fragments of known VM vendor and product names (QEMU, KVM, VMware, VirtualBox, Xen, Hypervisor, nspawn), with [Qq] matching either case; if any fragment appears anywhere in the blob, the verdict is indicators present. The *) fallback covers the case where no fragment matched: it still checks $virt, and anything systemd reported other than "none" counts as an indicator. The final else prints "no VM indicators found". Note what that line does not say: it does not say bare metal. It says the evidence sources were quiet.
Four reads, one verdict. Run each indicator by hand first, so you see what the script sees, then run the script and watch it decide. Every command below is copy-pasteable.
The kernel exposes the firmware's self-description as text files. Two reads, no privilege.
$ cat /sys/class/dmi/id/sys_vendor /sys/class/dmi/id/product_name Cloud Hypervisor cloud-hypervisor
The firmware says this machine is a Cloud Hypervisor guest. Remember who writes these strings: the hypervisor. A hypervisor that wants to lie sets them to anything it likes; the read itself cannot tell a true string from a false one.
Two more reads. They are not independent of the firmware strings: systemd-detect-virt itself opens /sys/class/dmi/id/sys_vendor, /sys/class/dmi/id/product_name, and friends (verified with strace), plus /proc/cpuinfo and the CPUID hypervisor bit directly. Treat the four reads as overlapping evidence with one extra CPUID opinion, not four independent channels. A sandbox that forges the DMI strings has also forged part of what systemd-detect-virt reads; what it has not forged is the CPUID signature, which systemd checks first.
$ grep -m1 -o hypervisor /proc/cpuinfo; systemd-detect-virt hypervisor systemd-nspawn
The hypervisor flag means the CPU told the kernel a hypervisor sits underneath this OS. systemd-detect-virt says systemd-nspawn: this shell runs inside a container. Note the disagreement with step 1: the firmware names a VM, the init system names a container. Both are true. One check would have told half the story; that is the concrete failure the layered check fixes.
The same four facts, now as one verdict.
$ ./sandbox-check.sh sys_vendor: Cloud Hypervisor product_name: cloud-hypervisor cpu flag: hypervisor detect-virt: systemd-nspawn verdict: VM/sandbox indicators present
A payload that wanted a sandbox would stop here: stay quiet, phone nothing home, leave no behavior to analyze. The interrogation cost four reads and printed its decision to the terminal.
The payload learned exactly where it is from public system facts before doing anything else. Nothing was planted, nothing persisted, no privilege was used, and no defender had any separate fact to check: the reads the attacker makes are the same reads the machine offers everyone.
The red phase asked the machine where it is. Now ask the defender's questions: what does the defender see that the attacker does not, what does the checking look like from outside, and what happens when the machine lies. Every command below is copy-pasteable.
Here is the trap: treating the indicator strings as hostile artifacts and hunting for them. The strings are not hostile. Your own inventory tooling reads the same files. The check is not an object to find; it is a behavior to observe, and a question you cannot stop from being asked.
The defender runs the same four reads. Watch the answers match the attacker's exactly.
$ cat /sys/class/dmi/id/sys_vendor; cat /sys/class/dmi/id/product_name; grep -m1 -o hypervisor /proc/cpuinfo; systemd-detect-virt Cloud Hypervisor cloud-hypervisor hypervisor systemd-nspawn
Identical answers. That is the first defensive fact, and it is a negative one: there is no defender-only channel here. The defender reads the same files the payload reads. You cannot stop a program from reading its own environment; the files are world-readable by design. Defense has two moves, and only two: lie to the check convincingly (step 3), or watch the checking happen (step 2).
The reads are legitimate, but their pattern is distinctive: one process, at startup, opening the DMI files and cpuinfo in a burst. strace -f follows the script and its children; -e trace=openat shows only file opens; the script's own output is discarded and the log is mined for the interesting paths.
$ strace -f -e trace=openat -o trace.log ./sandbox-check.sh >/dev/null 2>&1 $ grep -oE '/sys/class/dmi/id/[a-z_]+|/proc/cpuinfo' trace.log | sort -u /proc/cpuinfo /sys/class/dmi/id/product_name /sys/class/dmi/id/sys_vendor
That burst is the interrogation's observable footprint. A monitor shaped like this, DMI and cpuinfo reads clustered at process start, sees the checking even when it cannot judge the verdict. This rule is the site's own construction: D3FEND 1.6.0 maps no defender to T1497.001 specifically (its T1497 defenders target time-based evasion), so the Sources section says so plainly instead of borrowing a link that does not fit.
Defense move one is deception: a sandbox that lies convincingly. This step builds a small lying room with unshare: a mount namespace where /sys/class/dmi/id is a tmpfs holding forged strings, Dell Inc. and PowerEdge R750, a bare-metal costume. The namespace is contained; nothing on the host changes, and the room vanishes when the command exits.
$ unshare -rm sh -c 'mount -t tmpfs tmpfs /sys/class/dmi/id && printf "Dell Inc." > /sys/class/dmi/id/sys_vendor && printf "PowerEdge R750" > /sys/class/dmi/id/product_name && ./sandbox-check.sh' sys_vendor: Dell Inc. product_name: PowerEdge R750 cpu flag: hypervisor detect-virt: systemd-nspawn verdict: VM/sandbox indicators present
The DMI strings lied, and the verdict did not move: the CPU flag and systemd's CPUID read still told the truth, and the OR logic only needs one honest evidence source. Note what systemd's detector is here: a second opinion on overlapping evidence, not a separate channel. It re-reads the same DMI files the script read. The bar deception must clear is therefore every evidence source, not every channel: forged DMI, hidden CPUID hypervisor bit, masked container layer. Miss a single source, and the interrogation still convicts you.
The interrogation is observable as a burst of DMI and cpuinfo reads at process start, even though no single read is hostile. And the lying-room run proved the checker's trust boundary: it believes whatever the environment tells it, so the defense is to control the environment completely or not rely on the verdict at all.
Three moves, in order: do not let the verdict decide, watch the checking, make the lie airtight. Each is one way, not the way.
The check only protects the payload if you honor its decision to stay quiet. The mitigation is procedural and has two halves: see the interrogation without running it, then run the sample where its verdict does not matter.
1. Static triage first. The checker's evidence sources are visible without executing anything:
$ grep -nE 'dmi|cpuinfo|detect-virt|cpuid|CPUID' sample.sh 5:vendor=$(cat /sys/class/dmi/id/sys_vendor) 6:product=$(cat /sys/class/dmi/id/product_name) 7:cpuflag=$(grep -m1 -o 'hypervisor' /proc/cpuinfo || echo absent) 8:virt=$(systemd-detect-virt) 12:echo "detect-virt: $virt"
Four reads, one verdict. If the sample branches on these, you now know what it wanted to learn and what it planned to do with the answer, before it learned anything.
2. Detonate anyway. Run the sample in a disposable, instrumented VM regardless of what its interrogation concludes, and capture everything it does: process tree, file writes, network attempts. The interrogation becomes theater: it asked, and nobody listened.
3. If it stayed quiet anyway, the quiet is itself data: compare the static triage (it checks for sandboxes) against the dynamic run (it did nothing) and treat the sample as sandbox-aware in all future handling.
Good vs bad: a sample with no environment reads that detonates fully is a simpler problem; a sample whose first act is four environment reads and whose second act is silence is telling you its condition for detonation. Meet the condition in a room you control.
Honest limit. Static analysis misses packed or obfuscated checks: if the strings are not visible, the dynamic run in the disposable VM is the whole answer. And the deepest limit: none of this helps if the analyst lets the sample decide whether to run. Run it anyway, in a room you control, and the interrogation answers to an empty room.
First principle: never let the adversary's sensor decide your response. The interrogation exists to make you stand down; the mitigation is a procedure that does not stand down.
The strace pattern from Phase Blue is the monitor: a cluster of opens on /sys/class/dmi/id/* and /proc/cpuinfo at process start, before the process does anything else. Production versions run it in the EDR or auditd, not strace, and alert on the pattern, not on any single read. This is the fleet form of the check: the idea does not change, only the coverage.
$ strace -f -e trace=openat -o trace.log ./sandbox-check.sh >/dev/null 2>&1 $ grep -oE '/sys/class/dmi/id/[a-z_]+|/proc/cpuinfo' trace.log | sort -u /proc/cpuinfo /sys/class/dmi/id/product_name /sys/class/dmi/id/sys_vendor
Falsify every evidence source the interrogation reads, and keep them consistent: DMI strings via the hypervisor's firmware-string controls, the hypervisor CPUID bit hidden by the hypervisor itself, and the container layer camouflaged so systemd-detect-virt answers none. Or skip the arms race: detonate on bare metal reimaged from known-good media, where there is nothing to detect. D3FEND maps no defender to this sub-technique; the controls above are the site's own, and their limits are stated below.
Honest limit. Every one of these checks is trivially fooled by a sandbox that bothers to lie; absence of VM indicators proves nothing about bare metal, it proves the evidence sources were quiet. DMI strings are written by whoever built the VM. The hypervisor flag can be hidden by the hypervisor. The read-burst monitor misses checks that execute the CPUID instruction directly instead of reading files, and it races any check that runs before the monitor attaches. Static analysis misses packed or obfuscated checks. And the deepest limit: the checker's verdict is only useful to the attacker if the analyst lets the sample decide whether to run. Run it anyway, in a room you control, and the interrogation answers to an empty room.
The interrogation cannot be prevented, only answered dishonestly or observed in the act. A sandbox that falsifies every evidence source defeats the check; a monitor that watches the read burst sees it coming; an analyst who detonates anyway makes the verdict irrelevant. None of them changes the core fact: a program can always read its own environment.
A program can always read its own environment; the defense is to lie to it completely or watch what it does with the answer.
IOC checklist: signs this technique was used
Reproducibility checklist
Sources
MITRE ATT&CK T1497.001: System Checks
proc(5) (/proc/cpuinfo flags: the hypervisor bit)
systemd-detect-virt(1), and the kernel ABI document Documentation/ABI/stable/sysfs-class-dmi (the DMI sysfs files)
MITRE D3FEND: version 1.6.0 maps no defender to T1497.001; its T1497 defenders target .003 time-based evasion, so none are wired here
A file the listing never shows is still a file. The next file opens the drawer ls keeps shut.