Avoiding antivirus bypass dedicated vulnerabilities
In this section, you will learn how to prevent the vulnerabilities we presented in Chapter 3, Antivirus Research Approaches.
How to avoid the DLL hijacking vulnerability
To mitigate DLL hijacking attacks, the caller process needs to use a proper mechanism to validate the loaded DLL module not only by its name but also by its certificate and signature.
Also, the loading process (like the antivirus software) can, for example, calculate the hash value of the loaded DLL and check if it is the legitimate, intended DLL that is to be loaded, using Windows API functions such as LoadLibraryEx
followed by the validation of specific paths to be loaded from, rather than the regular LoadLibrary
, which simply loads a DLL by a name that attackers can easily mimic.
In other words, the LoadLibraryEx
function has the capability of validating a loaded DLL file by its signature, by specifying the flag of LOAD_LIBRARY_REQUIRE_SIGNED_TARGET...