Efficient vulnerability repair priority judgment method and device

By identifying the usage of function pointers in the heap block and constructing a complete dereference chain, it solves the problem of difficulty in guessing the cause during the software vulnerability repair process, improves the efficiency and accuracy of vulnerability repair, and provides efficient vulnerability repair priority determination. method.

CN118536115APending Publication Date: 2024-08-23INST OF SOFTWARE - CHINESE ACAD OF SCI
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202310187275.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-02-22
Publication Date
2024-08-23

AI Technical Summary

Technical Problem

During the repair process of software vulnerabilities, technicians need to speculate on the cause of the vulnerability and it takes a lot of time, which makes it difficult to determine the repair sequence, especially when there are many vulnerabilities, and the efficiency is low.

Method used

By identifying the usage of function pointers in heap blocks, obtaining structure types and member variables, building a complete dereference chain of function pointers, calculating repair priorities, and combining static analysis and instrumentation technology to improve the efficiency and accuracy of vulnerability repairs .

Benefits of technology

It improves the efficiency and accuracy of vulnerability repair, avoids waste of resources, solves the problem of low efficiency of function pointer usage point identification in existing methods, and provides a more efficient vulnerability repair priority determination method.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118536115A
    Figure CN118536115A
Patent Text Reader

Abstract

The invention discloses an efficient vulnerability repair priority judgment method and device, and the method comprises the steps: selecting a structural body containing a function pointer from an overflow heap block for a program with heap vulnerabilities, and obtaining the type and member variables of the structural body; identifying a use point of the function pointer; iteratively backtracking an instruction forwards from a use point, and obtaining a complete de-reference chain of a function pointer in combination with the type and member variables of a structural body; and based on the complete de-reference chain of each function pointer, judging the bug repair priority. According to the method, the bug repair priority can be judged according to the use condition of the function pointer.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of network security, and in particular relates to an efficient vulnerability repair priority determination method and device. Background Art

[0002] Software vulnerabilities are the main threat to cyberspace security. Software vulnerabilities exist in the operating system kernel or in applications, which can cause attackers to damage the system or application without authorization. The emergence of many automated vulnerability mining methods has accelerated the discovery of vulnerabilities. Therefore, software developers will face many software vulnerabilities that need to be repaired urgently. When software developers repair vulnerabilities, they need to speculate on the causes of the vulnerabilities, which requires a lot of repair experience and a lot of time. Therefore, when there are many software vulnerabilities, technicians need to determine the order in which these vulnerabilities should be repaired. Summary of the invention

[0003] In view of the above problems, the present invention discloses an efficient vulnerability repair priority determination method and device, which aims to determine the vulnerability repair priority by the use of sensitive data in a heap block, especially the use of function pointers.

[0004] The technical content of the present invention includes:

[0005] An efficient vulnerability repair priority determination method, the method comprising:

[0006] For a program with a heap vulnerability, a structure containing a function pointer is selected in an overflow heap block, and the type and member variables of the structure are obtained;

[0007] Identify the point of use of function pointers;

[0008] Based on the use point, determining whether the function pointer is obtained through a structure variable dereference instruction of the structure;

[0009] In the case where the function pointer is obtained through a structure variable dereference instruction of the structure, iteratively backtracking instructions forward from the use point, and combining the type and member variables of the structure to obtain a complete dereference chain of the function pointer;

[0010] Based on the complete dereference chain of each function pointer, the priority of vulnerability repair is determined.

[0011] Furthermore, for the program with the heap vulnerability, a structure containing a function pointer is selected in the overflow heap block, and the type and member variables of the structure are obtained, including:

[0012] By inserting a heap allocation function, a binary address where the heap block allocation function of the program is called is obtained;

[0013] Obtaining a source code line number according to the binary address, and obtaining a type of the heap block based on the variable type assigned to the heap block allocation in the corresponding line;

[0014] According to the overflow range of the heap overflow vulnerability obtained during the vulnerability discovery process, the address of the overflow heap block is obtained;

[0015] Based on the address of the overflowed heap block, a structure member variable of the overflowed heap block is obtained, and by analyzing the structure variable information, a structure including a function pointer is obtained;

[0016] The binary address is matched with the address of the overflowed heap block, and the type of the structure of the overflowed heap block is obtained in combination with the type of the heap block.

[0017] Further, the identifying the use point of the function pointer includes:

[0018] Compile the program into an intermediate language in the form of LLVM;

[0019] At the intermediate language level, determining whether each instruction in the program is a calling function;

[0020] If the instruction is not a function call, discard the instruction;

[0021] If the instruction is a function call, a user-defined function, a function in a standard library, or is not a variable representation, the instruction is discarded;

[0022] When the instruction is a function call, the instruction is not a user-defined function or a function in a standard library, and is represented by a variable, the function is used as the usage point of the function pointer.

[0023] Further, judging whether the function pointer is obtained through a structure variable dereference instruction of the structure based on the use point includes:

[0024] Tracing back instructions from the use point forward, and finding instructions where the function pointer is assigned;

[0025] If the meaning of the instruction to which the function pointer is assigned is not that a structure variable obtains the function pointer through pointer operation, the function pointer is discarded;

[0026] In the case where the instruction to assign the function pointer means that a structure variable obtains the function pointer through pointer operation, it is determined that the function pointer is obtained through a structure variable dereference instruction of the structure.

[0027] Furthermore, the iterative backtracking of instructions from the use point and combining the type and member variables of the structure to obtain a complete dereference chain of the function pointer includes:

[0028] Obtaining a pointer operation offset result and structure variable type information of a pointer operation traced back from the use point to the structure variable dereference instruction;

[0029] Backtracking forward from the instruction for dereferencing the structure variable to find the instruction for assigning a value to the structure variable;

[0030] If the instruction to which the structure variable is assigned is a structure member variable obtained by pointer operation of the structure variable, then obtaining the dereferenced member type and member offset, and taking the instruction to which the structure variable is assigned as the structure variable dereference instruction, returning to the backtracking from the structure variable dereference instruction to find the instruction to which the structure variable is assigned;

[0031] If the instruction to which the structure variable is assigned is not a structure member variable obtained by pointer operation of the structure variable, and the structure at this level is a function parameter and the actual parameter at the function call point is obtained by dereferencing the upper structure, then backtracking forward based on the actual parameter to obtain a complete dereference chain of the function pointer;

[0032] If the instruction to which the structure variable is assigned is not a structure member variable obtained by pointer operation of the structure variable, and this layer of structure is not a function parameter or the actual parameter at the function call point is not obtained by dereferencing the upper layer structure, then this layer of structure is determined to be the uppermost structure, and when the type and member variable of the uppermost structure match those of the structure in combination with the member type and member offset of each dereference, the complete dereference chain of the function pointer is obtained based on the member type and member offset of each dereference in the forward backtracking.

[0033] Furthermore, the backtracking forward based on the actual parameter to obtain a complete dereference chain of the function pointer includes:

[0034] For each function call point, find the actual parameters in the function call point corresponding to the formal parameters represented by the structure variable according to the order of function parameter passing;

[0035] If the actual parameter is a function parameter and the actual parameter at the function call point is obtained by dereferencing the upper structure, the member type and member offset of the dereference are obtained, and after entering the upper structure, return to each call point of the function, and find the actual parameter in the function call point corresponding to the formal parameter represented by the structure variable according to the order of function parameter passing;

[0036] If the actual parameter is not a function parameter or the actual parameter at the function call point is not obtained by dereferencing the upper structure, then this layer of structure is determined to be the top-level structure, and when the type and member variables of the top-level structure match those of the structure, the complete dereference chain of the function pointer is obtained based on the variable information of each layer in the forward backtracking.

[0037] Furthermore, in the case where it is determined that the type and member variables of the top-level structure match those of the structure in combination with the member type and member offset of each dereference, a complete dereference chain of the function pointer is obtained based on the member type and member offset of each dereference in forward backtracking, including:

[0038] Get the type of the top-level structure;

[0039] Matching the type of the uppermost structure with the type of the structure;

[0040] In the case where the type matching is successful, the member type and member offset of each dereference are matched with the member variables of the structure;

[0041] When the member variable is matched successfully, the complete dereference chain of the function pointer is obtained based on the member type and member offset of each dereference in the forward backtracking.

[0042] Furthermore, the priority of vulnerability repair is determined based on the complete dereference chain of each function pointer, including:

[0043] According to the complete dereference chain of each function pointer, calculate the number and location of all call points of the corresponding function pointer;

[0044] Get the number of function pointers x in each structure 1 The average number of dereference levels x of the function pointer in the structure 2 ;

[0045] Calculate the repair priority score y = x for each structure 1 +αx 2 ; Where α represents the weight coefficient.

[0046] An efficient vulnerability repair priority determination device, the device comprising:

[0047] A function pointer acquisition module is used to select a structure containing a function pointer in an overflowed heap block for a program with a heap vulnerability, and obtain the type and member variables of the structure;

[0048] Use point identification module, used to identify the use point of function pointer;

[0049] a dereference chain calculation module, for determining, based on the use point, whether the function pointer is obtained through a structure variable dereference instruction of the structure; if the function pointer is obtained through a structure variable dereference instruction of the structure, iteratively backtracking instructions forward from the use point, and obtaining a complete dereference chain of the function pointer in combination with the type and member variables of the structure;

[0050] The priority determination module is used to determine the priority of vulnerability repair based on the complete dereference chain of each function pointer.

[0051] An electronic device comprises a memory and a processor, wherein the memory stores a computer program, and wherein the processor implements any one of the above methods when executing the computer program.

[0052] Compared with the prior art, the advantages and positive effects of the present invention are as follows:

[0053] 1) The present invention compiles the open source software with the help of the existing static analysis method, distinguishes the functions called by the function, and identifies the use of function pointers.

[0054] 2) Compared with the traditional method of dynamically tracking the usage of function pointers in heap blocks after overflow, the present invention adds a static pre-judgment of whether the structure contains function pointers, which makes the analysis more efficient and targeted, and can also avoid the waste of resources for dynamic analysis when there are no function pointers in the structure.

[0055] 3) The present invention not only relates to the tracing process of dereferencing a structure function pointer within a function, but can also handle the tracing of dereferencing a structure variable between functions in combination with a function call.

[0056] 4) The present invention solves the problem of low efficiency in identifying function pointer usage points in existing analysis and detection methods, and can help vulnerability analysts improve their understanding of vulnerabilities and provide assistance for priority determination of vulnerability repairs. The present invention adopts a new static analysis method and adds preprocessing of structure member variable information, which can greatly improve the analysis speed and accuracy. BRIEF DESCRIPTION OF THE DRAWINGS

[0057] Figure 1 The figure is a general architecture diagram of the efficient vulnerability repair priority determination method of the present invention.

[0058] Figure 2 Analyze the flow chart for the structure where the function pointer is located. DETAILED DESCRIPTION

[0059] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings. Obviously, the described embodiments are only specific embodiments of the present invention, not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0060] This embodiment provides an efficient vulnerability repair priority determination method, such as Figure 1 As shown, the following steps are included:

[0061] Step 1: For the program with heap vulnerability, select the structure containing the function pointer in the overflow heap block and obtain the type and member variables of the structure.

[0062] When the binary program is running, the malloc and other heap allocation functions are instrumented to obtain the binary address where the application's heap allocation function is called. Use the addr2line tool to obtain the source code line number based on the binary address obtained, that is, the source code line number where the heap allocation function is located. Then find the corresponding source code line number, and the variable type assigned to the heap allocation is the structure type of the heap block, so as to obtain the structure type information of the heap block. Then obtain the overflow range of the heap overflow vulnerability obtained during the vulnerability discovery process, and obtain the address of the heap block after the overflow within the overflow range of the heap overflow vulnerability, and match it with the heap block allocation address obtained by instrumentation, so as to obtain the allocation address information of the heap block within the overflow range and the structure member variables of the heap block. Analyze the member variables of the structure to find out whether there are function pointers in it, and whether there are variables of function pointer type in the nested structure.

[0063] Step 2: Identify the point of use of the function pointer.

[0064] This embodiment uses LLVM (Low Level Virtual Machine) as a compiler. The program is compiled into an intermediate language using LLVM (Low Level Virtual Machine). At the intermediate language level, each instruction in the program is analyzed. If the instruction is a function call instruction, the called function is analyzed. All custom functions in the program are collected. If the called function is neither a user-defined function nor a function in the standard library, and is represented by a variable, then the function call is a call point of a function pointer.

[0065] Step 3: Iteratively trace back instructions from the point of use, and combine the type and member variables of the structure to obtain the complete dereference chain of the function pointer.

[0066] This embodiment continues to use the intermediate language in step 2 to identify the structure. Before iteratively tracing back instructions from the point of use, it is necessary to determine whether the function pointer is obtained through the structure variable dereference instruction of the structure. Specifically, after identifying the call point of the function pointer, this embodiment uses an iterative method to trace back instructions. The function pointer is a variable of the LLVM intermediate language instruction, so the variable is assigned before. If the assignment point is a pointer operation instruction, that is, the GEP instruction in the LLVM intermediate language instruction, then the dereferenced structure variable is the first operand of the instruction, and the other operands are the offsets of the pointer, and the offset information of the pointer and the type information of the structure variable are recorded.

[0067] Since there are nested structures that are dereferenced multiple times to obtain function pointer variables, we need to continue to trace back to analyze the assignment points of the structure variables. If the assignment point is a pointer operation instruction, then record the offset information of the instruction and the type information of the structure, and then repeat the process of backtracking the assignment points of the structure variables until the structure variables can no longer be assigned using the GEP instruction. Then, by searching the assignment points of the structure variables, we can get the top-level structure where the function pointer is located. At the same time, during the search process, we also record the offset information of each dereference of the top-level structure and the type information of the member variable structure obtained by each dereference.

[0068] In this embodiment, the case where the structure variable is obtained by passing parameters through a function is also considered. If the top-level structure obtained in the function is the formal parameter of the function, the calling position of the function is found in the entire application. For each calling position, the actual parameter corresponding to the parameter order is obtained from the parameter order of the formal parameter. The actual parameter is a structure variable, and then the top-level structure variable is obtained according to the iterative search method of the structure variable assignment point in the function.

[0069] Through the above steps, the top-level structure variable where the function pointer is located and the member type and member offset of each dereference can be obtained. The structure type of the top-level structure variable is matched with the structure type obtained in step 1. If the types match, the dereferenced member type and member offset are compared with the structure member variable obtained in step 1, thereby completing the variable information of each layer in the dereference process from the top-level structure to the function pointer, forming a complete dereference chain.

[0070] like Figure 2 As shown, the iterative forward tracing instructions of this step include:

[0071] Step 3.1, trace back the instructions from the function pointer call point to find the instruction where the function pointer is assigned;

[0072] Step 3.2, if the instruction means that a structure variable is used to obtain a function pointer through pointer operation, then the function pointer is obtained by dereferencing the structure variable, and the offset result of the pointer operation and the type information of the structure variable are recorded; if it is an instruction with other meanings, the function pointer call point is ignored.

[0073] Step 3.3, since there is a situation where the target variable is obtained by multiple dereferences of the nested structure, then continue to backtrack from the structure dereference instruction, that is, find the instruction where the structure variable is assigned; if the instruction is a structure variable that obtains its structure member variable through pointer operation, then record the offset result of the pointer operation and the type information of the structure variable, and repeat this step until the structure variable is no longer obtained by dereferencing a structure variable, and then execute the next step;

[0074] Step 3.4, considering the cross-function situation, when the top-level structure is the function parameter, the actual parameter of the structure variable at the function call point may be obtained by dereferencing the upper-level structure, then find the call point of the function in the application. For each call point of the function, according to the order of function parameter passing, find the actual parameter in the function call point corresponding to the formal parameter represented by the structure variable. Continue to trace back the actual parameter of the function call point to find the top-level structure;

[0075] Step 3.5, match the type information of the top structure obtained with the type information of the heap block structure within the overflow range obtained in step 1), and if the matching results are consistent, construct a dereference of each layer. According to the offset result of the pointer operation and the type information of the structure variable recorded in the backtracking process, each dereference from the top structure to the function pointer corresponds to a structure member, and the offset result represents the member number of the current member variable in the structure. The variable name and type information of the member variable are obtained, and the correctness of the result is further verified by adding the type information of the structure member recorded in the backtracking process. Therefore, the correspondence of the specific member variables of each layer of the structure can be completed, so as to complete the dereference from the top structure to the target function pointer.

[0076] Step 4. Determine the priority of vulnerability repair based on the complete dereference chain of each function pointer.

[0077] After traversing the program to obtain the number and location of all call points of the function pointer in the overflow heap block structure, the technician can sort the vulnerabilities according to the number of function pointer call points and the location of the call points to determine the priority of vulnerability repair. If the structure contains different function pointer member variables and all function pointers are used, a high priority will be given. If there are few function pointers in the structure and the number of call point locations is also small, a low priority will be given.

[0078] In summary, the present invention aims at the defects of the existing identification methods and provides an efficient determination method for vulnerability repair priority. It does not need to adopt the traditional dynamic analysis method, improves the analysis efficiency and quality, and can include multiple structure function pointer call points for technicians to determine the priority of repair.

[0079] 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 make equivalent substitutions for the technical solutions of the present invention without departing from the spirit and scope of the present invention. The protection scope of the present invention shall be subject to the claims.

Claims

1. An efficient vulnerability repair priority determination method, characterized in that: The method comprises: For a program with a heap vulnerability, a structure containing a function pointer is selected in an overflow heap block, and the type and member variables of the structure are obtained; Identify the point of use of function pointers; Based on the use point, determining whether the function pointer is obtained through a structure variable dereference instruction of the structure; In the case where the function pointer is obtained through a structure variable dereference instruction of the structure, iteratively backtracking instructions forward from the use point, and combining the type and member variables of the structure to obtain a complete dereference chain of the function pointer; Determine the priority of vulnerability repair based on the complete dereference chain of each function pointer.

2. The method according to claim 1, characterized in that For a program with a heap vulnerability, a structure containing a function pointer is selected in an overflow heap block, and the type and member variables of the structure are obtained, including: By inserting a heap allocation function, a binary address where the heap block allocation function of the program is called is obtained; Obtaining a source code line number according to the binary address, and obtaining a type of the heap block based on the variable type assigned to the heap block allocation in the corresponding line; According to the overflow range of the heap overflow vulnerability obtained during the vulnerability discovery process, the address of the overflow heap block is obtained; Based on the address of the overflowed heap block, a structure member variable of the overflowed heap block is obtained, and by analyzing the structure variable information, a structure including a function pointer is obtained; The binary address is matched with the address of the overflowed heap block, and the type of the structure of the overflowed heap block is obtained in combination with the type of the heap block.

3. The method according to claim 1, characterized in that The identification of the use point of the function pointer includes: Compile the program into an intermediate language in the form of LLVM; At the intermediate language level, determining whether each instruction in the program is a calling function; If the instruction is not a function call, discard the instruction; If the instruction is a function call, a user-defined function, a function in a standard library, or is not a variable representation, the instruction is discarded; When the instruction is a function call, the instruction is not a user-defined function or a function in a standard library, and is represented by a variable, the function is used as the usage point of the function pointer.

4. The method according to claim 1, characterized in that The determining, based on the use point, whether the function pointer is obtained through a structure variable dereference instruction of the structure includes: Tracing back instructions from the use point forward, and finding instructions where the function pointer is assigned; If the meaning of the instruction to which the function pointer is assigned is not that a structure variable obtains the function pointer through pointer operation, the function pointer is discarded; In the case where the instruction to assign the function pointer means that a structure variable obtains the function pointer through pointer operation, it is determined that the function pointer is obtained through a structure variable dereference instruction of the structure.

5. The method according to claim 1, characterized in that The iterative backtracking of instructions from the use point and combining the type and member variables of the structure to obtain a complete dereference chain of the function pointer includes: Obtaining a pointer operation offset result and structure variable type information of a pointer operation traced back from the use point to the structure variable dereference instruction; Backtracking forward from the instruction for dereferencing the structure variable to find the instruction for assigning a value to the structure variable; If the instruction to which the structure variable is assigned is a structure member variable obtained by pointer operation of the structure variable, then obtaining the dereferenced member type and member offset, and taking the instruction to which the structure variable is assigned as the structure variable dereference instruction, returning to the backtracking from the structure variable dereference instruction to find the instruction to which the structure variable is assigned; If the instruction to which the structure variable is assigned is not a structure member variable obtained by pointer operation of the structure variable, and the structure at this level is a function parameter and the actual parameter at the function call point is obtained by dereferencing the upper structure, then backtracking forward based on the actual parameter to obtain a complete dereference chain of the function pointer; If the instruction to which the structure variable is assigned is not a structure member variable obtained by pointer operation of the structure variable, and this layer of structure is not a function parameter or the actual parameter at the function call point is not obtained by dereferencing the upper layer structure, then this layer of structure is determined to be the uppermost structure, and when the type and member variable of the uppermost structure match those of the structure in combination with the member type and member offset of each dereference, the complete dereference chain of the function pointer is obtained based on the member type and member offset of each dereference in the forward backtracking.

6. The method according to claim 5, characterized in that The backtracking forward based on the actual parameter to obtain the complete dereference chain of the function pointer includes: For each function call point, find the actual parameters in the function call point corresponding to the formal parameters represented by the structure variable according to the order of function parameter passing; If the actual parameter is a function parameter and the actual parameter at the function call point is obtained by dereferencing the upper structure, the member type and member offset of the dereference are obtained, and after entering the upper structure, return to each call point of the function, and find the actual parameter in the function call point corresponding to the formal parameter represented by the structure variable according to the order of function parameter passing; If the actual parameter is not a function parameter or the actual parameter at the function call point is not obtained by dereferencing the upper structure, then this layer of structure is determined to be the top-level structure, and when the type and member variables of the top-level structure match those of the structure, the complete dereference chain of the function pointer is obtained based on the variable information of each layer in the forward backtracking.

7. The method according to claim 5 or 6, characterized in that In the case where it is determined that the type and member variable of the top-level structure match the type and member variable of the structure in combination with the member type and member offset of each dereference, a complete dereference chain of the function pointer is obtained based on the member type and member offset of each dereference in forward backtracking, including: Get the type of the top-level structure; Matching the type of the uppermost structure with the type of the structure; In the case where the type matching is successful, the member type and member offset of each dereference are matched with the member variables of the structure; When the member variable is matched successfully, the complete dereference chain of the function pointer is obtained based on the member type and member offset of each dereference in the forward backtracking.

8. The method according to claim 1, characterized in that The priority of vulnerability repair is determined based on the complete dereference chain of each function pointer, including: According to the complete dereference chain of each function pointer, calculate the number and location of all call points of the corresponding function pointer; Obtain the number x1 of the function pointers in each structure and the average number x2 of dereference levels of the function pointer in the structure; Calculate the repair priority score y=x1+αx2 for each structure; where α represents the weight coefficient.

9. An efficient vulnerability repair priority determination device, characterized in that: The device comprises: A function pointer acquisition module is used to select a structure containing a function pointer in an overflowed heap block for a program with a heap vulnerability, and obtain the type and member variables of the structure; Use point identification module, used to identify the use point of function pointer; a dereference chain calculation module, for determining, based on the use point, whether the function pointer is obtained through a structure variable dereference instruction of the structure; if the function pointer is obtained through a structure variable dereference instruction of the structure, iteratively backtracking instructions forward from the use point, and obtaining a complete dereference chain of the function pointer in combination with the type and member variables of the structure; The priority determination module is used to determine the priority of vulnerability repair based on the complete dereference chain of each function pointer.

10. An electronic device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the method according to any one of claims 1 to 8 is implemented.