Lumension - Reflective Memory Injection
Lumension - Reflective Memory Injection
arms race between attackers and defenders. Take a deep dive into
how RMI works, what it looks like, and how your organization
environment.
June 2013
WP-EN-06-19-13
Reflective Memory Injection: How it Works and How to Stop it
Overview Sponsered by
Reflective memory injection (RMI) is the most
recent weapon in the arms race between attack-
ers and defenders. Back in the 1990s, most se-
curity incidents centered around active penetra-
tion attempts, launched directly at the networks
and servers of target organizations. Such attacks
relied on simple security misconfigurations and
unhardened systems that were left at their unse-
cured default settings.
As awareness grew, organizations began harden- executable can be downloaded to the victim sys-
ing their most exposed systems and implementing tem and configured to run persistently. If you can
better network boundaries. But security patch- stop that EXE file from executing, you can prevent
ing was slow, and many systems simply went un- the attack from escalating.
patched for years. So attackers started looking
for software bugs that they could exploit, such as At about the same time that zero-day exploits be-
buffer overflows that allow malformed input to trick came popular with attackers, application whitelist-
programs into running arbitrary code. ing matured and became more common. Applica-
tion whitelisting solutions such as Lumension ®
In time, software vendors (arguably lead by Mi- Application Control prevent new EXEs from run-
crosoft) beefed up the default security settings of ning on protected systems unless the EXE passes
their products and began releasing patches more various trust policies.
regularly, along with automated patch-delivery sys-
tems. These changes made life more difficult for Software developers also began using more se-
attackers, but a significant window of opportunity cure coding techniques and compilers. OS and
still existed. Attackers began to exploit zero-day hardware vendors began developing ways to make
vulnerabilities, before vendors developed patches buffer overflows and related bugs less prevalent
and customers deployed them to target systems. and more difficult to exploit and to restrict the size
and flexibility of buffer overflows.
There’s no defense against a zero-day vulnerability
until a patch is available and you follow through With buffer overflows more difficult than ever to
and deploy it. But most zero-day vulnerabilities are exploit and the possibility that malicious EXEs
used as the initial vector through which a malicious could be blocked by application whitelisting, at-
1
Reflective Memory Injection: How it Works and How to Stop it
2
Reflective Memory Injection: How it Works and How to Stop it
Continued »
3
Reflective Memory Injection: How it Works and How to Stop it
What Does an RMI Process Look Like? soft Internet Explorer (IE) that is flagged for Read,
Detecting RMI code is complex. Classic methods Write, and Execute. In addition, the contents of the
of detecting DLLs that are injected through normal memory are a positive match for a DLL in Win32
APIs are obsolete. For instance, since the DLL was Portable Executable (PE) format.
not loaded with LoadLibrary(), the malicious code
won’t show up in the process’s metadata. Although the contents of the memory region is a
DLL and is writable, other investigation shows that
You must look for evidence of what RMI does, it does not appear in the list of DLLs that are load-
which is to allocate a region of private memory and ed through the normal API, nor is it mapped to a
flag it for not just Read and Write access but also file on the file system. This is suspicious but not
for Execute. The fact that the chunk of memory is in definite. Legitimate cases of programming could
the data part of a process’s memory but is flagged yield the same appearance, but these are unusual,
to allow execution is suspicious; a program’s exe- such as copy-protection mechanisms in game soft-
cutable code normally resides in the process’s “im- ware. Indeed, code that loads this way is code that
age” (EXE) region of memory and in any legitimate- wants to hide.
ly mapped DLL file. The region must be marked as
writable so that the shell code can write the code How Lumension Detects RMI
into the region. It must also be flagged as execut- Lumension ® Application Control (part of Lumen-
able so that the shell code can subsequently pass sion ® Endpoint Management and Security Suite)
execution to it. has long been a leader in application whitelisting,
which is the most effective way to prevent mali-
However, just looking for chunks of private memory cious or otherwise untrusted or unwanted applica-
that are flagged RWX will lead to false positives. tions from executing.
Some legitimate programs, such as the .NET Run-
time, use self-modifying code. RMI bypasses the file system and security technol-
ogies that interface with the file system. Through
To eliminate such false positives, you must exam- the acquisition of CoreTrace, Lumension ® Applica-
ine the contents of the suspicious memory chunk. tion Control includes CoreTrace’s Bouncer patent-
Look for structures and constants that show the pending technology. Bouncer can detect and stop
chunk to be a DLL in disguise. DLLs have a stan- RMI attacks by monitoring an endpoint’s memory
dard format with several headers and tables. Look address space and associated processes for dis-
for are the MZ and PE headers, which are prefixed tinct evidence of exploitation. The architecture and
by those actual characters, as shown in the fol- kernel-level position of Lumension ® Application
lowing figure. The Process Hacker screen in this Control allow it to extend beyond simple whitelist-
figure shows a region of private memory in Micro- ing to provide memory protection.
4
Reflective Memory Injection: How it Works and How to Stop it
5
Reflective Memory Injection: How it Works and How to Stop it
6
Reflective Memory Injection: How it Works and How to Stop it
Global Headquarters
8660 East Hartford Drive, Suite 300
Scottsdale, AZ 85255 USA
phone: +1.480.970.1025
fax: +1.480.970.6323
www.lumension.com
Vulnerability Management | Endpoint Protection | Data Protection | Compliance and IT Risk Management 7