Co-authored by Matthias Neugschwandtner.

Recently, collaborative research efforts between Northeastern University and IBM devised a means to reduce a Windows application’s attack surface by removing unused functions from libraries that are loaded dynamically, known as Dynamic Link Libraries (DLLs). The researchers will present their findings at Black Hat USA 2015.

What Are Dynamic Link Libraries?

Most Windows applications perform common functions, such as displaying a message box. Instead of each developer writing this function independently — which would result in incompatibility and an inconsistent user experience — Microsoft delivers multiple predefined libraries with common functions. The same goes for software development platform/compiler manufacturers and application developers. These are packaged as DLLs.

DLLs are loaded by applications so that they can use the functions. Even simple applications such as Notepad will load a DLL like User32.dll. Notepad then has access to not just the MessageBox function, but to all other functions contained in User32.dll — even though it will not use many of these capabilities.

Attackers Count on Consistency

When an attacker writes an exploit, he or she counts on certain code to exist in memory. For example, the actor may rely on code from the connect() function of the Windows Socket API to establish a communication channel. Therefore, removing all DLL functions from memory that an application will not use reduces the chances that an exploit will work because it decreases the amount of potentially exploitable code.

The Solution

Collin Mulliner from Northeastern University and Matthias Neugschwandtner from IBM devised a tool that iterates through the DLL function dependencies in an application and determines which functions in loaded DLLs are not needed. The tool then overwrites the unused functions’ code in memory with machine code instructions to stop the program. Since DLLs themselves can call other DLLs, it iterates through the entire load chain.

After the tool has stripped unused code, it freezes the code base of the program, i.e., it denies adding or modifying executable memory pages. As a result, attackers can no longer inject additional code into the process.

Application Function Complexities

It is not simple to determine the recursive library function chain, so in its initial incarnation, the solution requires a training period for each application. The application is executed and the solution monitors its activity for a period to determine which functions are called and which are not. Once an application profile has been created, the solution can be configured to strip unused functions, effectively moving from training to protection mode.

Side Effects

There is no runtime overhead after program startup, when stripping and freezing actually take place. Stripping and freezing is also a memory-only operation and does not affect the DLLs on disk. It only affects memory consumption since DLL code pages are stripped individually per application and can thus no longer be shared among multiple processes.

But if you ask us, this is a fair trade-off for security.

To learn more, attend the Black Hat USA presentation Aug. 6 at 3:50pm in South Seas IJ.

More from Software Vulnerabilities

FYSA – Critical RCE Flaw in GNU-Linux Systems

2 min read - Summary The first of a series of blog posts has been published detailing a vulnerability in the Common Unix Printing System (CUPS), which purportedly allows attackers to gain remote access to UNIX-based systems. The vulnerability, which affects various UNIX-based operating systems, can be exploited by sending a specially crafted HTTP request to the CUPS service. Threat Topography Threat Type: Remote code execution vulnerability in CUPS service Industries Impacted: UNIX-based systems across various industries, including but not limited to, finance, healthcare,…

X-Force discovers new vulnerabilities in smart treadmill

7 min read - This research was made possible thanks to contributions from Joshua Merrill. Smart gym equipment is seeing rapid growth in the fitness industry, enabling users to follow customized workouts, stream entertainment on the built-in display, and conveniently track their progress. With the multitude of features available on these internet-connected machines, a group of researchers at IBM X-Force Red considered whether user data was secure and, more importantly, whether there was any risk to the physical safety of users. One of the most…

X-Force releases detection & response framework for managed file transfer software

5 min read - How AI can help defenders scale detection guidance for enterprise software tools If we look back at mass exploitation events that shook the security industry like Log4j, Atlassian, and Microsoft Exchange when these solutions were actively being exploited by attackers, the exploits may have been associated with a different CVE, but the detection and response guidance being released by the various security vendors had many similarities (e.g., Log4shell vs. Log4j2 vs. MOVEit vs. Spring4Shell vs. Microsoft Exchange vs. ProxyShell vs.…

Topic updates

Get email updates and stay ahead of the latest threats to the security landscape, thought leadership and research.
Subscribe today