Dynamic Shellcode Protection is designed to expose and block fileless malware, ransomware and remote access agents.
Sophos has developed a new defense against adversaries trying to evade detection by loading fileless malware, ransomware and remote access agents into the memory of compromised computers.
The defense, called Dynamic Shellcode Protection, will make it significantly harder for adversaries to use memory as part of their arsenal of defense evasion techniques.
In a recent blog post Covert Code Faces a Heap of Trouble in Memory, Sophos researchers detailed how they discovered that covert attack code is injected directly into the dynamic “Heap” region of computer memory and then tries to obtain additional “Heap” memory with code execution rights, a behavior not seen in ordinary software.
In response, the researchers developed Dynamic Shellcode Protection, which is triggered whenever such “Heap-Heap” memory allocation behavior is detected.
The case of Conti
In a series of articles on the realities of the Conti ransomware, including A Conti Ransomware Attack Day-By-Day and Conti Ransomware: Evasive By Nature, Sophos reported on how the memory of compromised computers is a popular hiding place for adversaries looking to conceal their presence from defenders while they load and execute the remote access agents that will serve as enablers for the rest of the attack.
In the case of Conti, the remote access agent used was Cobalt Strike.
Another example, covered in a recent research article Gootloader Expands Its Payload Delivery Options shows how Gootloader injects fileless malware direct into memory.
“Preventing attackers from taking hold in a compromised network is the goal of defenders everywhere,” said Mark Loman, director of engineering, Sophos. “This goal is critical because once a remote access agent has been installed, it can facilitate most of the active adversary tactics that take place during the attack.”
These tactics include execution, credential access, privilege escalation, discovery, lateral movement, collection, exfiltration, and the release of the ransomware.
How in-memory infections work
“Code intended for malicious use evades detection by being heavily obfuscated and packed and loaded directly into memory,” said Loman. “Computer memory is not routinely scanned by security tools so that even when the code is de-obfuscated and unpacked in order to run, its presence is often not detected.”
However, Sophos identified a characteristic – “Heap-Heap” memory allocation – that is typical across multi-stage remote access agents and other attack code being loaded into memory.
Dynamic Shellcode Protection is based on the fact that code such as applications are stored in memory regions that have “execution” rights. This enables the apps to run. However, the apps generally need some additional, temporary, in-memory workspace, for example to unpack or store data.
This variable workspace is commonly called “Heap” memory. Apps can request their Heap memory allocation to come with execution rights.
In most cyber-attacks, however, the loader for a remote access agent is injected directly into Heap memory. It then needs to obtain further executable memory from the Heap to accommodate the needs of the inbound remote access agent. This is referred to as “Heap-Heap” memory allocation behavior.
Sophos researchers realized that such behavior was a clear indicator of potentially suspicious activity and designed a practical protection that blocks the allocation of execution permissions from one Heap memory to another. In doing so, the protection can intercept many cyberattacks involving remote access agents, fileless malware and ransomware, while being compatible with normal applications.
Your defense
“When a process, regardless of whether it is malicious or benign, violates the Heap memory allocation barrier, the Dynamic Shellcode Protection will block it and notify defenders. Security professionals can then take a closer look at what is going on,” said Loman.
“The new protection is not meant as a silver bullet for all attacks, but it does mean that adversaries face a new obstacle that blocks a fundamental behavior of their stealthy code. We hope this will make attackers’ jobs harder and more complicated.”
The Dynamic Shellcode Protection does not rely on the cloud or machine learning, representing a paradigm shift in the ongoing battle against many obfuscated malware and memory-delivered post-exploitation agents, including Cobalt Strike Beacon.
Dynamic Shellcode Protection is integrated into Sophos Intercept X.
Some additional general tips for defending against ransomware include:
- Shut down internet-facing remote desktop protocol (RDP) to deny cybercriminals access to networks.
- If you need access to RDP, put it behind a VPN connection.
- Use layered security to prevent, protect and detect cyberattacks, including endpoint detection and response (EDR) capabilities and managed response teams who watch networks 24/7.
- Be aware of the five early indicators an attacker is present.
- Have an effective incident response plan in place and update it as needed. If you don’t feel confident you have the skills or resources in place to do this, to monitor threats or to respond to emergency incidents, consider turning to external experts for help.