Binary bug repairing method and device

Through the analysis and decompilation processing of binary disassembly information, efficient and accurate vulnerability repair is achieved in the absence of source code, which solves the problems of low automation and decompilation technology limitations in the existing technology, and significantly improves binary vulnerability repair. efficiency and scope of application.

CN118708187AInactive Publication Date: 2024-09-27THE QUARTERMASTER RES INST OF THE GENERAL LOGISTICS DEPT OF THE CPLA
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202410834431.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-06-26
Publication Date
2024-09-27
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

The existing technology has a low degree of automation in binary-level vulnerability repair, relies on expert technology, and cannot efficiently match binary software security requirements. Especially in the absence of source code, the repair effect is poor, and the decompilation technology is scalable and accurate. Insufficient sex.

Method used

By conducting code security analysis on the binary disassembly information, determine the target function to be repaired, decompile, repair and recompile, combine the binary disassembly information for rewriting, and generate a repaired binary program, using the analysis module, decompilation Modules, repair modules and recompilation modules implement vulnerability fixes.

Benefits of technology

It achieves efficient and accurate vulnerability repair in the absence of source code, lowers the operating threshold, significantly improves the efficiency of binary vulnerability repair, has a wide range of applications, and reduces the repair load.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118708187A
    Figure CN118708187A
Patent Text Reader

Abstract

The invention provides a binary vulnerability repairing method and device.The method comprises the steps that code security analysis is conducted on obtained binary disassembling information of target software, fault positioning is achieved based on an analysis result, and a to-be-repaired target function is determined; decompiling the target function to obtain corresponding source code information; speculating a function interface variable type based on the binary disassembly information, and constructing a function interface based on the speculated type; performing code repair processing on the source code data and the function interface of the target function to obtain a repaired code; the repaired codes are recompiled, and candidate binary codes are obtained; and performing binary rewriting processing on the candidate binary codes by taking the binary disassembling information as a reference to obtain a target binary program. According to the binary vulnerability repairing method provided by the invention, vulnerability repairing can be efficiently and accurately carried out on various types of software.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the field of binary program vulnerability repair in computer security, and in particular relates to a binary vulnerability repair method and device. Background Art

[0002] As computers penetrate into every aspect of social life, computer networks built on them and computer systems have brought great convenience to people's production and life, but the accompanying security issues have also become increasingly prominent. At the binary level, the most eye-catching errors are security vulnerabilities, which need to be resolved quickly after they are disclosed to reduce the possibility of being attacked and exploited.

[0003] Vulnerabilities are difficult to locate and fix, especially when source code is not available and binary patching is required. Fixing software bugs is a challenging task when vendor support is not available, source code is not provided, or rebuilding the software from source is not feasible. In these cases, the bugs must be mitigated at the binary level, which is a tedious, complex, and error-prone task that does not easily cope with the large number of potential bugs in today's software.

[0004] A useful approach is for technical experts in the field to reverse analyze the binary program, obtain information about the vulnerable function, and complete the patch, but this measure relies heavily on the technical level and work efficiency of the experts, which is far from matching the current software development trend and binary security requirements. One way to address this challenge is to automate program repair. Although there are many different tools and technical methods that are already in use or are being actively developed, most automated program repair methods are only applicable when program source code is available. An attractive alternative is to convert the entire binary file into source code so that it can be analyzed, modified, and then recompiled to generate a patched binary file. However, current decompilation tools have shortcomings in scalability, or they focus more on user readability rather than the recompilability of binary programs. When applied to the entire binary file, they often produce inaccuracies or cannot be compiled.

[0005] In summary, the above solutions have the following defects and shortcomings:

[0006] (1) Manual methods based on domain experts have poor automation, low work efficiency, and are highly dependent on the technical level of experts. They cannot efficiently match the rapidly growing demand for binary software security repairs.

[0007] (2) Traditional automated program repair technology relies heavily on binary program source code, and has little effect on patching binary software vulnerabilities where the program source code cannot be obtained.

[0008] (3) The automated program repair technology based on complete decompilation is limited by the performance and scalability of current decompilation technology (software). It cannot accurately decompile all functions, and the source code generated by decompilation has poor recompilability. Summary of the invention

[0009] The technical problem to be solved by the present invention is to provide a binary vulnerability repair method, device and equipment for efficiently and accurately repairing vulnerabilities in various types of software.

[0010] The present invention provides a binary vulnerability repair method, comprising:

[0011] Perform code security analysis on the binary disassembly information of the target software, locate the fault based on the analysis results, and determine the target function to be repaired;

[0012] Decompiling the target function to obtain corresponding source code information;

[0013] Inferring the function interface variable type based on the binary disassembly information, and constructing the function interface based on the inferred type;

[0014] Performing code repair processing on the source code data and function interface of the target function to obtain repaired code;

[0015] Recompiling the repaired code to obtain a candidate binary code;

[0016] Using the binary disassembly information as a reference, the candidate binary code is subjected to binary rewriting processing to obtain a target binary program.

[0017] In some embodiments, the performing code security analysis on the obtained binary disassembly information includes:

[0018] In a test environment, performing function-level tracing and spectrum recognition on the binary disassembly information to determine each function included in the original binary program;

[0019] Code security analysis of binary disassembly information is performed based on the functions.

[0020] In some embodiments, the method further comprises:

[0021] Determine whether the binary disassembly information is a statically linked program, and if so, remove the standard library functions in the binary program data;

[0022] When redirecting the identified function, the minimum length of the function is limited to 45 bytes.

[0023] In some embodiments, locating the fault based on the analysis result and determining the target function to be repaired include:

[0024] A different fault location measurement algorithm is used for each identified function to perform spectrum fault location measurement, and a suspiciousness score corresponding to the function is calculated;

[0025] Constructing a matrix based on the functions, the fault location metric algorithm and the corresponding suspiciousness scores, each of the functions having a unique corresponding matrix;

[0026] Calculating the plurality of matrices based on a ranking aggregation algorithm to obtain a ranking list of function suspicions;

[0027] The first k functions in the function suspicion ranking list are determined as the target functions.

[0028] In some embodiments, the objective function is multiple, and the method further includes:

[0029] When decompiling the target function, the minimum reference set required by each entry function involved is determined as the union of the call trees referenced by the entry function.

[0030] In some embodiments, the method further comprises:

[0031] When repairing the target function, an unbound symbol interface is constructed as an entry of a dynamic link function, so that the dynamic link function can be called indiscriminately during the repair process to complete the repair;

[0032] A detour interface is constructed as a repair content entry point of the target function, so as to call symbols required for use in the repair process through the detour interface.

[0033] In some embodiments, recompiling the repaired code to obtain a candidate binary code includes:

[0034] The repaired code is recompiled in combination with position-independent code and static linking to obtain candidate binary code.

[0035] In some embodiments, the method further comprises:

[0036] When the candidate binary code is subjected to binary rewriting processing, reference instructions are generated corresponding to the references of the binary disassembly information involved, and the function calls involved are configured as interface alignment of function redirection, so that the data references and function calls involved meet the specifications.

[0037] Another embodiment of the present invention also provides a binary vulnerability repair device, including:

[0038] An analysis module is used to perform code security analysis on the binary disassembly information of the target software, locate the fault based on the analysis result, and determine the target function to be repaired;

[0039] A decompile module, used to decompile the target function to obtain corresponding source code information;

[0040] An inference module, used for inferring the function interface variable type according to the binary disassembly information, and constructing the function interface based on the inferred type;

[0041] A repair module, used to perform code repair processing on the source code data and function interface of the target function to obtain a repaired code;

[0042] A recompile module, used for recompiling the repaired code to obtain a candidate binary code;

[0043] The rewriting module is used to perform binary rewriting processing on the candidate binary code with reference to the binary disassembly information to obtain a target binary program.

[0044] Another embodiment of the present invention further provides an electronic device, the electronic device comprising a memory and a processor, the memory storing a computer program, and the processor implementing the steps in the binary vulnerability repair method described in any of the above embodiments when executing the computer program.

[0045] The beneficial effect of the present invention is that after locating the fault on the binary disassembly information of the software and determining the target function to be repaired, the function is decompiled to obtain the corresponding source code data, and then the source code data is repaired. After recompiling and binary rewriting, the repaired binary program of the software can be obtained. The overall process is concise, does not require the source code information of the software, has a wide range of applications, reduces the operational threshold for binary software vulnerability repair, and solves the problem of accurately and efficiently repairing binary program vulnerabilities in the absence of manufacturer support and program source code; and the repair process does not require compilation and processing of all binary program data, reduces the repair load to the minimum overhead, and significantly improves the efficiency of binary vulnerability repair work. BRIEF DESCRIPTION OF THE DRAWINGS

[0046] In order to more clearly illustrate the specific implementation methods of the present invention or the technical solutions in the prior art, the drawings required for use in the specific implementation methods or the description of the prior art will be briefly introduced below. Obviously, the drawings in the following description are some implementation methods of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0047] Figure 1The figure is a flowchart of a binary vulnerability repair method in an embodiment of the present invention.

[0048] Figure 2 The figure is a schematic diagram of the application process of the binary vulnerability repair method in the embodiment of the present invention.

[0049] Figure 3 4 is a structural block diagram of a binary vulnerability repair device in an embodiment of the present invention. DETAILED DESCRIPTION

[0050] The specific embodiments of the present invention are described in detail below with reference to the accompanying drawings, but are not intended to limit the present invention.

[0051] It should be understood that various modifications may be made to the embodiments disclosed herein. Therefore, the following description should not be considered as limiting, but merely as an example of an embodiment. Other modifications within the scope and spirit of the present disclosure will occur to those skilled in the art.

[0052] The accompanying drawings, which are incorporated in and constitute a part of the specification, illustrate embodiments of the present disclosure and, together with the general description of the present disclosure given above and the detailed description of the embodiments given below, serve to explain the principles of the present disclosure.

[0053] These and other characteristics of the invention will become apparent from the following description of a preferred form of embodiment given as a non-limiting example, with reference to the accompanying drawings.

[0054] It should also be understood that, although the invention has been described with reference to some specific examples, those skilled in the art will be able to realize many other equivalent forms of the invention that have the characteristics recited in the claims and are therefore within the scope of protection defined thereby.

[0055] The features and advantages of the present disclosure will become more apparent from the following detailed description when taken in conjunction with the accompanying drawings.

[0056] Specific embodiments of the present disclosure are described hereinafter with reference to the accompanying drawings; however, it should be understood that the disclosed embodiments are merely examples of the present disclosure, which may be implemented in a variety of ways. Well-known and / or repeated functions and structures are not described in detail to avoid obscuring the present disclosure with unnecessary or redundant details. Therefore, the specific structural and functional details disclosed herein are not intended to be limiting, but merely serve as a basis and representative basis for the claims to teach those skilled in the art to use the present disclosure in a variety of ways with substantially any suitable detailed structure.

[0057] This specification may use the phrases "in one embodiment," "in another embodiment," "in a further embodiment," or "in other embodiments," all of which may refer to one or more of the same or different embodiments according to the present disclosure.

[0058] The embodiments of the present invention are described in detail below with reference to the accompanying drawings.

[0059] like Figure 1 and Figure 2 As shown, an embodiment of the present invention provides a binary vulnerability repair method, including:

[0060] S1: Perform code security analysis on the binary disassembly information of the target software, locate the fault based on the analysis results, and determine the target function to be patched;

[0061] S2: Decompile the target function to obtain corresponding source code information;

[0062] S3: inferring the function interface variable type based on the binary disassembly information, and constructing the function interface based on the inferred type;

[0063] S4: performing code repair processing on the source code data and function interface of the target function to obtain a repaired code;

[0064] S5: recompile the repaired code to obtain a candidate binary code;

[0065] S6: Using the binary disassembly information as a reference, perform binary rewriting processing on the candidate binary code to obtain a target binary program.

[0066] The binary disassembly information described in this embodiment can be the program data of any software, and the specific details are not fixed. Based on the above content, it can be known that this embodiment locates the fault of the binary disassembly information of the software, determines the target function to be repaired, decompiles it to obtain the corresponding source code data, and then repairs the source code data. After recompiling and binary rewriting, the binary program after the software repair can be obtained. The overall process is simple, does not require the source code information of the software, and has a wide range of applications. It reduces the operational threshold for binary software vulnerability repair and solves the problem of accurately and efficiently repairing binary program vulnerabilities in the absence of manufacturer support and program source code; and the repair process does not require the compilation and processing of all binary program data, reducing the repair load to the minimum overhead, significantly improving the efficiency of binary vulnerability repair work. In actual application, the user can input the software information detected to have vulnerabilities into the system, and the system will perform vulnerability repair, or the user can input unknown software information into the system, and the system will determine whether there are vulnerabilities and automatically perform vulnerability repair, or the system can monitor the software operation, and when there is a problem with the software operation, the system automatically obtains the software information, and performs vulnerability detection and vulnerability repair.

[0067] Furthermore, the method of this embodiment first needs to accurately identify the functions that need to be decompiled and patched in the binary disassembly information, such as functions with vulnerabilities or errors, that is, to determine the target function. For example, a variant of spectrum-based fault location can be applied, that is, a set of suspicious functions can be identified by associating the binary function spectrum with its execution. Since the binary environment provides different assumptions from most fault location methods, this requires that at least the following requirements be met in the process of determining the target function:

[0068] (r1) It does not require the source code of the software or requires the system to have the ability to recompile;

[0069] (r2) Prioritize functions that need to be decompiled;

[0070] (r3) minimize running overhead;

[0071] (r4) Avoid the redirected function from affecting the determination of the target function;

[0072] (r5) Identify the target function with vulnerabilities.

[0073] The above process actually includes two stages: coarse-grained fault location and fine-grained fault location, that is, in this embodiment, two layers of screening and identification in a progressive relationship are involved when determining the objective function.

[0074] Specifically, the code security analysis of the obtained binary disassembly information includes:

[0075] S101: Under a test environment, performing function-level tracing and spectrum recognition on the binary disassembly information to determine each function included in the binary disassembly information;

[0076] S102: Perform code security analysis on binary disassembly information based on each function.

[0077] Exemplarily, the method used in the coarse-grained fault location implemented in this embodiment is to use Valgrind's callgrind to track the program under different unit tests in a test environment (this method meets the above requirements r1-r3). Valgrind can efficiently provide function-level tracing and identify function-level spectrum to help the system determine each function statement in the binary disassembly information and implement code security analysis of the corresponding software. In order to meet the above requirement r4, in another embodiment, the method further includes:

[0078] S8: Determine whether the binary disassembly information is a statically linked program, and if so, remove the standard library functions in the binary disassembly information;

[0079] S9: When performing redirection processing on the identified function, the minimum length of the function is limited to 45 bytes, and the function supports at least six references when redirected.

[0080] The above scheme is to reduce the possibility of overflow, especially redirection overflow. By limiting the function size and the number of references supported by redirection, small functions with large call trees can be eliminated to prevent them from interfering with fault location. It is equivalent to filtering the functions in the software to remove interfering functions.

[0081] Furthermore, after obtaining the above results, a fine fault location operation can be performed. Specifically, the fault location is realized based on the analysis results, and the target function to be repaired is determined, including:

[0082] S103: using a different fault location measurement algorithm to perform spectrum fault location measurement on each identified function, and calculating a suspiciousness score corresponding to the function;

[0083] S104: constructing a matrix based on the function, the fault location measurement algorithm and the corresponding suspiciousness score, each function having a unique corresponding matrix;

[0084] S105: Calculating the plurality of matrices based on a ranking aggregation algorithm to obtain a function suspicion ranking list;

[0085] S106: Determine the first k functions in the function suspicion ranking list as the target functions.

[0086] For example, in this embodiment, a plurality of different fault location measurement algorithms are used to perform spectrum fault location measurement on the functions selected in the above steps, including but not limited to using Tarantula, Ochiai, op2, Barinel, and D2 algorithms to implement spectrum-based fault location measurement, and calculating the suspicion score corresponding to each function. The suspicion score is used to characterize the probability that the function has a vulnerability or error and needs to be repaired. After obtaining multiple suspicion scores corresponding to each function, a matrix can be constructed based on the function, the location algorithm, and the suspicion score, and the top K suspicious functions can be identified using a ranking aggregation algorithm (this step can meet the above-mentioned r5 requirements, and this step will result in the top 35% of the functions involving functions with vulnerabilities in 92% of the time). The specific value of k is uncertain and can be flexibly determined according to actual conditions. Based on the aforementioned method, this embodiment can successfully determine the target function that needs to be repaired. The overall process is simple and fast. Although it has undergone coarse-grained and fine-grained identification as described above, the overall identification process still greatly simplifies the process, improves efficiency, reduces processing load, and abandons more sophisticated and complex identification processes compared to existing solutions. Therefore, compared with existing solutions, this embodiment can also be generally considered to belong to coarse-grained fault location.

[0087] After obtaining the target function, the decompilation module in the system will decompile it. For example, the module can use automated decompilation tools or / and artificial expert knowledge to generate accurate decompilation information. That is, the scheme of this embodiment does not need to decompile all binary functions when repairing binary program data. It only needs to decompile the result obtained by fault location, that is, the target function, which greatly simplifies the repair process. When decompiling the target function, it is also necessary to restore the type of the interface involved in the function. However, due to the lack of function and interface type information in the binary program data, these interface type information are needed when defining the function during the decompilation process. However, due to the lack of high-level semantic information, it is almost impossible for the system to recover accurate function interface type information from binary data. In this regard, the scheme adopted in this embodiment is to use binary disassembly information to infer the type of function variables, and obtain the compatible type of function variables based on this, and construct the function interface on this basis. The construction of the function interface is used to provide a basis for subsequent program code repair.

[0088] After obtaining the decompilation results and function interface, the system will perform code repair accordingly to obtain source code data without vulnerabilities. However, during the repair process, the separation of the original function call to the function interface will have the following problems:

[0089] (i1) The reference (denoted as r) added when the function is redirected will generate a byte cost c=7r+4, causing the corresponding original function to overflow.

[0090] (i2) When calling a decompiled function and returning, the stack status may be inconsistent;

[0091] The problem shown in (i1) usually occurs when there are multiple objective functions. Therefore, in this embodiment, if there are multiple objective functions, the solutions to this problem include:

[0092] S10: When decompiling the target function, the minimum reference set required by each entry function involved is determined as the union of the call trees referenced by the entry function.

[0093] Furthermore, in one embodiment, the method further comprises:

[0094] S11: when repairing the target function, constructing an unbound symbol interface as an entry of a dynamic link function, so that the dynamic link function can be called indiscriminately during the repair process to complete the repair;

[0095] S12: Constructing a detour interface as a repair content entry point of the target function, so as to call symbols required for use in the repair process through the detour interface.

[0096] The constructed unbound symbol interface and detour interface can jointly ensure that the generated repair content matches the original content, and the required symbols can also be added to the original function model of the target function through the detour interface to save the EBX register and reference data. Since the reference data can be considered as symbols in nature, by creating an unbound symbol interface, the decompiled data and its procedure link table conditions can be interfaced during the repair process, realizing the separation of binary function calls and detour interfaces, and assisting in completing code repair.

[0097] When solving the problem shown in (i2), the system can solve the problem by implementing a constructed detour interface, specifically by inserting an inline assembly for stack correction before the detour interface returns.

[0098] In another embodiment, recompiling the repaired code to obtain a candidate binary code includes:

[0099] S501: Recompile the repaired code in combination with position-independent code and static linking to obtain candidate binary code.

[0100] Specifically, the system has a partial recompile decompile module, which is used to perform recompile and binary rewrite process. The recompile and link of all links involved in the recompile process, function positioning are also completed by this module. When recompiling, the original binary execution flow and the source code obtained by decompilation can realize dynamic linking based on the pre-configured jump execution strategy, so for the new decompiled content added, the initialization of the standard interpreter (such as constructor, symbol resolution and relocation) will be bypassed. In order to adapt to this, the content recompiled in the present embodiment does not need an extra interpreter to execute binary functions, and can directly quote the global, local and external symbols in the original binary content.

[0101] Since partial recompilation must recompile high-level source code to ensure that the patched binary program data can be executed correctly, and no additional interpreter is required. In this embodiment, since new binary content is added, it is necessary to meet the requirement that even if the memory address of the new content is not known in advance, the content must be able to run normally. Accordingly, in this embodiment, position-independent, statically linked content is created based on the partial recompilation decompilation module, which belongs to the property of supporting static linking and PIC in a single shared object and does not have consistent behavior on all compilers. This embodiment generates the target file corresponding to the recompilation process by using the above-mentioned features and a custom linker script, and places all sections in a separate segment, and the data in the segment is compatible with GCC. In actual application, the dietlibc tool can be used, that is, a libc that takes up less space is used to support automatic program repair analysis.

[0102] Furthermore, when the above modules in this embodiment perform binary data rewriting processing, the method further includes:

[0103] S13: When performing binary rewriting processing on the candidate binary code, reference instructions are generated corresponding to the references of the binary disassembly information involved, and the function calls involved are configured as interface alignment of function redirection, so that the data references and function calls involved meet the specifications.

[0104] The binary data rewriting process in this embodiment is equivalent to combining the binary disassembly information and part of the recompilable disassembly source code into a single binary file that can be correctly executed, including prototype analysis, extraction, addition and operation of binary content, so that the recompiled single binary file can be correctly executed without an additional interpreter, and can reference the global, local and external symbols in the original binary content. In addition, in order to avoid the incompatibility of the constructed detour interface with the original function call in the binary disassembly information, this embodiment will analyze the binary content before inserting the jump instruction, and generate instructions for each required reference to change the valid function call to align with the redirection interface, so that the generated binary file conforms to the calling convention.

[0105] The new binary program data finally output in this embodiment, that is, the new binary file, can be, but is not limited to, composed of the original binary file (binary disassembly information), a "binary-source code" interface (including a detour interface and an unbound symbol interface) and a decompiled function. Because the source code of the original binary program is not available, the partially recompilable disassembly module will not compile the original source code, but will recompile the source code generated in the process, that is, the source code generated after decompilation, which contains the decompiled functions and "binary-source code interface". These "binary-source code interfaces" allow the decompiled code to execute the original binary content, and when used with a customized interceptor, allow the original binary program to execute the decompiled code. After the decompiled code is recompiled, it is the recompiled content generated by the partially recompilable disassembly module (equivalent to Figure 2 A' in the figure is the binary disassembly information). The above process can actually be understood as adjusting the recompiled data with reference to the original binary program data, such as adjusting the interface naming and relationship involved, the instruction form involved in the function call, etc., so that the two parts of the content are properly updated and merged to ensure that the generated target binary program can be executed safely and correctly. The obtained target binary program can be tested. When the test verifies that the recompiled content (A') is equivalent to the original binary file (A) in the test, it can be determined that the vulnerability of the corresponding software has been successfully patched.

[0106] like Figure 3 As shown, another embodiment of the present invention also provides a binary vulnerability repair device 100, including:

[0107] An analysis module is used to perform code security analysis on the binary disassembly information of the target software, locate the fault based on the analysis result, and determine the target function to be repaired;

[0108] A decompile module, used to decompile the target function to obtain corresponding source code information;

[0109] An inference module, used for inferring the function interface variable type according to the binary disassembly information, and constructing the function interface based on the inferred type;

[0110] A repair module, used to perform code repair processing on the source code data and function interface of the target function to obtain a repaired code;

[0111] A recompile module, used for recompiling the repaired code to obtain a candidate binary code;

[0112] The rewriting module is used to perform binary rewriting processing on the candidate binary code with reference to the binary disassembly information to obtain a target binary program.

[0113] In some embodiments, the performing code security analysis on the obtained binary disassembly information includes:

[0114] In a test environment, performing function-level tracing and spectrum recognition on the binary disassembly information to determine each function included in the binary disassembly information;

[0115] Code security analysis of binary disassembly information is performed based on the functions.

[0116] In some embodiments, the apparatus further comprises:

[0117] The judging module is used to judge whether the binary disassembly information is a statically linked program. If so, the standard library functions in the binary disassembly information are removed; and / or when the function is redirected, the minimum length of the function is limited to 45 bytes.

[0118] In some embodiments, locating the fault based on the analysis result and determining the target function to be repaired include:

[0119] A different fault location measurement algorithm is used for each identified function to perform spectrum fault location measurement, and a suspiciousness score corresponding to the function is calculated;

[0120] Constructing a matrix based on the functions, the fault location metric algorithm and the corresponding suspiciousness scores, each of the functions having a unique corresponding matrix;

[0121] Calculating the plurality of matrices based on a ranking aggregation algorithm to obtain a ranking list of function suspicions;

[0122] The first k functions in the function suspicion ranking list are determined as the target functions.

[0123] In some embodiments, there are multiple target functions, and the decompile module is further used to:

[0124] When decompiling the target function, the minimum reference set required by each entry function involved is determined as the union of the call trees referenced by the entry function.

[0125] In some embodiments, the repair module is further configured to:

[0126] When repairing the target function, an unbound symbol interface is constructed as an entry of a dynamic link function, so that the dynamic link function can be called indiscriminately during the repair process to complete the repair;

[0127] A detour interface is constructed as a repair content entry point of the target function, so as to call symbols required for use in the repair process through the detour interface.

[0128] In some embodiments, recompiling the repaired code to obtain a candidate binary code includes:

[0129] The repaired code is recompiled in combination with position-independent code and static linking to obtain candidate binary code.

[0130] In some embodiments, the rewrite module is further configured to:

[0131] When the candidate binary code is subjected to binary rewriting processing, reference instructions are generated corresponding to the references of the binary disassembly information involved, and the function calls involved are configured as interface alignment of function redirection, so that the data references and function calls involved meet the specifications.

[0132] Another embodiment of the present invention further provides an electronic device, comprising a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the steps in the binary vulnerability repair method described in any of the above embodiments are implemented.

[0133] Another embodiment of the present invention further provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps in the binary vulnerability repair method described in any of the above embodiments are implemented.

[0134] It should be noted that the computer storage medium of the present application may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access storage medium (RAM), a read-only storage medium (ROM), an erasable programmable read-only storage medium (EPROM or flash memory), an optical fiber, a portable compact disk read-only storage medium (CD-ROM), an optical storage medium, a magnetic storage medium, or any suitable combination of the above. In the present application, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, device or device. In the present application, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, in which a computer-readable program code is carried. This propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. A computer-readable signal medium may also be any computer-readable medium other than a computer-readable storage medium, which may send, propagate or transmit a program configured to be used by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer-readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, antenna, optical cable, RF, etc., or any suitable combination of the above.

[0135] A person skilled in the art should understand that the discussion of any of the above embodiments is merely illustrative and is not intended to imply that the scope of protection of the present application is limited to these examples. In line with the concept of the present application, the technical features in the above embodiments or different embodiments may be combined, the steps may be implemented in any order, and there are many other variations of different aspects of one or more embodiments of the present application as described above, which are not provided in detail for the sake of simplicity.

[0136] One or more embodiments of the present application are intended to cover all such substitutions, modifications and variations that fall within the broad scope of the present application. Therefore, any omissions, modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of one or more embodiments of the present application should be included in the protection scope of the present application.

Claims

1. A binary vulnerability repair method, It is characterized in that include: Perform code security analysis on the binary disassembly information of the target software, locate the fault based on the analysis results, and determine the target function to be repaired; Decompiling the target function to obtain corresponding source code information; Inferring the function interface variable type based on the binary disassembly information, and constructing the function interface based on the inferred type; Performing code repair processing on the source code data and function interface of the target function to obtain repaired code; Recompiling the repaired code to obtain a candidate binary code; Using the binary disassembly information as a reference, the candidate binary code is subjected to binary rewriting processing to obtain a target binary program.

2. The binary vulnerability repair method according to claim 1, It is characterized in that The code security analysis of the obtained binary disassembly information of the target software includes: In a test environment, performing function-level tracing and spectrum recognition on the binary disassembly information to determine each function included in the binary disassembly information; Code security analysis of binary disassembly information is performed based on the functions.

3. The binary vulnerability repair method according to claim 2, It is characterized in that The method further comprises: Determine whether the binary disassembly information is a statically linked program. If so, remove the standard library functions in the binary disassembly information. When redirecting the identified function, limit the minimum length of the function to 45 bytes.

4. The binary vulnerability repair method according to claim 2, It is characterized in that The method of locating the fault based on the analysis result and determining the target function to be repaired includes: A different fault location measurement algorithm is used for each identified function to perform spectrum fault location measurement, and a suspiciousness score corresponding to the function is calculated; Constructing a matrix based on the functions, the fault location metric algorithm and the corresponding suspiciousness scores, each of the functions having a unique corresponding matrix; Calculating the plurality of matrices based on a ranking aggregation algorithm to obtain a ranking list of function suspicions; The first k functions in the function suspicion ranking list are determined as the target functions.

5. The binary vulnerability repair method according to claim 1, It is characterized in that There are multiple objective functions, and the method further includes: When decompiling the target function, the minimum reference set required by each entry function involved is determined as the union of the call trees referenced by the entry function.

6. The binary vulnerability repair method according to claim 1, It is characterized in that The method further comprises: When repairing the target function, an unbound symbol interface is constructed as an entry of a dynamic link function, so that the dynamic link function can be called indiscriminately during the repair process to complete the repair; A detour interface is constructed as a repair content entry point of the target function, so as to call symbols required for use in the repair process through the detour interface.

7. The binary vulnerability repair method according to claim 6, It is characterized in that The step of recompiling the repaired code to obtain a candidate binary code includes: The repaired code is recompiled in combination with position-independent code and static linking to obtain candidate binary code.

8. The binary vulnerability repair method according to claim 6, It is characterized in that The method further comprises: When the candidate binary code is subjected to binary rewriting processing, reference instructions are generated corresponding to the references of the binary disassembly information involved, and the function calls involved are configured as interface alignment of function redirection, so that the data references and function calls involved meet the specifications.

9. A binary vulnerability repair device, It is characterized in that include: An analysis module is used to perform code security analysis on the binary disassembly information of the target software, locate the fault based on the analysis result, and determine the target function to be repaired; A decompilation module, used to decompile the target function to obtain corresponding source code information; An inference module, used for inferring the function interface variable type according to the binary disassembly information, and constructing the function interface based on the inferred type; A repair module is used to perform code repair processing on the source code data and function interface of the target function to obtain a repaired code; A recompile module, used for recompiling the repaired code to obtain a candidate binary code; The rewriting module is used to perform binary rewriting processing on the candidate binary code with reference to the binary disassembly information to obtain a target binary program.

10. An electronic device, It is characterized in that The electronic device includes a memory and a processor, the memory stores a computer program, and when the processor executes the computer program, the steps in the binary vulnerability repair method described in any one of claims 1 to 8 are implemented.

Citation Information

Patent Citations

  • Binary code-oriented reproduction vulnerability detection method and system

    CN115129591A

  • Binary code change vulnerability prioritization

    US20120011493A1