IMPROVING SECURE MAIN MEMORY PROGRAMMING USING A SIDEFRAME LICENSE PLATE MECHANISM
Patent Information
- Application Number
- DE112020004190
- Authority / Receiving Office
- DE · DE
- Patent Type
- Patents
- Current Assignee / Owner
- Priority Date
- 2019-11-08
- Filing Date
- 2020-10-16
- Publication Date
- 2024-09-19
- Estimated Expiration
- 2040-10-16
Smart Images

Figure 00000000_0000_ABST
Abstract
Description
BACKGROUND The present invention relates to computer security and, more particularly, to techniques for using a page frame tag mechanism to mitigate return oriented programming (ROP) attacks. Software programs (or applications) can, in some cases, be vulnerable to various types of exploits. These exploits can, for example, allow the injection and execution of malicious code within a program, allow privilege escalation, allow the program to perform actions normally restricted by system administrators, steal data, and the like. Some of these exploits can allow unauthorized users to access and exfiltrate data on a computer system. A common exploit involves attacking a program's execution flow by modifying the call stack. The call stack, for example, is a crucial data structure used and maintained throughout application execution. The execution flow (of a program) can be controlled by pushing the return addresses of called functions to the stack. Malicious actors can therefore manipulate the call stack to redirect program execution to execute arbitrary code. ROP is an example of a commonly used exploit that involves modifying the call stack. In a ROP exploit, a malicious actor typically uses several pieces of existing code (commonly referred to as "graphical objects" (gadgets)) to execute user interface (shell) code.For example, the malicious actor can manipulate the return address in the stack to execute a gadget by replacing the value of the return address with the address for the gadget. When chained together, these actions allow the malicious actor to perform arbitrary operations that affect the program's execution flow. Conventional techniques used to defend against ROP techniques include implementing address space layout randomization or control flow integrity systems. Address space layout randomization involves, for example, ordering the address space locations of process data regions to prevent an attacker from jumping unhindered to exploitable functions in memory. Control flow integrity systems typically utilize techniques that include preventing the control flow itself from being affected by the exploit. However, these conventional techniques involve high runtime overhead, limited hypervisor support, and so on. Furthermore, implementing these techniques can result in significant, labor-intensive code reordering. US 2018 / 0095902 A1 discloses a processor system enabling memory operand type enforcement using protection keys. The processor system for providing sandbox execution support for attacks with protection key privileges includes a processor core for executing a task associated with an untrusted application and for executing the task using a designated page of memory; and a memory management unit for designating the page of memory to support execution of the untrusted application.The memory management unit comprises: a storage unit for storing a page table entry associated with a page of memory, the page table entry including a protection key field identifying a location of a protection key right entry (PKR); and a PKR register containing the PKR entry, the PKR entry including a set of bits. The memory management unit is configured to deny, in response to a request to clear a bit of the set of bits of the PKR, the request to clear a bit of the set of bits of the PKR based on a comparison with a PKR update mask. US 2019 / 0095613 A1 discloses a computer-implemented method for preventing return-oriented programming (ROP) attacks, comprising registering one or more critical regions, wherein a critical region corresponds to an address selected to be monitored for potential ROP attacks; identifying one or more critical functions, wherein a critical function corresponds to a function selected to be analyzed as a potential ROP threat; identifying one or more critical functions, wherein a critical function corresponds to a function selected to be analyzed as a potential ROP threat; instrumenting the one or more critical regions with ROP protection mechanisms; detecting an attempted execution of a critical function in one or more of the identified critical regions;Determining whether values associated with the critical function match corresponding expected values; and in response to determining that values associated with the critical function do not match expected values, activating a return-oriented programming protection mechanism. SUMMARY An embodiment presented herein describes a method for mitigating a return-oriented programming (ROP) attack that occurs during the execution of an application. The method generally comprises receiving source code for compiling into an executable application. The method further comprises, during compilation of the source code, determining one or more functions within the source code associated with gadgets in a ROP attack and assigning each of the one or more functions to one or more protected pages of main memory for the executable application. The method further comprises, during compilation of the source code, assigning a tag to each of the one or more functions. The tag for each function is associated with the protected main memory page to which the function is assigned. Other embodiments include, but are not limited to, a computer program product comprising a storage medium containing computer-readable program code that enables a processing unit to implement one or more aspects of the disclosed methods, and a data processing system including a processor, main memory, and application programs configured to implement one or more of the disclosed methods. BRIEF DESCRIPTION OF THE DIFFERENT VIEWS IN THE DRAWINGS Embodiments of the invention will now be described, by way of example only, with reference to the accompanying drawings, in which: Fig. 1 illustrates an example data processing system configured with a protection component according to an embodiment. Fig. 2 illustrates an example implementation of a main memory protection key mechanism within a data processing system according to an embodiment. Fig. 3 illustrates an example of a return-oriented programming attack according to an embodiment. Fig. 4 is a flowchart of a method for mitigating a return-oriented programming attack according to an embodiment. Fig. 5 illustrates an example of functions associated with protected page frames according to an embodiment.Figure 6 illustrates an example of mitigating a ROP attack on an application according to one embodiment. Figure 7 is a flowchart of a method for executing an application according to one embodiment. Figure 8 illustrates an example data processing system configured to mitigate a ROP attack on an application according to one embodiment. For ease of understanding, identical reference numerals have been used, where possible, to identify identical elements appearing in the drawings. It is intended that elements and features of one embodiment may be advantageously incorporated into other embodiments without further elaboration. DETAILED DESCRIPTION Embodiments described herein provide methods, processing systems, and computer-readable media for using a page frame tagging mechanism supported in hardware within a data processing system to mitigate return-oriented programming (ROP) attacks on software applications. For example, some data processing systems may support a main memory protection key feature that allows protection keys to be assigned to main memory pages for access control purposes. When this feature is enabled, a set of bits (e.g., four bits) in each page table entry can be used to assign one of a set of (e.g., sixteen) key values to a specific page. These key values can be used to enforce protection measures on a per-page basis. For example, a data processing system supporting this feature may use a register with two bits for each key value to control write and read attempts to a specific page. Setting the write-disable bit for a specific key blocks attempts to write to a page with that key value.Similarly, setting the Disable Access bit for a particular key blocks attempts to read a page with that key value. Embodiments described herein may advantageously utilize the main memory protection key feature (typically used to enforce page-based protection measures) within a data processing system to mitigate ROP attacks. More specifically, embodiments may use the main memory protection key feature to assign labels to each function within protected page frames so that the program executes and runs in a specific order. In an embodiment described in more detail below, a compiler may, during source code compilation time, identify a set of functions within the source code associated with ROP attacks (e.g., high-risk functions vulnerable to being used as gadgets in a ROP attack), assign the identified set of functions to protected page frames (e.g.,protected with a main memory protection key) and assigning a label to each function. By assigning high-risk functions to protected page frames in this way, embodiments can mitigate exploits that attempt to modify the program's execution. For example, embodiments can prevent a malicious actor from taking advantage of gadgets to mount a ROP attack, because a program protected using the techniques presented herein will not execute if a called labeled function has an incorrect label. Fig. 1 illustrates an example data processing system 100 configured with a protection component 110, according to one embodiment. The data processing system 100 includes one or more applications 102, a compiler 104, an operating system 106, and hardware 108. The data processing system 100 represents various computing devices, including, for example, a desktop computer, a notebook computer, a mobile device, a tablet computer, etc. The hardware 108 includes a processor(s) 120 and main memory 122. The processor(s) 120 may represent one or more processors (e.g., microprocessors, central processing units (CPUs), etc.) or multi-core processors. The processor(s) 120 may include various registers, buffers, main memory, and other integrated circuit devices and may operate according to reduced instruction set (RISC) computing techniques.Main memory 122 may include a variety of computer-readable media, including, for example, volatile and / or non-volatile media, removable and / or non-removable media, etc. Main memory 122 may include one or more caches, random access memories, read-only memories, etc. Furthermore, main memory 122 may include main memory physically located within data processing system 100 or on another computing device coupled to data processing system 100. The data processing system 100 operates under the control of the operating system 106, which is responsible for executing applications 102 and managing the applications' 102 access to hardware 108. The operating system 106 generally represents any operating system, examples of which include, but are not limited to, versions of Microsoft® Windows®, Linux® and Unix® distributions, etc. As shown, the operating system 106 includes a system call interface 116 and a page frame allocation function 118 located within the kernel 114 of the operating system 106. The application(s) 102 may request services from the operating system 106 (e.g., make system calls) via the system call interface 116. The service request may include a request for one or more processes, requests to create and execute new processes, requests for access to various hardware devices (e.g., certain peripheral devices, etc.).), requests related to data transfer services, and others. The application 102 may be implemented as a set of instructions stored in main memory 122, and the processor(s) 120 may be configured to execute the instructions to perform a specified task or set of tasks. The page frame allocation function 118 may allocate and / or deallocate main memory to application processes based on their needs. In one embodiment, the page frame allocation function 118 may maintain a list of free pages of physical main memory from which it may allocate pages to application processes. In embodiments described herein, data processing system 100 supports a main memory protection key mechanism that allows one or more protection keys (pkeys) 124 to be assigned to main memory pages (e.g., assigned by page frame allocation function 118) for access control purposes. Using this mechanism, a particular application (or process) 102 can configure its main memory into multiple regions and selectively disable or enable access to any of these regions. For example, a protection key 124 is generally a multi-bit value (e.g., four bits) that may be stored in each page table entry for each page in an application's address space. Thus, assuming a protection key 124 is a four-bit value, pages can be assigned to one of sixteen key values.For each of these keys, application 102 can configure processor(s) 120 to deny write or read operations with respect to the respective main memory pages protected by the key. In one example, application 102 can obtain a protection key 124 via system call interface 116 using a "pkey_alloc()" system call, which returns an integer index indicating which key has been allocated. Application 102 can assign a key to a specific page via system call interface 116 using a "pkey_mprotect()" system call. Application 102 can use the "pkey_free()" system call to allocate or release a protection key to make it available for later allocations. Fig. 2 illustrates an exemplary implementation of the main memory protection key mechanism according to one embodiment. Here, the page frame allocation function 118 includes a page table 202 and a protection key rights for user pages (PKRU) register 204. The page table 202 includes one or more page table entries 206, each of which may be assigned a protection key 124. The PKRU register 204 is a control register that includes two separate bits for the rigid protection key 124 (e.g., an access disable bit and a write disable bit). In this example, the PKRU register 204 includes two separate bits for a first protection key 124A ("foo") and a second protection key 124B ("bar"). The PKRU register 204 can determine, for each protection key 124, whether the main memory page (of the page table entry 206) associated with that protection key 124 can be accessed (e.g., read from or written to). In this particular example, the page table entry 206 includes a protection key field 208 for a protection key 124 that applies to user-level pages (e.g., U / S = 1). The protection key 124 within the protection field 208 is used as an index to the PKRU 204. Access permissions to the main memory pages are then determined based on previous page permissions (from the page table entry 206) and the PKRU permissions for the protection key 124 (associated with the page table entry 206). For example, if the PKRU permissions deny access to a particular main memory page, the application 102 may be denied access to that main memory page.Similarly, direct main memory accesses to this main memory page from core 114 may also be rejected. Referring again to Fig. 1, compiler 104 may generally translate source code from a high-level programming language (e.g., C, C++, etc.) into a lower-level language (e.g., assembly code, object code, machine code, etc.) to create an executable program (e.g., application 102). Note that while Fig. 1 illustrates compiler 104 as being within data processing system 100, in other embodiments, compiler 104 may be located within another data processing system. In some embodiments, compiler 104 may be located in a data processing system hosted in a cloud computing environment (not shown). In some embodiments, application 102 may make use of functions coded either into the program itself or as part of a library (e.g., C library (libc)) stored in main memory 122.Functions can be defined within applications 102 (or programs) or separately in libraries that can be used by multiple applications. A function is often coded so that it can be started or called multiple times and from different locations during the execution of an application 102, including from other functions, and then branch or return to the next instruction after the call once the task is completed. A function can also be referred to as a procedure, subroutine, routine, method, subprogram, etc. A processor 120 may use a call stack to implement function calls and returns. For example, each function call creates a new entry, or stack frame, at one end of the stack. When the function returns, the stack frame is deleted from the stack, and the space can be used for other function calls. Each stack frame may include the private data (e.g., parameters and internal variables) of the corresponding call and return address (e.g., the address of the instruction after the call). A call stack is used to track the point to which each active function should return control when it finishes executing. For example, an active function is one that has been called but has not yet completed execution, after which control should return to the point of the call or to the calling function. A function may also include a function prologue and a function epilogue, which enclose the function body and can be used to manipulate the stack. For example, the function prologue appears at the beginning of the function and prepares the stack and registers for use within the function. Similarly, the function epilogue appears at the end of the function and restores the stack and registers to the state they were in before the function was called. The function epilogue typically includes the function exit point or the return instruction, such as "ret" in x86 assembly language. As noted, a malicious actor often uses multiple gadgets in a ROP attack to manipulate the call stack and alter program execution. As used herein, a gadget is a sequence of instructions that provides an operation for a return-oriented program. Each gadget may end with a return instruction (e.g., the x86 RET instruction). For example, "move eax. 10: ret" is a gadget that sets eax to 10 (decimal). The gadgets are typically sequences of instructions found in main memory (e.g., in the address space) of application 102. An example source of such a gadget is a library, such as libc, that is accessible to application 102.By analyzing the binary code of an operating system's programs or libraries, malicious actors can often identify sequences of instructions that can be used as gadgets. In general, any instruction sequence that ends with a destination address that can be determined at runtime, such as a return instruction, can potentially be used as a gadget. Examples of commonly used gadgets include gadgets that store and load data from one location to another (e.g., register to register, register to main memory, main memory to register, etc.), gadgets that perform arithmetic operations (e.g., ADD, SUB, MUL, DIV XOR, rotations, shifts, etc.), and so on. In some cases, a malicious actor may execute the ROP attack in the form of a return-oriented program. The return-oriented program may, for example, include one or more gadgets arranged in a specific order so that, when executed, they implement the malicious actor's intended behavior. A payload at the gadgets may be placed in the main memory of the exploited applications (e.g., application 102), and the stack pointer may be redirected to point to the first gadget. In one example, this may be achieved using a stack buffer overflow. The gadget frames are typically placed on the overflowed stack so that the first gadget has overwritten the stored instruction pointer of a particular function. When that function attempts to return, the return-oriented program is executed instead.Each gadget in the return-oriented program is structured so that when the return instruction in the last instruction of the sequence is executed, the stack pointer points to the next gadget to be executed. In this way, the return-oriented program executes one gadget at a time, thereby changing the intended execution flow of the application 102. Fig. 3 illustrates a reference example of a ROP attack according to one embodiment. In this reference example, application 102 starts at 302 and waits for user input at 304 (e.g., application 102 may call a function that requires user input). Here, application 102 may contain a known vulnerability at 304 (e.g., the application is vulnerable to a buffer overflow in the call stack). At 306, a malicious actor exploits this vulnerability and overwrites stack 350 with arbitrary data. As shown, in this case, the buffer overflow overwrites the return address of the called function and subsequent stack regions with main memory addresses of interest. At 308, execution of the application 102 continues, and at 310, the current function returns. However, instead of returning to the previous return address associated with the current function, the application 102 returns to the address of a first gadget (within the library 360 located in the main memory of the application 102) and executes instructions associated with the first gadget at 312. When the return instruction of the first gadget is executed, the application 102 returns to the address of a second gadget (within the library 360) and executes instructions associated with the second gadget at 314. When the return instruction of the second gadget is executed, the application 102 returns to the address of a third gadget (within the library 360) and executes instructions associated with the third gadget at 316. In this process, each gadget is accessed via a return function (e.g.,ret) is called, and this gadget ends with a return function that points to the next gadget. The malicious actor can pass the gadget arguments within the library 360 via the stack 350. This process can continue in this way until the malicious actor achieves their goal. For example, a malicious actor can use this ROP attack to force an arbitrary order of function execution to open doors (e.g., opening a root shell on Unix) that can be exploited by the malicious actor. Furthermore, the ROP attack illustrated in Fig. 3 can be implemented without injecting new code. That is, the ROP attack reuses functions from a library (library 360, such as libc) in main memory and passes arbitrary parameters to the functions in the stack 350. Embodiments described herein provide techniques that can mitigate ROP attacks, such as the ROP attack illustrated in Fig. 3, by leveraging the main memory protection key mechanism (e.g., illustrated in Fig. 2) supported by data processing system 100. Referring again to Fig. 1, compiler 104 includes a protection component 110 configured to implement one or more techniques described herein for mitigating ROP attacks. Note that Fig. 1 illustrates only one possible arrangement of data processing system 100, and that other arrangements of data processing systems may be used to implement the techniques described herein.For example, in one embodiment, compiler 104 may reside on another data processing system and compile source code using the techniques described herein for execution by data processing system 100. In one embodiment, protection component 110 may protect CPU instructions of an application 102 with one or more protection keys 124 during compile time to protect application 102 from ROP attacks when executing on data processing system 100. For example, when compiling source code of an application 102, protection component 110 may associate "high-risk" functions that are vulnerable to being used as gadgets for page frames within main memory 122 that are protected with one or more protection keys 124. In one embodiment, protection component 110 may determine that a function is a "high-risk" function based on a preconfigured list of functions received from a developer (e.g., a developer of application 102). When compiling the source code, the protection component 110 may also assign a protection tag 112 to each of the "high-risk" functions protected with a particular protection key 124. Each protection tag 112 is associated with a particular page frame protected with a protection key 124. In an embodiment described in more detail below, the protection component 110 may use the protection tags 112 to define the proper execution order of functions within the source code of the application 102, such that functions of the application 102 are only executed if the page frame in which the function is located contains the proper tag order. Fig. 4 is a flowchart of a method 400 for mitigating ROP attacks according to one embodiment. The method 400 may be performed by a compiler (e.g., compiler 104). In one embodiment, the method 400 may be performed during compile time (e.g., before runtime or execution) of the application 102. The method 400 may enter the flow at block 402, where the compiler starts the build phase. At block 404, the compiler identifies a type of one or more functions within the source code. At block 406, the compiler determines which types of functions of the source code are "high-risk" functions that are vulnerable to being used as gadgets. Examples of "high-risk" functions may include functions vulnerable to buffer overflow attacks (e.g., copy functions, move functions, etc.). In one embodiment, the compiler may determine a set of "high-risk" functions based on a predetermined list of such functions received from a developer. In another embodiment, the compiler may use information associated with the source code (e.g.,Analyze or evaluate a set of developer guidelines received from a source code developer. For example, the developer guidelines may specify which types of functions should be mapped to different page frames to protect the functions from being used as gadgets in a ROP attack. At block 408, the compiler triggers the assignment of each of the set of "high-risk" functions to one or more page frames protected with one or more protection keys 124. In one embodiment, the compiler may trigger the assignment by instructing (or requesting) a page frame assignment function (e.g., page frame assignment function 118) to assign the set of "high-risk" functions to one or more page frames protected with one or more protection keys 124. After assignment, the computer assigns a protection flag 112 to each function in the set of "high-risk" functions (block 410). In one embodiment, the compiler may use a system call (e.g., pkey_alloc_flag()) via the system call interface 116 to assign each protection flag 112.Assigning a guard flag 112 to a particular function modifies the function prologue and epilogue to include the guard flag 112. The compiler specifies the order in which the functions in the source code are to be executed via the set of guard flags 112. Once the guard flags 112 are assigned, the compiler may terminate the build process (block 412), and the method 400 ends. Fig. 5 illustrates an example of functions associated with page frames protected with protection keys 124 according to one embodiment. In this embodiment, compiler 104 assigns three different functions, A(), B(), and C(), to three different page frames 502A, 502B, and 502C, respectively. Each page frame 502A, 502B, and 502C is protected by a respective protection key 124A, 124B, and 124C. As shown, compiler 104 also assigns protection tags 112A, 112B, and 112C to functions A(), B(), and C(), respectively. Each protection tag 112 is associated with one of protection keys 124. As noted, the compiler 104 may use the set of protection flags 112 to control which functions of the application 102 are executed and / or to define the order in which the "high-risk" functions of the application 102 are executed.For example, because compiler 104 processes the order of authorized functions with protection keys 124, the functions can only be executed if each page frame has the correct tag order. Thus, if a malicious actor attempts to change the function call order, application 102 may crash because the function call does not contain the correct protection key. Note that while Fig. 5 illustrates three functions associated with three different protected page frames, in other embodiments, the functions identified as "high risk" may be associated with protected page frames in other ways. For example, in some embodiments, multiple functions may be associated with the same protected page frame. In these embodiments, each of these functions may be assigned a protection tag 112 associated with the same protection key 124. In other embodiments, there may be multiple functions associated with the same page frame protected with multiple protection keys 124.For example, in these embodiments, different main memory areas (or regions) within the page frame may be protected with a different protection key 124, and one or more functions may be assigned (or associated) to the different main memory areas. Consider the exemplary scenario illustrated in Fig. 6 of an ROP attack on an application 102 compiled using the ROP mitigation techniques described herein. Similar to the ROP attack in Fig. 3, in this ROP attack, a malicious attacker exploits a vulnerability (e.g., a buffer overflow) in the application at 306 (e.g., after the program starts at 302 and stops to wait for input at 304). Specifically, the malicious actor attempts a buffer overflow on the stack 350, overwriting the return address of the called function with the address of a gadget within the library 360 of the main memory page 502.However, in this embodiment, if the corrupted return address at 602 attempts to call the gadget in main memory, execution halts because the called function is tagged and the function call does not provide the correct protection flag 112 (the protection flag 112 associated with the protection key 124 for the main memory page 502). In this way, embodiments provide a secure mechanism that can be fully implemented by the compiler and that is transparent to the user and the developer. Furthermore, embodiments can implement the techniques described herein with minimal overhead (e.g., relative to the overhead associated with conventional techniques) and do not require reordering of source code. Fig. 7 is a flowchart of a method 700 for executing an application (e.g., application 102) compiled by a compiler (e.g., compiler 104) according to one embodiment. The method 700 may be performed by one or more components (e.g., processor(s) 120) of the data processing system 100. The method 700 may enter flow at block 702, where the data processing system 100 detects one or more protection tags (e.g., protection tags 112) from a prologue of a (first) function associated with the application. As noted, the protection tags are associated with functions located within main memory pages protected with one or more protection keys (e.g., protection key 124). At block 704, the data processing system 100 begins executing the function. In one embodiment, the data processing system 100 may pause, for example, for user input or to perform another operation. In some cases, during execution, a malicious actor may exploit a vulnerability within the application and cause a buffer overflow that overwrites the return address of the first function with the address of another (second) function (or gadget) in main memory.For example, at block 706, data processing system 100 determines that the function return calls another function in main memory. At block 708, data processing system 100 determines whether the function return call includes the protection flag(s) associated with the other function. If the function return call does not include the relevant protection flag(s), data processing system 100 halts execution and blocks access to the other function (block 710). If the function return call does include the relevant protection flag(s), data processing system 100 executes the other function (block 712). Method 700 then exits. In one embodiment, the data processing system may perform repetitions of the operations in 702, 704, 706, and 708 as part of performing the operations in 712. Fig. 8 illustrates a data processing system 800 according to one embodiment that is configured to perform onboarding of devices. As shown, the data processing system 800 includes, but is not limited to, a central processing unit (CPU) 805, a network interface 815, a main memory 820, and a storage 860, each connected to a bus 817. The data processing system 800 may also include an I / O device interface 810 for connecting I / O devices 812 (e.g., a keyboard, display, and mouse unit) to the data processing system 800. Further, in the context of this disclosure, the data processing elements shown in the data processing system 800 may be associated with a physical data processing system (e.g.,a system in a data center), or it may be a virtual computing instance running within a computing cloud. The CPU 805 retrieves and executes programming instructions stored in the main memory 820 and stores and retrieves application data located in the main memory 820. The interconnect 817 is used to transfer programming instructions and application data between the CPU 805, the I / O device interface 810, the memory 860, the network interface 815, and the main memory 820. It should be noted that the CPU 805 is representative of a single CPU, multiple CPUs, a single CPU containing multiple processing cores, and the like. The main memory 820 is generally representative of random access memory. The memory 860 may be a disk drive storage unit. Although the memory 860 is shown as a single unit, it may be a combination of fixed and / or removable storage units, such asHard disk drives, removable memory cards, or optical storage, network-attached storage (NAS), or a storage area network (SAN). Memory 860 contains protection tags 112 and protection keys 124, which are described in more detail above. For illustrative purposes, main memory 820 contains compiler 104 and operating system 106, which are described in more detail above. The descriptions of the various embodiments of the present invention are intended to be illustrative, but are not intended to be exhaustive or limited to the disclosed embodiments. Many modifications and variations will occur to those skilled in the art without departing from the scope and spirit of the described embodiments. The terminology used herein has been chosen for the purpose of explaining the principles of the embodiments, practical application, or technical improvement over current technology, or to enable others of similar skill in the art to understand the embodiments disclosed herein. In the following, reference is made to embodiments presented in this disclosure. However, the scope of the present disclosure is not limited to the specific embodiments described. Rather, any combination of the following features and elements, regardless of whether they are associated with different embodiments, is conceivable to realize and practice the invention. Furthermore, although embodiments disclosed herein may achieve advantages over other possible solutions or over the prior art, a specified embodiment does not limit the scope of the present disclosure regardless of whether a particular advantage is achieved by a specified embodiment.Therefore, the following aspects, features, embodiments, and advantages are merely illustrative and are not intended to be elements or limitations of the appended claims, except where expressly stated in a claim(s). Likewise, reference to "the invention" should not be construed as a generalization of any inventive subject matter disclosed herein and should not be considered elements or limitations of the appended claims, except where expressly stated in a claim(s). Aspects of the present invention may take the form of an embodiment implemented entirely in hardware, an embodiment implemented entirely in software (including, but not limited to, firmware, resident software, microcode, etc.), or an embodiment combining software and hardware aspects, generally referred to herein as a "circuit," "module," or "system." The present invention may be a system, a method, and / or a computer program product. The computer program product may include computer-readable storage medium(s) having computer-readable program instructions stored thereon for causing a processor to perform aspects of the present invention. The computer-readable storage medium may be any tangible device on which instructions can be stored and retained for use by an instruction-executing device. The computer-readable storage medium may be, for example, but not limited to, an electronic storage device, a magnetic storage device, an optical storage device, an electromagnetic storage device, a semiconductor storage device, or any suitable combination of the foregoing.A non-exhaustive list of more specific examples of the computer-readable storage medium includes the following: a portable computer diskette, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), static random access memory (SRAM), portable read-only memory in the form of a compact disc (CD-ROM), a digital versatile disc (DVD), a memory stick, a floppy disk, a mechanically encoded device such as punched cards or raised structures in a groove with instructions recorded thereon, or any suitable combination of the foregoing.A computer-readable storage medium as used herein shall not be construed as including transient signals per se, such as radio waves or freely propagating electromagnetic waves, electromagnetic waves propagating through a waveguide or other transmission media (e.g. light pulses traveling through a fiber optic cable), or electrical signals transmitted via a cable. Computer-readable program instructions described herein may be downloaded from a computer-readable storage medium to respective computing / processing units or to an external computer or storage unit over a network, for example, the Internet, a local area network, a wide area network, and / or a wireless network. The network may include copper transmission cables, fiber optic transmission lines, wireless transmission, routers, firewalls, switches, gateway computers, and / or edge servers. A network adapter card or network interface in the computing / processing unit receives computer-readable program instructions from the network and forwards the computer-readable program instructions for storage in a computer-readable storage medium within the respective computing / processing unit. Computer-readable program instructions for performing operations of the present invention may be assembly instructions, Instruction Set Architecture (ISA) instructions, machine instructions, machine-dependent instructions, microcode, firmware instructions, state-setting data, or either source code or object code written in any combination of one or more programming languages, including an object-oriented programming language such as Smalltalk, C++, or the like, and conventional procedural programming languages such as the "C" programming language or similar programming languages.The computer-readable program instructions may execute entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on the remote computer or server. In the latter scenario, the remote computer may be connected to the user's computer over any type of network, including a local area network (LAN) or a wide area network (WAN), or the connection may be made to an external computer (for example, over the Internet using an Internet service provider).In some embodiments, electronic circuits, including, for example, programmable logic circuits, field-programmable gate arrays (FPGAs), or programmable logic arrays (PLAs), that execute computer-readable program instructions may be configured to personalize the electronic circuit by utilizing state information of the computer-readable program instructions to perform aspects of the present invention. Aspects of the present invention are described herein with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be appreciated that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, may be implemented using computer-readable program instructions. These computer-readable program instructions may be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device to produce a machine such that the instructions, executing via the processor of the computer or other programmable data processing device, provide means for implementing the functions / acts specified in a block(s) of the flowchart(s) and / or block diagram(s).These computer-readable program instructions may also be stored in a computer-readable medium that can instruct a computer, other programmable data processing apparatus, or other devices to function in a particular manner, such that the computer-readable medium with instructions stored thereon comprises a product that includes instructions that implement the function / action specified in a block(s) of the flowcharts and / or block diagrams. The computer-readable program instructions may also be loaded into a computer, other programmable data processing apparatus, or other devices to cause a series of operations to be performed on the computer, other programmable devices, or other devices to create a computer-implemented process, such that the instructions executing on the computer, other programmable devices, or devices implement the functions / acts specified in a block or blocks of the flowcharts and / or block diagrams. The flowcharts and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of the present invention. In this context, each block in the flowcharts or block diagrams may represent a module, segment, or section of instructions comprising one or more executable instructions for implementing the specified logical function(s). In some alternative implementations, the functions specified in the block may be executed in a different order than that specified in the figures. For example, two blocks listed in succession may actually execute substantially concurrently, or the blocks may sometimes be executed in reverse order depending on the functionality associated with the blocks.Furthermore, it should be noted that each block of the block diagrams and / or flowchart representations, as well as combinations of blocks in the block diagrams and / or flowchart representations, may be implemented using dedicated hardware-based systems for performing the specified functions or acts, or using combinations of dedicated hardware and dedicated computer instructions. Embodiments of the invention may be provided to end users via a cloud computing infrastructure. The term "cloud computing" generally refers to the provision of scalable computing resources as a service over a network. More formally, cloud computing can be defined as a computing capability that provides an abstraction between the computing resource and its underlying technical architecture (e.g., servers, storage, networks), enabling user-friendly, on-demand network access to a shared collection of configurable computing resources that can be provisioned and released with minimal administrative effort or interaction with the service provider.Thus, cloud computing allows a user to access virtual computing resources (e.g., storage, data, applications, and even entire virtualized computing systems) in the “cloud,” regardless of the underlying physical systems (or the locations of the systems) used to provide the computing resources. Typically, cloud computing resources are provided to a user on a pay-per-use basis, where users are only charged for the computing resources actually used (e.g., an amount of storage space consumed by a user or a number of virtual systems instantiated by the user). A user can access any of the resources located in the cloud anytime, anywhere, via the Internet. In the context of the present invention, a user can access applications (e.g., compiler 104) and associated data available in the cloud. For example, compiler 104 could execute on a computing system in the cloud and compile source code for an application (e.g., application 102) using one or more ROP mitigation techniques described herein.In such a case, compiler 104 could identify "high-risk" functions in an application's source code, trigger the assignment of these "high-risk" functions to memory pages protected with one or more protection keys, and assign protection flags to the "high-risk" functions. The application 102 can then be stored for later retrieval by a computing system. For example, while executing the application, the computing system can then determine whether a particular function in main memory is accessible based on whether the function includes the relevant protection flags. This allows a user to access this data from any computing system connected to a network connected to the cloud (e.g., the Internet). While the foregoing is directed to embodiments of the present invention, other and further embodiments of the invention may be devised without departing from the basic scope thereof, the scope of which is defined by the following claims.
Claims
A computer-implemented method for mitigating return-oriented programming (ROP) attacks, the computer-implemented method comprising:receiving source code for compiling into an executable application;determining (406), during compilation of the source code, one or more functions within the source code associated with gadgets in a ROP attack;assigning (408), during compilation of the source code, each of the one or more functions to one or more protected pages (502) of main memory for the executable application;andassigning (410), during compilation of the source code, a tag (112) to each of the one or more functions, the tag for each function being associated with the protected main memory page to which the function is assigned, the method further comprising, during execution of the executable application: determining (710) that a function return (310) of the executable instruction calls a second function in main memory for the executable application; and upon determining that the function return does not include (708) the tag associated with the second function, halting (710) execution of the executable application; The computer-implemented method of claim 1, wherein determining the one or more functions within the source code associated with gadgets in the ROP attack comprises receiving a list of one or more functions associated with gadgets in the ROP attack from a developer of the source code. The computer-implemented method of claim 1, wherein determining the one or more functions within the source code associated with gadgets in the ROP attack comprises: determining one or more types of functions that can be used as gadgets in the ROP attack based on an evaluation of information associated with the source code received from a developer of the source code; and determining that the one or more functions is one of the determined types of functions that can be used as gadgets in the ROP attack. The computer-implemented method of claim 1, wherein assigning the identifier to each of the one or more functions comprises, for each of the one or more functions, modifying at least one of a prologue of the function and an epilogue of the function to include a reference to the identifier. The computer-implemented method of claim 1, wherein assigning each of the one or more functions to the one or more protected main memory pages comprises assigning each function to a different protected main memory page. The computer-implemented method of claim 1, wherein assigning each of the one or more functions to the one or more protected main memory pages comprises assigning a plurality of functions within the source code to a same protected main memory page. A system comprising:at least one processor; anda main memory storing one or more applications that, when executed by the processor, perform an operation to mitigate a return-oriented programming (ROP) attack that occurs during execution of an application, the operation comprising:receiving source code for compiling into an executable application;determining, during compilation of the source code, one or more functions within the source code associated with gadgets in a ROP attack;assigning, during compilation of the source code, each of the one or more functions to one or more protected pages of main memory for the executable application;andassigning, during compilation of the source code, a tag to each of the one or more functions, the tag for each function being associated with the protected main memory page to which the function is assigned,wherein the operation, during execution of the executable application, further comprises:determining (710) that a function return (310) of the executable instruction calls a second function in main memory for the executable application; andafter determining that the function return does not include (708) the tag associated with the second function, halting (710) execution of the executable application; The system of claim 7, wherein determining the one or more functions within the source code associated with gadgets in the ROP attack comprises receiving a list of one or more functions associated with gadgets in the ROP attack from a developer of the source code. The system of claim 7, wherein determining the one or more functions within the source code that are associated with gadgets in the ROP attack comprises: determining one or more types of functions that can be used as gadgets in the ROP attack based on an evaluation of information associated with the source code received from a developer of the source code; and determining that the one or more functions is one of the determined types of functions that can be used as gadgets in the ROP attack. The system of claim 7, wherein assigning the identifier to each of the one or more functions comprises, for each of the one or more functions, modifying at least one of a prologue of the function and an epilogue of the function to include a reference to the identifier. The system of claim 7, wherein assigning each of the one or more functions to the one or more protected main memory pages comprises assigning each function to a different protected main memory page. The system of claim 7, wherein assigning each of the one or more functions to the one or more protected main memory pages comprises assigning a plurality of functions within the source code to a same protected main memory page. A non-transitory computer-readable storage medium having computer-readable program code collectively stored thereon, the computer-readable program code executable by one or more processors to perform an operation for mitigating return-oriented programming (ROP) attacks, the operation comprising:receiving source code for compiling into an executable application;determining, during compilation of the source code, one or more functions within the source code associated with gadgets in a ROP attack;assigning, during compilation of the source code, each of the one or more functions to one or more protected pages of main memory for the executable application;andassigning, during compilation of the source code, a tag to each of the one or more functions, the tag for each function being associated with the protected main memory page to which the function is assigned,wherein the operation, during execution of the executable application, further comprises:determining (710) that a function return (310) of the executable instruction calls a second function in main memory for the executable application; andafter determining that the function return does not include (708) the tag associated with the second function, halting (710) execution of the executable application; The non-transitory computer-readable storage medium of claim 13, wherein determining the one or more functions within the source code associated with gadgets in the ROP attack comprises receiving a list of one or more functions associated with gadgets in the ROP attack from a developer of the source code. The non-transitory computer-readable storage medium of claim 13, wherein determining the one or more functions within the source code associated with gadgets in the ROP attack comprises: determining one or more types of functions that can be used as gadgets in the ROP attack based on an evaluation of information associated with the source code received from a developer of the source code; and determining that the one or more functions is one of the determined types of functions that can be used as gadgets in the ROP attack. The non-transitory computer-readable storage medium of claim 13, wherein assigning the identifier to each of the one or more functions comprises, for each of the one or more functions, modifying at least one of a prologue of the function and an epilogue of the function to include a reference to the identifier. The non-transitory computer-readable storage medium of claim 13, wherein assigning each of the one or more functions to the one or more protected main memory pages comprises assigning each function to a different protected main memory page.
Citation Information
Patent Citations
Enforcing memory operand types using protection keys
US20180095902A1
Return oriented programming attack protection
US20190095613A1
