ROP generation method and device for processing data dependence and side effects between Gadgets

By constructing exploit blueprints and Gadget computation graphs using the TGRop method, the ROP generation process is decomposed into multiple sub-objectives, resolving data dependencies and side effects, achieving more efficient ROP generation, and improving Gadget utilization and automated generation capabilities.

CN119026131APending Publication Date: 2024-11-26INSTITUTE OF INFORMATION ENGINEERING CHINESE ACADEMY OF SCIENCES
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410943936.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-07-15
Publication Date
2024-11-26

AI Technical Summary

Technical Problem

Existing automated ROP generation tools cannot effectively utilize Gadgets involving memory operations and complex arithmetic, resulting in a limited number of Gadgets. Furthermore, exploratory methods are prone to timeouts in large programs, and existing tools lack a systematic solution to the problems of data dependencies and side effects.

Method used

The TGRop method is adopted to decompose the exploitation process into multiple sub-objectives by constructing exploit blueprints and Gadget computation graphs, gradually build ROP chains, use SMT solvers to filter Gadgets, resolve data dependencies and side effects, and optimize the Gadget combination process.

Benefits of technology

It improves the efficiency and success rate of ROP generation, effectively utilizes more Gadgets, reduces the search space, and enhances the ability to automatically generate Gadgets in scenarios with limited Gadgets.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119026131A_ABST
    Figure CN119026131A_ABST
Patent Text Reader

Abstract

The invention belongs to the technical field of automatic vulnerability utilization, and relates to an ROP generation method and device for processing data dependence and side effects between Gadgets. The method comprises the following steps: setting a vulnerability utilization initial state; generating a vulnerability utilization blueprint based on the vulnerability utilization initial state and the vulnerability utilization process description; extracting Gadget semantic information in the program, and constructing a Gadget calculation graph based on the Gadget semantic information; according to the Gadget calculation graph and the vulnerability utilization blueprint, sequentially constructing ROP chains of all stages, and solving the problems of data dependence and side effects existing between Gadgets; and generating a complete ROP chain according to the ROP chain of each stage. According to the method, the whole vulnerability utilization process is decomposed into a plurality of sub-targets, so that the search space is effectively reduced, the effectiveness of an SMT solver is improved to the maximum extent, data dependence is solved, side effects are eliminated, and the efficiency and the success rate of the ROP generation process are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to automated vulnerability exploitation technology, which aims at the automated generation process of attack payloads for return-oriented programming (ROP), solves the data dependency and side effects in the process of automatically searching for vulnerability exploitation targets and combining instruction code snippets (Gadgets), and realizes the generation of ROP exploitation payloads. This solution focuses on how to use Gadgets containing memory operations and complex arithmetic operation semantics, and uses SMT solvers to identify and solve data dependency and side effects between Gadgets, overcoming the fundamental limitations of existing Gadget combinations and improving the automated generation capabilities of ROP in Gadget-restricted scenarios. Background Art

[0002] Return-oriented programming (ROP) is a common vulnerability exploitation technique that reuses code. It is usually based on hijacking the control flow of the program and reusing the existing instruction code in the program to execute a series of short instruction code fragments (ending with "ret / jmp / call" instructions, called "Gadgets") to trigger arbitrary malicious behavior. In real-world vulnerability exploits, ROP's exploit targets usually include: leaking program base addresses, stack migration, arbitrary function calls, arbitrary memory modifications, and arbitrary command execution. Before achieving these exploitation goals, we first need to search for Gadgets that set register values ​​and memory values ​​in the program, and link them together to form a specified function call or system call, and then execute different call targets to achieve the target exploitation effect. Since the ROP technology was proposed in 2007, it is still widely used in actual attacks. It is not limited to stack overflow type vulnerability exploits, but also appears in heap-related vulnerability exploits.

[0003] The classic ROP construction process usually includes three key steps, and the key steps of the automated ROP tool are the same: first, search for gadgets and identify their semantic information for classification, then select gadgets with specified semantics for combination based on the exploit requirements, and finally repair the data that gadgets depend on to ensure that the exploit target state is reached after the ROP is executed. So far, the research on automated ROP generation schemes in academia and industry can be divided into three categories, which can be summarized as: hard-coded rule ROP generation, heuristic ROP generation, and exploratory ROP generation. ROP generation schemes based on hard-coded rules mainly match and link gadgets based on regular expression rules. They only select gadgets with fixed forms for linking (such as ROPgadget and Ropper). Heuristic ROP generation schemes mainly classify gadgets by identifying their semantic information, and search and select gadget combinations for linking based on the classification information to generate ROP (such as Angrop, ROPium, and Exrop). The exploratory ROP automatic generation solution explores the reachability from the program state before the vulnerability exploit to the target exploit state through the SMT solver or symbolic execution, and solves a set of gadgets as a feasible solution through exploration. It does not need to consider any gadget classification and gadget side effects, but completes the automatic generation of ROP (such as SGC and Limbo) by exploring the feasible gadget combination solutions that are reachable in the state.

[0004] Among the existing heuristic ROP automatic generation schemes, Q, Angrop, ROPium, Exrop and RiscyROP tools are the most representative. They all follow three steps in the automatic link ROP. Step 1: Gadget semantic identification and classification. Heuristic-based methods use directed dependency graphs, symbolic execution and other methods to describe the semantic information of gadgets and complete the classification of gadgets. In this step, defining a complete semantic classification list for gadgets is a key link. Step 2: Gadget selection and combination. Based on the classified gadgets, heuristic automated tools will select and combine gadgets with matching semantic information in turn according to the exploit goals described by the user to complete ROP generation. Semantic matching is one of the clues for selecting gadgets, but when a gadget with completely matching semantics cannot be found, it is necessary to combine the semantics of multiple gadgets to achieve the required function. For example, tools such as Angrop use the method of building MOV connection graphs to find these combinations. In this method, gadgets containing mov instructions are identified, and their MOV source and destination operands are used as nodes of the graph, and the directions of MOV instructions are represented as edges in the graph. More gadget combinations that satisfy data transfer semantics can be found by traversing the paths in the MOV connection graph. The main difference between different automated ROP tools in this step is whether they support the use of gadgets with complex semantics in their gadget selection strategies. Angrop, RiscyROP, and Exrop only consider instructions containing simple arithmetic operations such as add and sub, conditional branch instructions under cmp instructions only, and direct jump instructions with the target address stored in a register. In addition, ROPium can also additionally support the use of gadgets containing memory write operations or operating on immediate values. However, some gadgets containing complex semantics, such as complex memory read and write operations, conditional branches, and complex arithmetic operations, are often not used due to data dependency issues and side effects. This challenge limits the application scope of available gadgets and reduces the success rate of ROP construction when the number of gadgets is small. In the third step, some customized repair techniques are used to eliminate and resolve the side effects and data dependency issues generated in the second step. For example, Angrop prevents subsequent gadgets from tampering with the set values ​​by maintaining a list of registers that each gadget combination can control, but this solution will miss some combinations. These solutions are temporary and do not consider conflicts between gadgets in memory write operations, especially for stack memory modifications.

[0005] Unlike heuristic approaches that rely on gadget classification, exploratory approaches make extensive use of hybrid symbolic execution and SMT solvers to link gadgets. Limbo generates ROP chains for programs with control flow integrity protection. It allows users to specify the initial states of registers and memory cells, and then selects gadgets that comply with the CFI policy for symbolic execution. By minimizing the distance between the target state and the state after executing the gadget, Limbo gradually builds a ROP chain that satisfies the exploit target. SGC converts the semantics and side effects of gadgets into constraints. After setting the ROP chain length, it randomly selects gadgets to combine into a complete ROP chain. By querying the SAT / SMT solver, SGC determines whether the ROP chain can successfully transform the initial state to the target exploitable state. These exploratory approaches follow a hypothesis testing process. During the exploration process, they keep trying until they time out or find a feasible solution. Although there are thresholds for the gadget chain length and the number of optional gadgets, the size of the constraint expression and the solution time still grow exponentially. Therefore, exploratory approaches are more suitable for small programs with limited gadgets, otherwise the performance overhead will become a bottleneck for the success of such approaches.

[0006] Therefore, in general, in this field of work, the current advanced automated tools still have limitations in terms of fundamental technical solutions, which makes them unable to generate ROP in some application scenarios. There are three main shortcomings:

[0007] (1) Existing works cannot perform ROP linking with gadgets involving memory operations and complex arithmetic, thus missing out on valuable gadgets.

[0008] (2) Some exploratory methods rely heavily on symbolic execution and SMT solvers, which can easily fail due to timeout when processing large programs containing a large number of candidate gadgets.

[0009] (3) When building ROP chains, existing state-of-the-art tools do not adopt a comprehensive system design, but instead rely on ad hoc solutions to handle data dependencies and eliminate side effects between gadgets, resulting in poor results. Summary of the invention

[0010] In order to iteratively solve the data dependency and side effect problems of gadgets to support the use of more gadgets, while ensuring efficient and more systematic search for gadget combination solutions and completing ROP automatic linking, the present invention designs and implements TGRop (Top Gun of Return-Oriented Programming Automation).

[0011] The technical solution of the present invention includes:

[0012] A heuristic automated ROP generation method that focuses on solving gadget data dependency and side effect problems. The steps include:

[0013] Set the initial state of the vulnerability exploit;

[0014] Generate vulnerability exploitation blueprint based on the initial state of vulnerability exploitation and vulnerability exploitation process description;

[0015] Extract gadget semantic information from the program and build a gadget computation graph based on the gadget semantic information;

[0016] According to the gadget calculation graph and vulnerability exploitation blueprint, build the ROP chain of each stage in sequence, and solve the data dependency and side effect problems between gadgets;

[0017] Generate a complete ROP chain based on the ROP chains at each stage.

[0018] Furthermore, the above method of the present invention specifically comprises the following steps:

[0019] (1) Before generating the ROP chain, the user needs to complete two preparations: (a) Set the register state and memory state of the vulnerability at the time of hijacking the control flow as the initial state of the target ROP chain. (b) Describe the vulnerability exploitation process based on the five interfaces provided by TGRop. Given the exploitation process, the target state after the ROP chain is executed can be uniquely determined. The ROP chain generated by TGRop can make the program reach the target state from the initial state, which means that the vulnerability exploitation is successfully completed.

[0020] (2) TGRop proposes a concept of "exploitation blueprint" to decompose the complex exploitation process into multiple sub-goals and stages. Here, each sub-goal corresponds to the five interfaces provided by TGRop, and each stage is defined by function calls or system calls. The exploitation blueprint serves as an execution guide to guide TGRop to gradually build the ROP chain of each stage, while solving data dependency and side effect problems for the gadgets in each sub-goal.

[0021] (3) Before linking a gadget, TGRop searches and identifies the semantic information of all potential gadgets in the program and constructs a gadget computation graph (GCG). GCG includes gadgets that involve memory operations and complex semantics, which allows us to use more gadgets for ROP linking, enhancing the ROP attack capability to a certain extent.

[0022] (4) Under the guidance of the blueprint, TGRop gradually completes the construction of the gadget chain stage by stage. Starting from the initial state, a ROP chain is generated for each stage through four steps, and the initial state is updated after each stage state is reached. If a stage fails due to an inappropriate initial state value, TGRop adds constraints, backtracks to adjust the ROP chain of the previous stage, and generates a new initial state for the subsequent stage. This workflow is repeated until a complete ROP chain is successfully constructed for all stages.

[0023] (5) In the first step of each stage, TGRop will use the SMT solver to select or combine gadgets to form a pre-linked ROP chain to individually satisfy the sub-goals in the blueprint. For sub-goals that can be semantically satisfied in a single gadget, it is directly selected as the gadget to be linked to the sub-goal; however, if the sub-goal cannot be directly achieved by a single gadget, it is necessary to traverse the reachable paths between different operand nodes in the GCG graph to search for a suitable gadget combination to fill the semantic gap in the data transfer between the two operands.

[0024] (6) After searching for a reachable path, TGRop uses the SMT solver to assist in screening the candidate gadgets on each edge for pre-linking, but does not consider solving data dependency and side effect problems at this stage. The initial state and target state of the sub-goal are converted into constraint expressions, and the gadget semantics on the path are converted into constraint expressions and added to them to screen the candidate gadgets on each edge that may connect the initial state and target state.

[0025] (7) In the second step of each phase, TGRop focuses on resolving data dependencies between gadgets. To solve this problem, TGRop creates new sub-goals in the blueprint and uses the SMT solver to screen candidate gadgets to fix the data dependency problem. This process ensures that the new sub-goals are executed before the original sub-goals, so that the target value is set correctly.

[0026] (8) In the third step of each stage, TGRop needs to determine the execution order of gadgets between sub-goals to eliminate potential side effects. The side effect semantics of gadget-B means that the execution of gadget-B destroys the program state previously set by gadget-A, causing the subsequent gadget-C to read an incorrect value during execution. This side effect that affects ROP execution needs to be identified and eliminated. TGRop uses the method of constructing a topological graph to obtain the correct execution order between gadgets. The gadgets are used as nodes in the topological graph, and the read and write relationships between gadgets for the same operands are used as directed edges of the topological graph to identify the required execution relationship between the two. Finally, topological sorting is performed to successfully obtain the correct gadget execution order.

[0027] (9) In the last step of each stage, TGRop links gadgets by topological sorting and generates ROP chains with the help of SMT solver.

[0028] (10) After completing the ROP chain generation at each stage, the program status is updated and the next stage of ROP chain automatic generation is entered according to the blueprint until the automatic generation of the attack payload of the entire blueprint is completed.

[0029] Furthermore, the initial state directly describes the register and memory states at the time of hijacking the control flow in JOSN format, such as {rax:0x10}.

[0030] Furthermore, the five interfaces provided by TGRop include five operations: (1) register setting; (2) memory reading; (3) memory writing; (4) function calling; (5) system calling. Using these user-friendly interfaces, TGRop users can describe the process of vulnerability exploitation in a way similar to writing C programs, which can also show the target exploitation status.

[0031] Furthermore, TGRop analyzes all gadgets in the target program to extract semantics and classify them accordingly, including gadgets ending with ret / jmp / call, etc. The semantics of each gadget is described using logical expressions through symbolic execution, and gadgets are divided into 15 categories based on different logical expressions. They describe the potential data flow operations in gadget execution. These data flow directions are used to construct edges in the GCG graph, and different operands are used as nodes in the GCG graph. Thus, a data flow relationship graph that can describe all gadgets in the program is constructed, and the paths in the graph represent the data transmission effect after different gadgets are combined.

[0032] Furthermore, during the construction of GCG, each edge represents a deeper category of gadgets based on operand-level semantics. The semantics of each gadget is analyzed, focusing on its source operands and target operands, and they are assigned to the corresponding edges in GCG. In the case of multiple source operands, these operands are identified as multiple graph nodes one by one, thereby creating multiple edges from each source operand to the target operand. To this end, all gadgets in the target program can be associated with one or more edges in the GCG graph.

[0033] Furthermore, in the first step of each stage, the data dependency and side effect problems between the gadgets of the sub-goals are not considered, which will be systematically solved in the second and third steps.

[0034] Furthermore, since function calls and system calls can be simply implemented through gadgets ending with ret, jmp, call and syscall, which obtain the target address from the user-controllable stack, register or memory to complete the final function call and system call, TGRop focuses more on how to search for gadgets to complete the setting of registers and memory (preparation of call parameters) and how to solve data dependencies and side effects (preconditions that need to be met to use a gadget).

[0035] Furthermore, if the SMT solver finds that adding a candidate gadget to an edge causes the constraint to be unsolvable, the gadget will be discarded. Therefore, after the candidate gadgets combination of each path is screened and pre-linked by the SMT solver, TGRop can provide multiple linking solutions, which provides the conditions for finally selecting an optimal ROP chain.

[0036] Furthermore, the data dependency problem of a gadget refers to the dependency of a gadget on the correct range of register values ​​or memory values ​​before execution to satisfy the target state of the sub-goal. These gadget data dependency types include: valid address, correct jump target, and appropriate register / memory value.

[0037] Furthermore, when linking gadgets to achieve these new sub-goals, additional data dependency problems may arise, which may lead to repeated sub-goal creation processes. TGRop maintains a list of data dependencies to systematically solve iterative data dependency problems and prevent infinite loop dependencies.

[0038] Furthermore, the root cause of the side effects between gadgets is that the gadget chains executed earlier update the initial program state (register or memory value), causing the execution of some gadget chains to fail to obtain the correct target value. Analytically, in order to avoid side effects, it is necessary to ensure that the write-read pairs between and within sub-target chains are never destroyed during the assembly process. More specifically, a write-read pair refers to a situation where an earlier gadget writes to a register or memory that is read by a later gadget. This order cannot be reversed, otherwise the value obtained by the later gadget will become incorrect. Similarly, a third gadget that sets the same register or memory cannot be inserted between the two.

[0039] Furthermore, TGRop generates a set of ROP chain solutions for each stage, and TGRop can give priority to using shorter ROP chains, with the number of instructions and stack size as the main evaluation factors. This optimization method helps to circumvent the limitations of certain vulnerabilities on the stack control range.

[0040] A ROP generation device for processing data dependency and side effects between gadgets, comprising:

[0041] The preparation module is used to set the initial state of vulnerability exploitation; generate the vulnerability exploitation blueprint based on the initial state of vulnerability exploitation and the description of vulnerability exploitation process; and extract the gadget semantic information in the program and build the gadget calculation graph based on the gadget semantic information;

[0042] The phase search module is used to build the ROP chain of each phase in sequence according to the gadget calculation graph and vulnerability exploitation blueprint, and solve the data dependency and side effect problems between gadgets;

[0043] The ROP chain generation module is used to generate a complete ROP chain based on the ROP chains of each stage.

[0044] The beneficial effects of the present invention are:

[0045] The TGRop of the present invention can use gadgets that involve memory operations or perform complex arithmetic calculations. TGRop effectively reduces the search space by decomposing the entire exploit process into multiple sub-goals, thereby maximizing the utility of the SMT solver. More importantly, TGRop adopts a systematic approach to solve data dependencies and eliminate side effects, improving the efficiency and success rate of the ROP generation process. BRIEF DESCRIPTION OF THE DRAWINGS

[0046] Figure 1 This is the overall flow chart of the TGRop tool.

[0047] Figure 2 This is a blueprint example diagram.

[0048] Figure 3 This is an example diagram of gadget semantic information extraction.

[0049] Figure 4 It is the Gadget Computation Graph (GCG).

[0050] Figure 5 This is a GCG graph traversal and ROP prelinking example graph.

[0051] Figure 6 The following are example diagrams for solving the gadget side effect problem, where (a) is an example diagram for building a topology graph to solve the side effect, and (b) is an example diagram for eliminating the side effect of the stack frame memory read and write loop. DETAILED DESCRIPTION

[0052] In order to make the technical solution of the present invention more obvious and easy to understand, embodiments are given in combination with the accompanying drawings to clearly and completely describe the technical solution in the embodiments of the present invention.

[0053] This example provides an automated ROP generation method that systematically solves the gadget data dependency and side effect problems. For a given binary file and a user-defined vulnerability exploitation initial state and vulnerability exploitation target, the method generates a ROP based on the following formula: Figure 1 The specific processing steps are as follows:

[0054] 1. Preparation: initial state setting, blueprint generation and gadget analysis, and gadget calculation graph construction.

[0055] (1) Based on the initial state of the vulnerability and the description of the vulnerability exploitation process input by the user, a vulnerability exploitation blueprint is generated to guide the construction of the ROP chain.

[0056] like Figure 2 In the blueprint example shown, each node represents a sub-goal that a gadget sub-chain needs to satisfy, and the edges describe the execution order between sub-goals. Each sub-goal can be a call to the (1) register setting, (2) memory reading, and (3) memory writing interfaces supported by TGRop; for (4) function calls and (5) system calls, TGRop first divides them into sub-goals that set parameters before function and system calls, and then uses these function / system call nodes as boundaries to further divide the blueprint into different stages. Figure 2 An exploit blueprint is shown that specifies writing malicious shellcode in memory. Each stage contains several sub-goals that set register values, which must be achieved before invoking a function call or system call.

[0057] (2) TGRop uses Ropper and ROPGadget to search for all gadgets in the program. When the number of gadgets found is small, it adjusts the parameters to search for more gadgets (longer number of instructions) to support the automatic generation of ROP chains.

[0058] Given a gadget, TGRop symbolizes all registers and memory and performs symbolic execution starting from the first instruction. It accurately captures all modifications that a gadget can make to the program state and represents them as symbolic expressions. In addition, TGRop supports identifying conditional branch semantics in gadgets by forking execution when encountering symbolic conditional branches. TGRop classifies all semantics into 15 categories, as shown in Table 1. The classification is based on the type of the destination operand, such as general register (Reg), memory (M[Reg+X]), and PC register, and is further subdivided according to the source operand type, including immediate value (IMM), system call number (Syscall number), parameters of call instructions, branch conditions, and conditional jump targets such as cmp-jne instructions. In Table 1, <>b represents any arithmetic operation, such as add and xor. Figure 3 An example of semantic extraction of a gadget is shown.

[0059] The gadget computation graph (GCG graph) is constructed based on the gadget semantic information obtained by symbolic execution. The gadget computation graph aims to systematically organize all gadgets in the program according to the potential data flow semantic information. TGRop uses GCG as a clue to search for a single gadget or a combination of gadgets that can set registers and memory. These register and memory values ​​can be used as parameters for function calls and system calls, or used to solve data dependency problems and eliminate side effects. Figure 4 As shown, the nodes in GCG represent operands that may appear in the x86 instruction set, including immediate values, general registers, and memory, and the directed edges between nodes represent the data flow direction of the gadget semantics.

[0060] Table 1: Classification of instruction semantics based on source and destination operand types.

[0061]

[0062] 2. Phase search: After completing the preparation work, the ROP chain of each phase can be automatically constructed in sequence according to the guidance of the blueprint. The construction process of each phase includes four steps: sub-target ROP pre-linking, data dependency problem solving (or data dependency solving), side effect elimination and ROP chain generation.

[0063] (1) Sub-goal ROP pre-linking step: TGRop extracts the operands and transfer directions related to the data transfer semantic information required to complete each sub-goal in turn (for example, if RSI is set to 0, search for a reachable path starting from an immediate value or stack frame node and ending at the RSI register, i.e., IMM = 0 → RSI or STACK → RSI), searches the GCG graph using a depth-first traversal method, and outputs a set of reachable paths. There is at least one optional gadget on each edge of each reachable path. TGRop uses the SMT solver to determine which gadgets on the path can be pre-linked, forming a ROP chain scheme for multiple groups of reachable sub-goals.

[0064] TGRop uses the SMT solver to screen the qualified gadgets on each edge during the ROP pre-linking process. First, the initial state (i.e., precondition) and sub-goal (i.e., postcondition) are converted into constraint expressions and added to the solver; then the gadgets on all edges in the path are traversed, and their semantic information is converted into constraint expressions and added to the solver in turn. If the addition of a gadget causes the ROP chain constraint to be unsolvable, the gadget is discarded. At the same time, there are data dependency problems and side effect problems in these ROP chains, which cause the state of the ROP chain formed by the current pre-link after execution to not necessarily meet the utilization state. In this case, TGRop will not discard the gadget, but choose to keep it until the next step to further determine whether the generation of the ROP chain can be improved by solving data dependency and side effect problems.

[0065] like Figure 5 As shown in the figure, the reachable path of the r8=3 sub-goal can be M[rsp+x]->rsi->rax->r8 or M[rsp+x]->rax->r8. In the path M[rsp+x]->rsi->rax->r8, the GCG graph provides three gadgets for the edge of rax->r8, where the z3 constraint expression is as follows: Figure 5As shown. The constraints of the gadgets on each edge are connected with &, and the gadgets on the same edge are connected with |. For the first two gadgets, the SMT solver will identify the unsolvable constraint problem caused by the conflict with the post-condition constraint, and it can be determined that the gadget cannot be used. The constraint of the first gadget is r8_a1_out == jmp_addr, but since this is the address of the next gadget, it conflicts with the sub-goal r8_out == 3; the second gadget, it contains a z3 constraint r8_b1_out == rax_b1_in >> 63, which restricts the r8 register to 0 or 1 (shifting the 64-bit value right by 63 bits, which is equivalent to dividing by 2^63), and there is a conflict with the sub-goal r8_out == 3. For the last gadget, the rax_c1_in register from the controllable stack can be any value. The constraint of r8_c1_out == rax_c1_in + r8_c1_in means that we can control the value of r8_out based on r8_c1_in from the initial state or the previous gadget execution. Therefore, it cannot be discarded in the pre-link at this stage, and can be retained until the second step to solve the data dependency problem.

[0066] (2) Data dependency problem solving steps: TGRop extracts the data dependencies of each gadget by identifying the constraint expressions on each path, and ensures that the ROP chain can reach the utilization state of the sub-goals by iteratively adding new sub-goals.

[0067] There are three main types of gadget data dependencies:

[0068] (a) Valid Address: This subgoal ensures that all memory accesses are valid addresses, such as the value of AddrReg is a legal address, so that reading or writing from M[AddrReg] will not cause the program to crash.

[0069] (b) Correct Jump Target: This subgoal ensures that the next address to be executed is the desired gadget. To solve this problem, the relevant operand must be set to the address of the correct target. In addition, for IF semantics, if the desired next gadget is in the true branch, the condition prediction should satisfy it to true, otherwise it should be false.

[0070] (c) Appropriate register / memory value: This subgoal ensures that the value of the source operand is appropriate so that the value of the target operand is correctly set after the gadget is executed. Figure 5Taking the third gadget on the rax->r8 side in as an example, assuming that the rax register comes from the controllable stack and can be any value (such as 3), the TGRop will create a subtarget that sets r8 to an immediate value of 0 so that rax+r8 can be evaluated as 3.

[0071] After creating a new subgoal, it is critical to determine its appropriate value. In most cases, using the SMT solver to determine the value of each subgoal is the fastest way. However, when the solver's suggested value cannot match an available gadget in the program, TGRop will first consider a value in the LOAD-CONST type path (from immediate to operand) in the GCG. For example, if the solver suggests setting register r8 to an uncommon value like 0xeeeff, we may not easily find a gadget that can satisfy this subgoal directly. Therefore, TGRop will look for a gadget in the program that uses an immediate value to set the r8 register and determine whether the immediate value is a feasible solution.

[0072] (3) Side effect elimination step: Identify the side effects between gadgets and determine the gadget execution order by building a topology graph to eliminate the side effects.

[0073] After the first and second steps, TGRop obtains a set of gadget chains for each sub-goal in this stage. However, since each sub-goal not only completes the setting of the target register / memory value, it also affects the rest of the program state. This causes the subsequent gadgets to read incorrect values ​​and execute incorrectly. This side effect can generally be eliminated by adjusting the gadget execution state.

[0074] TGRop's solution is essentially to sort the topology derived from the blueprint. For example, Figure 6(a) of contains three sub-goals. Sub-goal A is to set r8 to 3, sub-goal B is to set rsi to a valid address (to ensure that Gadget 1 in the first sub-goal does not cause the program to crash), and sub-goal C is to set r8 to 0. Sub-goals B and C are both created in step (2), the step of solving the data dependency problem, to solve the data dependency problem. In each sub-goal, the gadgets are executed in their original order. Between the sub-goals, there are two write-read pairs about the values ​​of rsi and r8, and topological edges are constructed from gadget4 and 5 to gadget 1, that is, gadgets 4 and 5 must be executed before gadget 1. The final execution order involves gadgets 2, 3, and 4 because they either write from rsi or read from rsi. On the one hand, gadget 4 cannot be executed before gadget3, otherwise the write-read pair between gadget 4 and gadget 1 is destroyed. On the other hand, gadget 4 cannot be executed between gadgets 3 and 2 because it will destroy the read-write pair between them. Therefore, Gadget 4 must be executed after Gadget 2. According to the topology constructed in the above order, in the fourth step, TGRop can directly perform topological sorting to assemble Gadgets without worrying about side effects.

[0075] For a topology without loops, TGRop can go directly to step 4. However, for situations that contain loops, additional operations are required. For example, in some cases, you may encounter a stack-based write-read loop formed by two gadgets. To break such a loop, TGRop uses stack adjustments, such as inserting a gadget that executes a pop instruction, which can change the stack pointer (rsp) to point to, thereby effectively breaking the loop. Figure 6 This technique is also applicable to breaking longer loop chains. This approach provides a flexible and effective solution strategy by dynamically adjusting the execution flow and the state of the operation stack.

[0076] (4) ROP chain generation step: Based on the topology graph generated in the third step, TGRop will concatenate the gadgets in sequence through topological sorting to generate the ROP chain of this stage.

[0077] 3. The execution of each ROP chain will transition from the initial state of the stage to a new state. TGRop carries the new program state into the next stage and repeats steps (1), (2) and (3), namely the sub-target ROP pre-linking step, the data dependency problem solving step and the side effect elimination step, to generate the ROP chain of the next stage. Finally, TGRop links the ROP chains of each stage to generate the attack payload of the entire blueprint.

[0078] Experimental data:

[0079] The present invention uses a test set containing 347 programs to generate ROP chains for different exploit targets. By analyzing the generation success rate of these ROP chains, the performance and capability of TGRop can be effectively evaluated.

[0080] (1) Dataset: A collection of Debian 10, CentOS 7, and OpenBSD 6.2 programs (architecture: X64) from the ROP-Benchmark open source automated ROP tool evaluation framework.

[0081] (2) ROP exploitation targets: (a) call execve(" / bin / sh",0,0) to obtain a shell; (b) write an arbitrary string to an arbitrary memory location; (c) control the values ​​of 3-6 parameter registers (the number of parameters in the function call); these three targets represent the capabilities most desired by attackers - code execution and arbitrary write.

[0082] (3) Comparison tools: The six most advanced open source automated ROP tools with the highest number of stars on GitHub: Ropper and ROPgadget based on hard-coding; Angrop (the most popular automated ROP tool on GitHub), Exrop and Ropium based on heuristic approach; SGC based on exploratory approach.

[0083] (4) ROP automated tool verification framework: ROP-Benchmark. This open source framework can inject buffer overflow vulnerabilities into these benchmark programs, and then automatically call the ROP tool to generate a target ROP chain for the vulnerable program (within 1 hour), and finally automatically verify whether the ROP chain can be successfully exploited.

[0084] Table 2

[0085]

[0086] As shown in Table 2, the overall performance of TGRop is evaluated by generating six ROP exploit targets in a set of 347 programs. The table shows the experimental results of TGRop and six comparison tools, where the "X / Y / Z" format means that for program X, the tool successfully generated a chain that meets the exploit target; for program Y, the ROP chain attack verification failed; for program Z, the tool failed due to timeout; and the remaining programs failed to generate within 1 hour. NA means that the tool does not distinguish between success and failure in its output.

[0087] From the analysis of the experimental results, we can see that for exploit target 1, TGRop achieved a success rate of 97.69%, which is significantly better than other ROP automation tools (3.57% to 60.23%). The experiment proves that TGRop is 1.62 to 27 times more effective than the existing technical solutions. From the experimental results of other exploit targets, we can see that TGRop also has superior ROP chain automation generation performance and capabilities.

[0088] The success rate of automated ROP chain generation of heuristic-based ROP tools ranges from 31.41% to 63.40%, which is mainly limited by the completeness of the heuristic rules of each tool. In contrast, TGRop uses semantic extraction and classification and GCG graphs to achieve more efficient gadget usage, and the systematic solution used by TGRop solves data dependency and side effect problems between gadgets. This approach improves the matching and combination efficiency of gadgets, thereby increasing the success rate of ROP chain generation.

[0089] For exploratory methods, SGC has the largest number of timeout programs in its failure cases, which is mainly due to its use of a large number of SMT solver calculations, which reduces its success rate. Even if we extend the limit time for ROP chain generation in the experiment, SGC's success rate is still low due to frequent timeouts. In contrast, TGRop effectively reduces the occurrence of timeouts by reducing its reliance on symbolic execution and solver technology, thereby improving the success rate.

[0090] This invention addresses the fundamental limitations of current approaches, thereby bringing the automation of ROP construction to a new level. We first validate the feasibility of the rationale behind TGRop's design and show through thorough experiments that TGRop outperforms all open source state-of-the-art tools.

[0091] Another embodiment of the present invention provides a ROP generation device for processing data dependency and side effects between gadgets, comprising:

[0092] The preparation module is used to set the initial state of vulnerability exploitation; generate the vulnerability exploitation blueprint based on the initial state of vulnerability exploitation and the description of vulnerability exploitation process; and extract the gadget semantic information in the program and build the gadget calculation graph based on the gadget semantic information;

[0093] The phase search module is used to build the ROP chain of each phase in sequence according to the gadget calculation graph and vulnerability exploitation blueprint, and solve the data dependency and side effect problems between gadgets;

[0094] The ROP chain generation module is used to generate a complete ROP chain based on the ROP chains of each stage.

[0095] The specific implementation process of each module refers to the above description of the method of the present invention.

[0096] Another embodiment of the present invention provides a computer device (computer, server, smart phone, etc.), which includes a memory and a processor, the memory stores a computer program, the computer program is configured to be executed by the processor, and the computer program includes instructions for executing each step in the method of the present invention.

[0097] Another embodiment of the present invention provides a computer-readable storage medium (such as ROM / RAM, magnetic disk, optical disk), wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a computer, the steps of the method of the present invention are implemented.

[0098] The above embodiments are only used to illustrate the technical solutions of the present invention rather than to limit the same. A person skilled in the art may modify or replace the technical solutions of the present invention with equivalents. The protection scope of the present invention shall be subject to the claims.

Claims

1. A ROP generation method for processing data dependencies and side effects between gadgets, characterized in that: The following steps are involved: Set the initial state of the vulnerability exploit; Generate vulnerability exploitation blueprint based on the initial state of vulnerability exploitation and vulnerability exploitation process description; Extract gadget semantic information from the program and build a gadget computation graph based on the gadget semantic information; According to the gadget calculation graph and vulnerability exploitation blueprint, build the ROP chain of each stage in sequence, and solve the data dependency and side effect problems between gadgets; Generate a complete ROP chain based on the ROP chains at each stage.

2. The method according to claim 1, characterized in that The initial state of the vulnerability exploit is the register state and memory state of the vulnerability at the moment of hijacking the control flow.

3. The method according to claim 1, characterized in that The method extracts the gadget semantic information in the program and constructs a gadget computation graph based on the gadget semantic information, including: analyzing all gadgets in the target program, describing the semantics of each gadget using a logical expression through symbolic execution, and classifying the gadgets according to different logical expressions to describe potential data flow operations in gadget execution, wherein the data flow direction is used to construct edges in the gadget computation graph, and different operands are used as nodes in the gadget computation graph, thereby constructing a data flow relationship graph that can describe all gadgets in the program, and the paths in the graph represent the data transmission effect after different gadgets are combined.

4. The method according to claim 3, characterized in that The gadget computation graph systematically organizes all gadgets in the program according to the potential data flow semantic information, and uses the gadget computation graph as a clue to search for a single gadget or a gadget combination that sets registers and memory. The register and memory values ​​are used as parameters for function calls and system calls, or are used to solve data dependency problems and eliminate side effects.

5. The method according to claim 1, characterized in that The vulnerability exploitation blueprint decomposes the complex vulnerability exploitation process into multiple sub-goals and stages; each sub-goal corresponds to five interfaces: register setting, memory reading, memory writing, function call, and system call; each stage is defined by a function call or a system call; the vulnerability exploitation blueprint is used as an execution guide to guide the construction of the ROP chain in each stage, and at the same time, data dependency and side effect problems are solved for the gadgets in each sub-goal.

6. The method according to claim 1, characterized in that The ROP chains of each stage are constructed in sequence, where each stage contains four steps: Sub-goal ROP pre-linking: Use the SMT solver to select or combine gadgets to form a pre-linked ROP chain to individually satisfy the sub-goals in the vulnerability exploitation blueprint; for those gadgets that can semantically satisfy the sub-goals, directly select them as the gadgets to be linked to the sub-goals; if the sub-goals cannot be directly achieved by a single gadget, traverse the reachable paths between different operand nodes in the gadget calculation graph to search for a suitable gadget combination to fill the semantic gap of data transmission between the two operands; after searching for the reachable path, use the SMT solver to assist in screening the candidate gadgets on each edge for pre-linking; Data dependency problem solving: Create new sub-goals in the exploit blueprint and use the SMT solver to filter candidate gadgets to fix data dependency problems, ensuring that the new sub-goals are executed before the original sub-goals, so as to correctly set the target value; Eliminate side effects: Use the method of building a topology graph to obtain the correct execution order between gadgets. Use gadgets as nodes in the topology graph, and use the read and write relationships between gadgets for the same operands as directed edges of the topology graph to identify the required execution order between the two. Finally, perform topological sorting to successfully obtain the correct gadget execution order. ROP chain generation: Link gadgets by topological sorting and generate ROP chains with the help of SMT solver.

7. The method according to claim 1, characterized in that A set of ROP chains are generated for each stage, with shorter ROP chains being preferred.

8. A ROP generation device for processing data dependencies and side effects between gadgets, characterized in that: include: Preparation module, used to set the initial state of vulnerability exploitation; Generate vulnerability exploitation blueprint based on the initial state of vulnerability exploitation and vulnerability exploitation process description; And extract the gadget semantic information in the program, and build the gadget calculation graph based on the gadget semantic information; The phase search module is used to build the ROP chain of each phase in sequence according to the gadget calculation graph and vulnerability exploitation blueprint, and solve the data dependency and side effect problems between gadgets; The ROP chain generation module is used to generate a complete ROP chain based on the ROP chains of each stage.

9. A computer device, characterized in that: The method comprises a memory and a processor, wherein the memory stores a computer program, the computer program is configured to be executed by the processor, and the computer program comprises instructions for executing the method according to any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a computer, the method according to any one of claims 1 to 7 is implemented.