How can Advanced Sandboxing Techniques Thwart Elusive Malware?
by Moony Li and Jerry Liu (Trend Micro Engineer-Developers)
Sandboxes are mechanisms many traditional security solutions often employ as part of an endpoint or network’s last lines of defense. Like what its namesake says, sandboxes are where malware or suspicious files are given the controlled, virtualized environment to play around in (read: execute their routines). Their observed behaviors are then analyzed; sandboxes typically use patterns of existing behaviors and routines to determine if the files are malicious or not. They can help ensure an endpoint’s security, isolating untrusted files that could’ve otherwise caused damage to the system’s actual infrastructure.
But what if the malware happens to find a gap through which it can escape the sandbox? What if it’s self-aware, capable of knowing it’s in a sandbox? What if it pretends to be benign, to prevent rousing suspicion?
Here is a rundown of notable malware and their modus operandi of eluding traditional security technologies, how they take the path of least resistance, and how they can be addressed with advanced sandboxing techniques:
Notable Sandbox-evading Malware
In 2016, Locky's use of kernel exploits made it notable. The middleman in the attack chain is a downloader Trojan (TROJ_LOCKY.DLDRA) that exploits a local privilege escalation flaw (CVE-2015-1701, patched May 12, 2015) and masquerades as a system process to avoid sandbox detection. By exploiting the security flaw, attackers can leverage mechanisms in the vulnerable system’s kernel (work-items, system threads, and asynchronous procedure calls) to connect to a command and control server (C&C) in order to download the ransomware. In effect, the malware can be installed without creating files on the affected machine. This technique is often employed on top of a then-zero-day attack (CVE-2016-1019, patched April 5, 2016) uncovered in the Magnitude exploit kit.
Shamoon/Disttrack (WORM_DISTTRACK family), whose emergence dated as far back as 2012, is typically used in targeted attacks mainly against high-profile organizations in the Middle East. It wipes the system’s Master Boot Record (MBR), and renders endpoints and servers connected to the targeted organization’s domain unbootable. Upon its reemergence in December 2016, Shamoon sported a sandbox-evading technique—including a logic bomb within its code. It activates and drops its malicious components at a certain date and time, which are hardcoded within the malware.
Sandbox Evasion via Fileless Malware
For fileless infection, less is more. How? These kinds of attacks don’t involve actual files, or even downloading and writing one to a computer’s disk. Malicious payloads are typically executed in the system’s memory. The lack of actual files to analyze significantly reduces an attack’s footprint, especially against traditional sandboxes.
By following the path of least resistance—in this case the system’s memory or registry—fileless attacks are increasingly becoming a staple technique for cybercriminals. Threats such as various iterations of enterprise-targeting Trojans and point-of-sale (PoS) malware have been delivered this way. Cyberespionage malware Duqu 2.0, for instance, was noted for its use of malicious modules executed within the infected system’s memory. Its attack chain entailed the abuse of a penetration testing tool (Metasploit) to steal an affected computer’s system password from memory, in order to escalate their privileges in the system.
Here is how different kinds of fileless attacks (executed in memory) are employed depending on the bad guy’s evasion tactic, and how traditional sandboxes typically work:
|Evasion Tactic||Fileless Attacks
||How Traditional Sandbox Works|
|Bypass file scanning||No file involved||Scan files on demand|
|Interfere with behavior correlation||Use Script or cmd under the guise of a system process||System API-level hook|
|Bypass sandbox||Time delay (i.e. creating a scheduled task)||Monitor within a restricted time|
|Anti-forensics||Infection traces in memory is volatile|
An Advanced, Custom Sandbox
As sandbox-evading techniques in malware become more common, it is equally important that sandboxes can be customized in a way that can reflect a system’s actual environment (including software configurations) as accurately as possible. This helps better simulate how certain suspicious files, such as kernel exploits, can affect the system. A sandbox capable of analyzing the multifaceted behaviors and routines in a malware—from scripts, shellcode, to payload—can help further identify obfuscation and evasion tactics that may be overlooked in a regular sandbox.
Anti-VM codes within malware are typically kept packed, and are only unpacked during execution. This can be mitigated by a sandbox capable of searching and verifying traces of code written to evade sandbox analysis at runtime.
Most sandboxes often only check system APIs (Application Program Interface), which can be bypassed by fileless attacks through the use and abuse of scripts and system utilities. These can be mitigated by a sandbox with high-level system monitoring, which checks for malicious communication beyond the machine’s system APIs.
Traditional sandboxes rely mostly on dynamic analysis—understanding how malware behaves within its environment by emulating and executing its binaries. Malware, like the CrypMIC (RANSOM_CRYPMIC) and Cerber (RANSOM_CERBER) ransomware, evade sandbox analysis by using CPUID-based instructions in order to check if it’s run on a virtual machine.
Trend Micro’s sandbox, which can be tailored to better match an actual system’s configurations, has more forensic capabilities by bridging dynamic analysis with the benefits of static analysis. Various components of a file are dissected and reverse-engineered, which helps achieve a better detection rate of a file’s malicious routines and behaviors. The time bomb within Shamoon, for instance, can be detected via static analysis by checking the date in the binary. Dynamic analysis of the payload can then identify its behaviors under certain systems. Another example would be the use of shellcode and abuse of Component Object Model (COM) to embed malicious commands within a process, which could’ve been missed by behavioral analysis.
Trend Micro’s custom sandbox integrated in Deep Discovery™, Deep Security™, and OfficeScan™ endpoint security can intercept APIs—protocols/routines that specify how software components communicate—and check for code strings meant to execute a malware’s evasion technique. It can dynamically trace, control, and analyze the semantics of these instructions in order to find the evasion logic within them. These instructions can be further enumerated into possible program execution paths. Each can then be analyzed for suspicious or malicious behavior, including one that commands the malware to sleep for a duration of time before executing.
Indeed, today’s threat landscape is like an arms race. As cybersecurity evolves, so will cybercriminals. They are projected to further adapt and grow more seasoned, enabling themselves to sophisticate their tactics, techniques and procedures. Malware are weaponized with different tacks that can evade traditional security solutions. As we’ve seen in 2016, we’ve already seen a shift toward how they are deployed—stealthier behaviors, and bigger attack vectors, as well as exploit and infection chains. We also predict that these sandbox evasion techniques will broaden in malicious PE files (Portable Executable), but also for script files (.JS, .VBS, .VBA, PowerShell, etc.).And while sandboxes can be particularly effective against unknown threats and zero-day exploits, a sandbox is not a silver bullet. It should be considered as something that complements a multilayered, cross-generational approach to securing the system—from the gateway and server to the network and its endpoints.
Like it? Add this infographic to your site:
1. Click on the box below. 2. Press Ctrl+A to select all. 3. Press Ctrl+C to copy. 4. Paste the code into your page (Ctrl+V).
Image will appear the same size as you see above.
- Ransomware Spotlight: TargetCompany
- Email Threat Landscape Report: Cybercriminal Tactics, Techniques That Organizations Need to Know
- Preventing an Imminent Ransomware Attack With Early Detection and Investigation
- Inside the Halls of a Cybercrime Business
- Securing Cloud-Native Environments with Zero Trust: Real-World Attack Cases