Before an attachment reaches an inbox in many organisations, an email security product quietly opens it somewhere else first. It boots a disposable virtual machine, runs the file, watches what happens for a few minutes and then decides whether the employee should receive it. This is sandboxing, and it is one of the main ways defenders catch malware nobody has seen before. It is also the target of an entire category of attacker techniques designed to make malware behave innocently whenever it suspects it is in a test environment.

What a security sandbox actually is

In the security operations sense, a sandbox is an isolated, instrumented environment for executing untrusted files and links. (The word is also used for application sandboxes, like the restrictions a browser places on web pages, which is a related but different idea.) A detonation sandbox typically:

  • starts a clean virtual machine or emulated system from a snapshot;
  • opens the file with the appropriate application, or browses to the URL;
  • records processes, file and registry changes, network connections, DNS lookups, and sometimes memory and screenshots;
  • scores the behaviour against rules and produces a verdict and a report;
  • throws the machine away.

Sandboxes sit in email gateways, web proxies, EDR platforms (which can submit suspicious files automatically) and standalone analysis services used by SOC analysts. Their great advantage over signatures is that they judge what a file does, not what it looks like, so a freshly recompiled sample that no antivirus engine recognises can still be caught.

The attacker’s problem, and their answers

From the attacker’s side, the sandbox is a witness. If the malware reveals its behaviour there, its command servers get blocked and its hash gets shared within hours. So malware authors build in checks, and if anything looks wrong, the sample exits, sleeps or does something harmless. ATT&CK catalogues this as Virtualization/Sandbox Evasion. Conceptually, the checks fall into a few families.

Is this a virtual machine? Virtual machines leave traces: hardware vendor names, specific drivers, characteristic network adapter address ranges, guest tools. Of course, plenty of real business computing runs on virtual machines too, so this check alone costs the attacker victims.

Does this look like a real person’s computer? Sandboxes are often minimal: one or two CPU cores, small disks, little memory, a fresh user profile with no documents, no browser history, no recently opened files. Malware can check for these signs of an unlived-in machine.

Is anyone actually using it? A real user moves the mouse, scrolls and clicks. Some malware waits for a specific number of clicks, scrolling through a document, or closing a dialog before acting.

Can I simply outwait it? A sandbox watches each file for a few minutes because it has thousands to process. Malware that sleeps for twenty minutes before doing anything may pass as benign. Sandboxes respond by fast-forwarding sleep calls; malware responds by checking whether time really passed, for example by comparing timestamps from different sources.

Am I in the right place? Targeted malware may check the system’s language, keyboard layout, time zone or the organisation’s domain name and run only when they match the intended victim. A sample built for Indian targets might do nothing on a sandbox configured with a US locale.

Keep the payload out of reach. Perhaps the most effective approach avoids sandbox detection checks entirely. The attachment is a password-protected archive with the password in the email body, which automated systems may not connect. Or the first stage is harmless and the real payload is only served by the attacker’s server if the request comes from an expected country, at an expected time, from a victim that looks real. The sandbox sees a dull downloader and an empty response.

How defenders push back

Sandbox vendors and analysts have their own toolkit:

  • Realistic images with lived-in user profiles, typical corporate software, realistic hardware specifications, and locale settings matching the organisation.
  • Simulated users that move the mouse, scroll documents and click through prompts.
  • Better instrumentation: monitoring from the hypervisor level, outside the guest operating system, leaves fewer traces for malware to find. Some services run samples on real physical machines for this reason.
  • Evasion as evidence. A document that queries the hardware vendor, checks the number of CPU cores and then exits is behaving suspiciously in itself. Good sandboxes score evasion attempts, not only malicious actions.
  • Context extraction, such as trying passwords found in the email body on attached archives.

What this means for an analyst reading a report

The practical lesson is that a clean sandbox verdict means “nothing bad was observed in this run”, not “this file is safe”. When an analyst is investigating a file that has other suspicious context, such as an unknown sender, a lookalike domain or a user who reported strange behaviour afterwards, a benign sandbox score should not end the investigation.

Useful follow-up steps include re-running the sample in a differently configured environment (another locale, longer duration, more realistic profile), checking the report for evasion behaviour or failed network requests that suggest a payload was withheld, and looking at what happened on the real endpoint where the file was opened. Endpoint telemetry from the actual victim machine cannot be fooled by sandbox detection, because it is the real environment.

Sandboxing remains valuable precisely because it forces attackers to spend effort. Every check they add makes their malware larger, more fragile and more likely to skip some real victims. The contest is not won by either side permanently; it is a cost the defender imposes and the attacker keeps paying.

Written by the RP Strativa Team.

Leave a Reply

Trending