The present disclosure generally relates to computer security and malware protection. In particular, the present disclosure is generally directed towards systems and methods for detecting and mitigating code injection attacks
A heap is an area of computer memory that a program (or “process”) can access in order to store data in a variable amount. Blocks of memory in the heap may be dynamically allocated and de-allocated (i.e., allocated and freed in arbitrary order). The pattern of allocation and size of blocks within the heap are not known until run time. The total size of the heap may grow and shrink with use.
A heap spray attack is a malware attack where heap memory is sprayed by a series of non-operational machine instructions (“no-ops”) that are followed by an executable portion of code. No-ops are computer instructions that do not define an operation, such as arithmetic operations with a zero operand. A sequence of no-ops instructions that are meant to “slide” a processor's instruction execution flow to a desired destination may be referred to as a no-op slide. The desired destination may include a transfer-of-control operation such as a return, jump, or call. The no-op slide may route the computer to executable code that causes the computer system to perform actions at the behest of the attacker, such as gaining root access.
Alternatively, the heap spray attack may function similar to a denial-of-service attack, where the volume of no-ops exceeds the volume of memory available in the heap, and a user is no longer able to run a program. Accordingly, heap spraying may be used to trigger an unrelated code vulnerability, such as a buffer over-flow.
Heap spray attacks have been used to attack applications that provide user-scripting capability, such as Web Browsers, Adobe reader, Windows OS components and the like. It is expected that the prevalence of heap spray attacks will continue to increase.
Heap spray attacks may be classified as a type of code injection attack. Other code injection attacks can include attacks based on injection of foreign code using dynamically-linked libraries (DLLs), and attacks based on the use of malicious scripts (e.g., JavaScript).
Accordingly, there is a need for computer systems and methods that can detect and mitigate a code injection attack. Discussed herein are system and methods for detecting and mitigating a code injection attack. Some embodiments of the present disclosure may be described in terms of mitigating heap spray attacks, however a skilled artisan will understand that the systems and methods disclosed herein can be applied to detect and mitigate other types of code injection attacks, including but not limited to attacks based on injection of foreign code using dynamically-linked libraries (DLLs), and attacks based on the use of malicious scripts (e.g., JavaScript).
In some embodiments, an electronic computer system for detecting a code injection attack includes a processor, and at least one non-transitory computer-readable memory communicatively coupled to the processor. The processing instructions encoded in the at least one non-transitory computer-readable memory, when executed by the processor, may be operable to perform operations including: scanning one or more sections of the computer-readable memory for computer instructions that do not define an operation, detecting a heap spray attack based on the scanned one or more sections, and mitigating the heap spray attack by taking one or more defensive actions.
In some embodiments, a system for detecting and mitigating a heap spray attack may detect a heap spray attack based on the scanned one or more sections by determining a number of computer instructions that do not define an operation in the scanned one or more sections, and determining whether the number of computer instructions that do not define an operation exceeds a no-ops threshold. In some embodiments, detecting a heap spray attack based on the scanned one or more sections includes determining a number of computer instructions that do not define an operation in the scanned one or more sections, determining a total number of computer instructions in the scanned one or more sections, and determining whether the determined number of computer instructions that do not define an operation in the scanned one or more sections exceeds a threshold percentage of the determined total number of computer instructions in the scanned one or more sections. In some embodiments, detecting a heap spray attack based on the scanned one or more sections includes determining a spatial locality metric for the computer instructions that do not define an operation in the scanned one or more sections, and determining whether the spatial locality metric exceeds a spatial locality threshold. In some embodiments, mitigating the heap spray attack includes terminating execution of the computer program. In some embodiments, mitigating the heap spray attack includes isolating one or more portions of the scanned one or more sections. In some embodiments, detecting the heap spray attack includes applying a Hidden Markov Model (HMM).
In some embodiments, a non-transitory computer-readable medium stores instructions for detecting a heap spray attack. The instructions, when executed by a processor, may be configured to scan one or more sections of one of the computer-readable memory or computer instructions that do not define an operation, detect a heap spray attack based on the scanned one or more sections, and mitigate the detected heap spray attack by taking one or more defensive actions.
In some embodiments, the instructions to detect a heap spray attack based on the scanned one or more sections may include instructions to determine a number of computer instructions that do not define an operation in the scanned one or more sections and determine whether the number of computer instructions that do not define an operation exceeds a no-ops threshold. In some embodiments, the instructions to detect a heap spray attack based on the scanned one or more sections includes instructions to determine a number of computer instructions that do not define an operation in the scanned one or more sections, determine a total number of computer instructions in the scanned one or more sections, and determine whether the determined number of computer instructions that do not define an operation in the scanned one or more sections exceeds a threshold percentage of the determined total number of computer instructions in the scanned one or more sections. In some embodiments, the instructions to detect a heap spray attack based on the scanned one or more sections includes instructions to determine a spatial locality metric for the computer instructions that do not define an operation in the scanned one or more sections, and determine whether the spatial locality metric exceeds a spatial locality threshold. In some embodiments, the instructions to mitigate the heap spray attack includes terminating execution of the computer program. In some embodiments instructions to mitigate the heap spray attack includes isolating one or more portions of the scanned one or more sections. In some embodiments, instructions to detect the heap spray attack includes applying a Hidden Markov Model (HMM).
In some embodiments, a method for detecting a heap spray attack includes the steps of scanning one or more sections of one of at least one non-transitory computer-readable memory for computer instructions that do not define an operation, detecting a heap spray attack based on the scanned one or more sections, and mitigating the heap spray attack by taking one or more defensive actions. Embodiments may detect a heap spray attack based on the scanned one or more sections by determining a number of computer instructions that do not define an operation in the scanned one or more sections, and determining whether the number of computer instructions that do not define an operation exceeds a no-ops threshold. Detecting a heap spray attack based on the scanned one or more sections may include determining a number of computer instructions that do not define an operation in the scanned one or more sections, determining a total number of computer instructions in the scanned one or more sections, and determining whether the determined number of computer instructions that do not define an operation in the scanned one or more sections exceeds a threshold percentage of the determined total number of computer instructions in the scanned one or more sections.
In some embodiments a method for detecting a heap spray attack based on the scanned one or more sections includes determining a spatial locality metric for the computer instructions that do not define an operation in the scanned one or more sections, and determining whether the spatial locality metric exceeds a spatial locality threshold. Further, mitigating the heap spray attack may include at least one of terminating execution of the computer program, and isolating one or more portions of the scanned one or more sections. Detecting the heap spray attack may include applying a Hidden Markov Model (HMM).
In some embodiments, processing device 103 may include, without being limited to, a microprocessor, a central processing unit, an application specific integrated circuit (ASIC), a field programmable gate array (FPGA), a digital signal processor (DSP) and/or a network processor. Processing device 103 may be configured to execute processing logic 105 for performing the operations described herein. In general, processing device 103 may include any suitable special-purpose processing device specially programmed with processing logic 105 to perform the operations described herein.
In certain embodiments, memory 107 may include, for example, without being limited to, at least one of a read-only memory (ROM), a random access memory (RAM), a flash memory, a dynamic RAM (DRAM) and a static RAM (SRAM), storing computer-readable instructions 117 executable by processing device 103. In general, memory 107 may include any suitable non-transitory computer-readable storage medium storing computer-readable instructions 117 executable by processing device 103 for performing the operations described herein. Although one memory device 107 is illustrated in
Computer system 100 may include communication interface device 121, for direct communication with other computers (including wired and/or wireless communication), and/or for communication with network. In some examples, computer system 100 may include display device 123 (e.g., a liquid crystal display (LCD), a touch sensitive display, etc.). In some examples, computer system 100 may include user interface 125 (e.g., an alphanumeric input device, a cursor control device, etc.).
In some examples, computer system 100 may include data storage device 119 storing instructions (e.g., software) for performing any one or more of the functions described herein. Data storage device 119 may include any suitable non-transitory computer-readable storage medium, including, without being limited to, solid-state memories, optical media and magnetic media.
In some examples, the computer system 100 may be connected (e.g., networked) to other computer systems. The machine may operate in the capacity of a server or a client computer system in a client-server network environment, or as a peer computer system in a peer-to-peer (or distributed) network environment. The computer system may be any special-purpose computer system capable of executing a set of instructions (sequential or otherwise) that specify actions to be taken by that computer system for performing the functions describe herein. Further, while only a single computer system is illustrated, the term “computer system” shall also be taken to include any collection of computer systems that individually or jointly execute a set (or multiple sets) of instructions to perform any one or more of the methodologies discussed herein.
As discussed above, at 305 the computer system may detect a heap spray attack in the scanned memory sections by looking at the scanned memory sections to see if the scanned memory sections contain no-ops patterns that are associated with heap spray attacks. No-ops patterns that are associated with heap spray attacks may be pre-configured or stored in a scanning module such as scanning module 129. The pre-configured no-ops patterns may be downloaded from a central server, and may include patterns that are computer architecture (e.g., Intel, ARM) specific. The no-ops patterns may also be user configured by an administrator or user. The administrator or user may add new or change existing no-op patterns. Furthermore, no-ops patterns may be generated using machine learning techniques that analyze prior no-ops patterns and behavior of a single computer, across an enterprise or across multiple enterprises.
An application process may have one or more heap memory 111 allocations, each having one or more heap segments. To scan a particular application for a heap spray attack, in one embodiment, all corresponding heap segments of the process may be scanned. Alternatively, a subset of an application process's heap segments may be scanned. In another alternative, multiple processes' heap segments may be scanned. Scans may be generally run by a scanning module at any frequency appropriate to detect heap spray attacks. In one embodiment, scans may be run at a frequency that is determined based on the monitored application calls. For example, the scanning module may run a scan every time a system call is intercepted.
In condition A, the computer system may perform a first series of steps. In particular, at step 403a the computer system may determine the number of no-ops in the scanned section of computer program memory and then at step 403b determine whether the number of no-ops exceeds a number of no-ops threshold. In one embodiment, the threshold may be predetermined and stored in a memory of the computer system. If it is determined at step 403b that the number of no-ops exceeds a threshold, the computer system may provide an indication that there is a heap spray present in the scanned section of computer program memory.
In condition B, the computer system may perform a second series of steps. In particular, the computer system at step 403c may determine the number of no-ops in the scanned section of computer program memory, at step 403d the computer system may then determine the total number of computer instructions in the scanned section of computer program memory, and at step 403e the computer system may determine whether the number of no-ops exceeds a threshold percentage of the total number of computing instructions in the scanned section of memory. Step 403e may involve comparing the determined number of no-ops to the determined total number of computer instructions and calculating a percentage corresponding to the number of no-ops divided by the total number of computer instructions. Furthermore, step 403e may involve comparing the calculated percentage with a threshold percentage. In one embodiment the threshold percentage may be predetermined and stored in a memory of the computer system. If it is determined at step 403e that the number of no-ops exceeds a threshold percentage of the total number of computing instructions, then the computer system may provide an indication that there is a heap spray present in the scanned section of computer program memory.
In condition C, the computer system may perform a third series of steps. In particular, the computer system at step 403f may determine a spatial locality metric for the no-ops in the scanned section of computer program memory. At step 403g the computer program may determine whether the spatial locality metric exceeds a spatial locality threshold. If it is determined at step 403g that the no-ops within the scanned section of computer program memory are adjacently located then the computer system may provide an indication that there is a heap spray present in the scanned section of computer program memory.
At step 405 the computer system may detect the presence of a heap spray attack in the scanned section of computer program memory based on conditions A, B, and/or C. If one or more of the series of steps provides an indication that there is a heap spray present in the scanned section of the computer program memory, then the computer system may detect the presence of a heap spray attack.
If, at step 405, the computer system determines the presence of a heap spray in the scanned section of computer program memory the computer system may proceed to step 407 and mitigate a heap spray attack. Mitigating a heap spray attack 307 may include taking one or more defensive actions such as providing a notification or alarm to a user of the computer system and/or isolating the no-op sections within the section of computer program memory. Defensive actions may also include terminating the process by flushing it from memory. In one embodiment, providing a notification or alarm to a user of the computer system may include recording the forensic information associated with the heap spray attack but allowing the heap spray attack to continue running.
In addition to or alternatively to the three series of steps illustrated in
The systems and methods described herein may be implemented on any suitable operating system including for example, Windows, Linux, and iOS.
While the present disclosure has been discussed in terms of certain embodiments, it should be appreciated that the present disclosure is not so limited. The embodiments are explained herein by way of example, and there are numerous modifications, variations and other embodiments that may be employed that would still be within the scope of the present disclosure.
This application is a continuation of U.S. Ser. No. 16/242,292, which claims priority to U.S. Provisional Application Ser. No. 62/614,616, filed Jan. 8, 2018, the content of which is incorporated herein by reference in its entirety.
Number | Date | Country | |
---|---|---|---|
62614626 | Jan 2018 | US |
Number | Date | Country | |
---|---|---|---|
Parent | 16242292 | Jan 2019 | US |
Child | 17578533 | US |