A formatted string branch tampering backdoor detection method and system

By calculating global variable-constant comparison of branch information and dynamically using formatted string vulnerabilities, we generate input instances that can penetrate branches, solving the problem of detecting formatted string branches tampering with backdoors in the prior art, and realizing the backdoor of the software system effective detection.

CN118760608BActive Publication Date: 2024-11-15NAT UNIV OF DEFENSE TECH
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411221258.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-09-02
Publication Date
2024-11-15
Estimated Expiration
2044-09-02

AI Technical Summary

Technical Problem

The prior art is difficult to effectively detect the backdoor of formatted string branches tampering because of the lack of arbitrary address writing ability that affects the content of global variables of the branch that compares the constants.

Method used

By calculating the global variable-constant comparison branch-related information in the target program, the context of formatted string vulnerabilities is accumulated during the dynamic analysis process, and these vulnerabilities are used to penetrate the branches, generating input instances that can trigger the backdoor, realizing dynamic detection of the backdoor .

Benefits of technology

It realizes effective detection of the backdoor of formatted string branches tampering, can penetrate deep path state space, and provides technical support for detecting the backdoor of the software system in security analysis.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118760608B_ABST
    Figure CN118760608B_ABST
Patent Text Reader

Abstract

The present invention discloses a formatted string branch tampering backdoor detection method and system, belonging to the technical field of backdoor detection. The method first calculates all global variable-constant comparison branch related information in the target program; then, in the dynamic analysis process, accumulates the calculation context of the formatted string vulnerabilities that occur; then, when encountering these branches, the previously accumulated formatted string vulnerabilities are utilized in the form of tampering branches; thereby penetrating the branch, and in the process of exploring the deep path state space, realizing dynamic detection of the software backdoor protected by the branch. The present invention is used to detect the formatted string branch tampering backdoor existing in the software system.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of backdoor detection, and in particular relates to a method and system for detecting formatted string branch tampering backdoors. Background Art

[0002] A software backdoor is a method of bypassing software security controls and gaining control of the system through a relatively secret channel. A formatted string branch tampering backdoor is a software backdoor that software developers reserve in the software system during the software development phase. By exploiting the formatted string vulnerability reserved by the developer in the software system, the attacker maliciously tampers with the content of global data variables that can affect certain program branches, allowing program branches that would otherwise be impossible to execute to be successfully executed, thereby triggering the backdoor protected by the program branch and gaining control of the system.

[0003] The following is an example of a formatted string branch tampering backdoor:

[0004]

[0005] It can be seen that there is a system backdoor in line 7 of the program, which allows the attacker to execute arbitrary commands on the target system. The backdoor is protected by the if constant comparison branch in line 6. However, the branch predicate i==0x8888 cannot be satisfied under normal circumstances because the global variable i is assigned only once in the entire program (i.e., the initialization operation), which assigns the value of the variable i to 0. However, due to a format string vulnerability in line 5, the attacker can use the vulnerability to overwrite the content of the global variable i and tamper with it to 0x8888, thereby ensuring that the branch condition in line 6 is met, thereby successfully triggering the backdoor in line 7.

[0006] Software backdoor detection is a research hotspot in the field of information security. Fuzz testing and symbolic execution are the two main technical means at present. Both of them essentially try to generate a large number of test cases and use these test cases as input to drive the execution of the target program. During the execution process, the program monitoring technology is used to check whether function calls in the form of system (" / bin / sh") can be triggered. If it is determined that it can be triggered, it can be determined that there is a backdoor in the target system. The difference between the two lies in the test case generation strategy: fuzz testing technology generates test cases in a random mutation manner, while symbolic execution technology replaces the input of the program from specific values ​​to symbolic variables, focusing on the symbolic variable-related constraints corresponding to each path in the target program, dividing the program's path state space into several equivalence classes, and using this to perform regular test case generation and path state space coverage.

[0007] Although fuzz testing and symbolic execution techniques are widely used in software backdoor detection, they are difficult to effectively detect formatted string branch tampering backdoors. The reason is that the triggering of the backdoor requires the arbitrary address write capability of the formatted string vulnerability to perform targeted tampering on the content of global variables that can affect constant comparison branches. Existing technologies generally lack this capability, and therefore cannot effectively detect potential formatted string branch tampering backdoors in the target program. Summary of the invention

[0008] In view of the above problems, the present invention proposes a formatted string branch tampering backdoor detection scheme. The scheme first calculates all global variable-constant comparison branch related information in the target program, and then accumulates the calculation context of the formatted string vulnerabilities that occur during the dynamic analysis process. Then, when encountering these branches, the previously accumulated formatted string vulnerabilities are attempted to be exploited in the form of tampering branches, thereby penetrating the branch, and realizing dynamic detection of the software backdoor protected by the branch during the exploration of the deep path state space.

[0009] The first aspect of the present invention discloses a formatted string branch tampering backdoor detection method. Given a target binary program and a seed test case, the method comprises:

[0010] During the static analysis phase:

[0011] Calling a global variable-constant comparison branch static identification module to analyze the target binary program to calculate all global variable-constant comparison branches contained in the target binary program, and extracting branch virtual addresses corresponding to the global variable-constant comparison branches and operands involved in the branch operation as metadata information;

[0012] During the dynamic monitoring phase:

[0013] Call the format string vulnerability context dynamic collection module, use the seed test case to drive the execution of the target binary program, and dynamically track the generated program execution trajectory, sequentially record the trigger context corresponding to all triggered format string vulnerabilities, and dynamically track the program execution status after the format string vulnerability occurs;

[0014] The format string vulnerability delay exploitation module is called. When it is determined that the global variable-constant comparison branch is reached, the trigger context corresponding to the format string vulnerability and the metadata information of the global variable-constant comparison branch are combined to generate an input instance of the format string vulnerability to tamper with the non-constant memory operand content of the global variable-constant comparison branch;

[0015] The backdoor execution monitoring module is called to analyze the execution process of the input instance. When the backdoor is found to be triggered, the input instance is output as a target input instance that can trigger the backdoor.

[0016] According to the method of the first aspect of the present invention, the global variable-constant comparison branch static identification module is called to specifically perform:

[0017] Use binary program static control flow analysis technology to calculate all functions contained in the target binary program, and use the in-process arrival fixed value analysis technology to calculate the arrival fixed values ​​corresponding to each memory unit and register for each function;

[0018] Check whether the last instruction in each basic block of the function is a comparison instruction of the JE or JNE form;

[0019] If yes, further determine whether one of the two operands of the most recent CMP instruction before the last instruction in the basic block is a constant operand and the other is a non-constant operand; if yes, the last instruction in the basic block is a constant comparison branch, and record the triple {last instruction, constant operand, non-constant operand} as metadata information of the constant comparison branch;

[0020] For the metadata information of the constant comparison branch, obtain the arrival fixed value corresponding to the position of the non-constant operand in the last instruction, and check whether the arrival fixed value originates from the memory unit of the determined address;

[0021] If yes, the last instruction in the basic block is a global variable-constant comparison branch, and the ternary {last instruction, constant operand, memory unit of the determined address} is used as the metadata information of the global variable-constant comparison branch; otherwise, continue to track the source of the constant value corresponding to the position of the non-constant operand in the last instruction;

[0022] The metadata information corresponding to all global variable-constant comparison branches is stored.

[0023] According to the method of the first aspect of the present invention, the formatted string vulnerability context dynamic collection module is called to specifically perform:

[0024] Relying on the specific symbolic execution platform, the format string processing function is dynamically hooked using the API function hooking technology;

[0025] When the target format string processing function is dynamically called, the hook function of the format string vulnerability context dynamic collection module is triggered, and the hook function obtains the content of the format string to be processed and checks whether it is related to the external input;

[0026] If so, it is determined that the format string processing function causes a format string vulnerability, and the symbol value content corresponding to the format string is extracted and accumulated into the trigger context corresponding to the format string vulnerability that has occurred and is maintained globally.

[0027] According to the method of the first aspect of the present invention, calling the formatted string vulnerability delay exploitation module specifically includes:

[0028] Given the program execution status of the global variable-constant comparison branch and the trigger context corresponding to the currently accumulated format string vulnerability, traverse the strings that cause the format string vulnerability recorded in the trigger context corresponding to the accumulated format string vulnerability to obtain branch information:

[0029] <branch_addr, branch_const, branch_operand>

[0030] Among them, branch_addr represents the branch virtual address, branch_const represents the constant operand involved in the branch operation, and branch_operand represents the non-constant operand involved in the branch operation;

[0031] Construct a format string that writes the contents of branch_const to the memory address of branch_operand:

[0032] Symstr == WRITE (branch_operand, branch_const)

[0033] Among them, Symstr represents the constructed format string, and WRITE represents the write operation;

[0034] Using the formatted string as a symbolic constraint, if the symbolic constraint is satisfied under the path constraint conditions contained in the current program execution state, the constraint solving technology is used to calculate the conjunction condition of the symbolic constraint and the path constraint contained in the current path execution state to determine the input instance that can penetrate the global variable-constant comparison branch.

[0035] The second aspect of the present invention discloses a formatted string branch tampering backdoor detection system, the system comprising: a global variable-constant comparison branch static identification module, a formatted string vulnerability context dynamic collection module, a formatted string vulnerability delay utilization module, and a backdoor execution monitoring module; wherein, given a target binary program and a seed test case:

[0036] During the static analysis phase:

[0037] Calling a global variable-constant comparison branch static identification module to analyze the target binary program to calculate all global variable-constant comparison branches contained in the target binary program, and extracting branch virtual addresses corresponding to the global variable-constant comparison branches and operands involved in the branch operation as metadata information;

[0038] During the dynamic monitoring phase:

[0039] Call the format string vulnerability context dynamic collection module, use the seed test case to drive the execution of the target binary program, and dynamically track the generated program execution trajectory, sequentially record the trigger context corresponding to all triggered format string vulnerabilities, and dynamically track the program execution status after the format string vulnerability occurs;

[0040] The format string vulnerability delay exploitation module is called. When it is determined that the global variable-constant comparison branch is reached, the trigger context corresponding to the format string vulnerability and the metadata information of the global variable-constant comparison branch are combined to generate an input instance of the format string vulnerability to tamper with the non-constant memory operand content of the global variable-constant comparison branch;

[0041] The backdoor execution monitoring module is called to analyze the execution process of the input instance. When the backdoor is found to be triggered, the input instance is output as a target input instance that can trigger the backdoor.

[0042] According to the system of the second aspect of the present invention, the global variable-constant comparison branch static identification module is called to specifically perform:

[0043] Use binary program static control flow analysis technology to calculate all functions contained in the target binary program, and use the in-process arrival fixed value analysis technology to calculate the arrival fixed values ​​corresponding to each memory unit and register for each function;

[0044] Check whether the last instruction in each basic block of the function is a comparison instruction of the JE or JNE form;

[0045] If yes, further determine whether one of the two operands of the most recent CMP instruction before the last instruction in the basic block is a constant operand and the other is a non-constant operand; if yes, the last instruction in the basic block is a constant comparison branch, and record the triple {last instruction, constant operand, non-constant operand} as metadata information of the constant comparison branch;

[0046] For the metadata information of the constant comparison branch, obtain the arrival fixed value corresponding to the position of the non-constant operand in the last instruction, and check whether the arrival fixed value originates from the memory unit of the determined address;

[0047] If yes, the last instruction in the basic block is a global variable-constant comparison branch, and the ternary {last instruction, constant operand, memory unit of the determined address} is used as the metadata information of the global variable-constant comparison branch; otherwise, continue to track the source of the constant value corresponding to the position of the non-constant operand in the last instruction;

[0048] The metadata information corresponding to all global variable-constant comparison branches is stored.

[0049] According to the system of the second aspect of the present invention, the formatted string vulnerability context dynamic collection module is called to specifically perform:

[0050] Relying on the specific symbolic execution platform, the format string processing function is dynamically hooked using the API function hooking technology;

[0051] When the target format string processing function is dynamically called, the hook function of the format string vulnerability context dynamic collection module is triggered, and the hook function obtains the content of the format string to be processed and checks whether it is related to the external input;

[0052] If so, it is determined that the format string processing function causes a format string vulnerability, and the symbol value content corresponding to the format string is extracted and accumulated into the trigger context corresponding to the format string vulnerability that has occurred and is maintained globally.

[0053] According to the system of the second aspect of the present invention, calling the format string vulnerability delay exploitation module specifically includes:

[0054] Given the program execution status of the global variable-constant comparison branch and the trigger context corresponding to the currently accumulated format string vulnerability, traverse the strings that cause the format string vulnerability recorded in the trigger context corresponding to the accumulated format string vulnerability to obtain branch information:

[0055] <branch_addr, branch_const, branch_operand>

[0056] Among them, branch_addr represents the branch virtual address, branch_const represents the constant operand involved in the branch operation, and branch_operand represents the non-constant operand involved in the branch operation;

[0057] Construct a format string that writes the contents of branch_const to the memory address of branch_operand:

[0058] Symstr == WRITE (branch_operand, branch_const)

[0059] Among them, Symstr represents the constructed format string, and WRITE represents the write operation;

[0060] Using the formatted string as a symbolic constraint, if the symbolic constraint is satisfied under the path constraint conditions contained in the current program execution state, the constraint solving technology is used to calculate the conjunction condition of the symbolic constraint and the path constraint contained in the current path execution state to determine the input instance that can penetrate the global variable-constant comparison branch.

[0061] The third aspect of the present invention discloses an electronic device, which includes a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the formatted string branch tampering backdoor detection method described in the first aspect of the present disclosure is implemented.

[0062] The fourth aspect of the present invention discloses a computer-readable storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the formatted string branch tampering backdoor detection method described in the first aspect of the present disclosure is implemented.

[0063] In summary, the present invention calculates all global variable-constant comparison branch information contained in a given binary program, and in the dynamic analysis process, creatively generates input instances that can penetrate the global variable-constant comparison branch by delaying the use of the formatted string vulnerability existing in the system, and effectively detects the system backdoor while efficiently covering the deep state space. The present invention can provide effective technical support for security analysts to detect the formatted string branch tampering backdoor in the software system. BRIEF DESCRIPTION OF THE DRAWINGS

[0064] 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.

[0065] Figure 1 It is a flowchart of a method for detecting a formatted string branch tampering backdoor according to an embodiment of the present invention;

[0066] Figure 2 Schematic diagram of a system for detecting formatted string branch tampering backdoor according to an embodiment of the present invention. DETAILED DESCRIPTION

[0067] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present invention.

[0068] Definitions of Abbreviations and Key Terms:

[0069] Constant comparison branch: refers to branch jump instructions in the form of JZ and JNZ. The branch predicate of this branch jump instruction is to determine whether two operands are equal, and one of the operands involved in the operation is a constant.

[0070] Global variable-constant comparison branch: It is a type of constant comparison branch. The special thing is that the two operands that affect the branch predicate of the branch jump instruction are a constant and a global variable (non-constant).

[0071] The first aspect of the present invention discloses a formatted string branch tampering backdoor detection method. Given a target binary program and a seed test case, the method comprises:

[0072] During the static analysis phase:

[0073] Calling a global variable-constant comparison branch static identification module to analyze the target binary program to calculate all global variable-constant comparison branches contained in the target binary program, and extracting branch virtual addresses corresponding to the global variable-constant comparison branches and operands involved in the branch operation as metadata information;

[0074] During the dynamic monitoring phase:

[0075] Call the format string vulnerability context dynamic collection module, use the seed test case to drive the execution of the target binary program, and dynamically track the generated program execution trajectory, sequentially record the trigger context corresponding to all triggered format string vulnerabilities, and dynamically track the program execution status after the format string vulnerability occurs;

[0076] The format string vulnerability delay exploitation module is called. When it is determined that the global variable-constant comparison branch is reached, the trigger context corresponding to the format string vulnerability and the metadata information of the global variable-constant comparison branch are combined to generate an input instance of the format string vulnerability to tamper with the non-constant memory operand content of the global variable-constant comparison branch;

[0077] The backdoor execution monitoring module is called to analyze the execution process of the input instance. When the backdoor is found to be triggered, the input instance is output as a target input instance that can trigger the backdoor.

[0078] Specifically, this method includes four key technical modules: static identification of global variable-constant comparison branches, dynamic collection of formatted string vulnerability context, delayed exploitation of formatted string vulnerability, and backdoor execution monitoring. The first three technical modules are the key technical elements proposed in this application, and the backdoor execution monitoring module is implemented based on the current more mature dynamic binary translation technology.

[0079] The workflow of this method includes two stages: static analysis and dynamic monitoring.

[0080] like Figure 1 As shown in the figure, given a binary program and a seed test case, the method first enters the first stage of static analysis, in which the global variable-constant comparison branch static identification module is used to analyze the target binary program, calculate all global variable-constant comparison branches contained in the binary program, and extract metadata information such as branch virtual addresses corresponding to these branches and operands involved in branch operations. Then, the metadata information, the target binary program, and the seed input instance are used as input to guide the analysis into the second stage of dynamic monitoring.

[0081] In the dynamic monitoring phase, the formatted string vulnerability context dynamic collection module is first used to dynamically track the program execution trajectory generated by the binary program execution driven by the seed test case, and the trigger context corresponding to all formatted string vulnerabilities triggered in the process is recorded in sequence. The program execution status after the formatted string vulnerability occurs is dynamically tracked. When it is determined that a certain global variable-constant comparison branch has been reached, the formatted string vulnerability delay exploitation module is applied in combination with the accumulated formatted string vulnerability trigger context and the metadata information corresponding to the branch, and an input instance that can tamper with the non-constant memory operand content corresponding to the branch with a formatted string vulnerability that occurred previously is automatically generated. The input instance can successfully penetrate the global variable-constant comparison branch. The backdoor execution monitoring module is then used in the dynamic monitoring phase to analyze the execution process of the input instance. When the backdoor is found to be triggered, the input instance is output as an input instance that can trigger the backdoor.

[0082] According to the method of the first aspect of the present invention, the global variable-constant comparison branch static identification module is called to specifically perform:

[0083] Use binary program static control flow analysis technology to calculate all functions contained in the target binary program, and use the in-process arrival fixed value analysis technology to calculate the arrival fixed values ​​corresponding to each memory unit and register for each function;

[0084] Check whether the last instruction in each basic block of the function is a comparison instruction of the JE or JNE form;

[0085] If yes, further determine whether one of the two operands of the most recent CMP instruction before the last instruction in the basic block is a constant operand and the other is a non-constant operand; if yes, the last instruction in the basic block is a constant comparison branch, and record the triple {last instruction, constant operand, non-constant operand} as metadata information of the constant comparison branch;

[0086] For the metadata information of the constant comparison branch, obtain the arrival fixed value corresponding to the position of the non-constant operand in the last instruction, and check whether the arrival fixed value originates from the memory unit of the determined address;

[0087] If yes, the last instruction in the basic block is a global variable-constant comparison branch, and the ternary {last instruction, constant operand, memory unit of the determined address} is used as the metadata information of the global variable-constant comparison branch; otherwise, continue to track the source of the constant value corresponding to the position of the non-constant operand in the last instruction;

[0088] The metadata information corresponding to all global variable-constant comparison branches is stored.

[0089] Specifically, the global variable-constant comparison branch static identification technology first applies the current more mature binary program static control flow analysis technology to calculate all the functions contained in the binary program. Then, for each function func, the current more mature in-process arrival fixed value analysis technology is applied to calculate the arrival fixed values ​​corresponding to each memory unit and register at each program position inside it, and then the following analysis process is carried out.

[0090] Check whether the last instruction insn in each basic block bb of the function func is a comparison instruction of the form of JE or JNE. If it is confirmed, further check whether the two operands of the most recent CMP instruction before insn in the basic block are a constant operand c and a non-constant operand d. If it is confirmed, insn is a constant comparison branch, and the triple {insn, c, d} is recorded as the metadata information corresponding to the constant comparison branch;

[0091] For the metadata information {insn, c, d} corresponding to each identified constant comparison branch, obtain the arrival constant rd corresponding to the operand d at the insn position, and check whether rd originates from the memory unit vaddr of the determined address. If it is determined, insn can be determined to be a global variable-constant comparison branch, and {insn, c, vaddr} is recorded as the metadata information of the global variable-constant comparison branch; otherwise, the source constant of rd will continue to be tracked in the above manner.

[0092] After completing the above analysis, this module will dump the metadata information corresponding to all the collected global variable-constant comparison branches to the disk file, providing global variable-constant comparison branch related information support for the delayed exploitation of the formatted string vulnerability in the subsequent dynamic analysis stage.

[0093] According to the method of the first aspect of the present invention, the formatted string vulnerability context dynamic collection module is called to specifically perform:

[0094] Relying on the specific symbolic execution platform, the format string processing function is dynamically hooked using the API function hooking technology;

[0095] When the target format string processing function is dynamically called, the hook function of the format string vulnerability context dynamic collection module is triggered, and the hook function obtains the content of the format string to be processed and checks whether it is related to the external input;

[0096] If so, it is determined that the format string processing function causes a format string vulnerability, and the symbol value content corresponding to the format string is extracted and accumulated into the trigger context corresponding to the format string vulnerability that has occurred and is maintained globally.

[0097] Specifically, the dynamic collection technology of formatted string vulnerability context dynamically hooks formatted string processing functions such as printf based on the specific-symbolic execution platform and the current more mature API function hooking technology. When the target formatted string processing function is dynamically called, the hook function specially customized by this module is triggered. The hook function first obtains the content of the formatted string to be processed and checks whether it is related to the external input. When it is confirmed to be related to the external input, it is determined that the current formatted string processing function call can cause a formatted string vulnerability, and then the symbol value content corresponding to the formatted string is extracted and accumulated into the globally maintained formatted string vulnerability context that has occurred. After completing the collection of this part of information, the program execution state is continuously deduced forward based on the specific-symbolic execution platform. When it is found that the program execution state reaches a certain global variable-constant comparison branch (this is determined by combining the calculation results of the global variable-constant comparison branch static identification module), the program execution state at this time and the accumulated formatted string vulnerability context are used as input to schedule the formatted string vulnerability delay exploitation technology for further analysis.

[0098] According to the method of the first aspect of the present invention, calling the formatted string vulnerability delay exploitation module specifically includes:

[0099] Given the program execution status of the global variable-constant comparison branch and the trigger context corresponding to the currently accumulated format string vulnerability, traverse the strings that cause the format string vulnerability recorded in the trigger context corresponding to the accumulated format string vulnerability to obtain branch information:

[0100] <branch_addr, branch_const, branch_operand>

[0101] Among them, branch_addr represents the branch virtual address, branch_const represents the constant operand involved in the branch operation, and branch_operand represents the non-constant operand involved in the branch operation;

[0102] Construct a format string that writes the contents of branch_const to the memory address of branch_operand:

[0103] Symstr == WRITE (branch_operand, branch_const)

[0104] Among them, Symstr represents the constructed format string, and WRITE represents the write operation;

[0105] Using the formatted string as a symbolic constraint, if the symbolic constraint is satisfied under the path constraint conditions contained in the current program execution state, the constraint solving technology is used to calculate the conjunction condition of the symbolic constraint and the path constraint contained in the current path execution state to determine the input instance that can penetrate the global variable-constant comparison branch.

[0106] Specifically, given the program execution state that can reach a certain global variable-constant comparison branch and the current accumulated format string vulnerability trigger context, the format string vulnerability delay exploitation technology traverses each string Symstr recorded in the accumulated format string vulnerability trigger context that can cause the format string vulnerability to occur, and obtains the information corresponding to the branch branch<branch_addr, branch_const, branch_operand> , try to construct a formatted string Symstr == WRITE (branch_operand, branch_const) that can write the content of branch_const to the memory address of branch_operand as a symbolic constraint. If the symbolic constraint is satisfiable under the path constraint conditions implied by the current program execution state, that is, the constraint solving technology is applied to calculate the conjunction conditions of the symbolic constraint and the path constraint implied by the current execution state, the input obtained is the input instance that can penetrate the global variable-constant comparison branch.

[0107] Prototype system example

[0108] Based on the technical solutions discussed above, a prototype system is designed and implemented based on the binary program analysis platform angr and the binary program full system dynamic symbolic execution platform s2e. Figure 2 As shown, the prototype system includes two working phases: the first phase is the static analysis phase, and the second phase is the dynamic monitoring phase.

[0109] In the static analysis phase, we first use angr's built-in control flow analysis technology (including disassembly, function identification, and intra-procedural control flow analysis) to statically analyze the target program and extract the various function entities contained in the binary program. Then, we apply the global variable-constant comparison branch static identification module to each function entity, thereby extracting the global variable-constant comparison branch metadata information contained in each module. The global variable-constant comparison branch static identification module is actually implemented as a function-level analysis process of angr.

[0110] The dynamic analysis phase is designed and implemented based on the s2e binary program full system symbolic execution platform. The two key technologies of dynamic collection of formatted string vulnerability context and delayed exploitation of formatted string vulnerability and the backdoor execution monitoring module described in this application are all implemented in the form of s2e system analysis plug-in. These three functional modules work in series as described in this application, and while successfully penetrating the global variable-constant comparison branch, they can effectively detect the system backdoor.

[0111] Experimental Examples

[0112] In order to verify the system's ability to automatically detect the formatted string branch tampering backdoor, the target program is compiled into an ELF executable program bin under the 32-bit i386 architecture on a 64-bit operating system. The built analysis system is started to analyze the program. In the static analysis stage, the output lua result file content is as follows:

[0113]

[0114] It can be seen that the static analysis phase can successfully identify the global variable-constant comparison branch in the program. Then, the dynamic analysis phase is started with the bin program, the global variable-constant comparison branch metadata information output by the static analysis phase, and the seed input instance as input. An input instance that can trigger the software backdoor is successfully generated.

[0115] The second aspect of the present invention discloses a formatted string branch tampering backdoor detection system, the system comprising: a global variable-constant comparison branch static identification module, a formatted string vulnerability context dynamic collection module, a formatted string vulnerability delay utilization module, and a backdoor execution monitoring module; wherein, given a target binary program and a seed test case:

[0116] During the static analysis phase:

[0117] Calling a global variable-constant comparison branch static identification module to analyze the target binary program to calculate all global variable-constant comparison branches contained in the target binary program, and extracting branch virtual addresses corresponding to the global variable-constant comparison branches and operands involved in the branch operation as metadata information;

[0118] During the dynamic monitoring phase:

[0119] Call the format string vulnerability context dynamic collection module, use the seed test case to drive the execution of the target binary program, and dynamically track the generated program execution trajectory, sequentially record the trigger context corresponding to all triggered format string vulnerabilities, and dynamically track the program execution status after the format string vulnerability occurs;

[0120] The format string vulnerability delay exploitation module is called. When it is determined that the global variable-constant comparison branch is reached, the trigger context corresponding to the format string vulnerability and the metadata information of the global variable-constant comparison branch are combined to generate an input instance of the format string vulnerability to tamper with the non-constant memory operand content of the global variable-constant comparison branch;

[0121] The backdoor execution monitoring module is called to analyze the execution process of the input instance. When the backdoor is found to be triggered, the input instance is output as a target input instance that can trigger the backdoor.

[0122] According to the system of the second aspect of the present invention, all functions contained in the target binary program are calculated using the binary program static control flow analysis technology, and for each function, the arrival fixed value analysis technology within the process is used to calculate the arrival fixed value corresponding to each memory unit and register;

[0123] Check whether the last instruction in each basic block of the function is a comparison instruction of the JE or JNE form;

[0124] If yes, further determine whether one of the two operands of the most recent CMP instruction before the last instruction in the basic block is a constant operand and the other is a non-constant operand; if yes, the last instruction in the basic block is a constant comparison branch, and record the triple {last instruction, constant operand, non-constant operand} as metadata information of the constant comparison branch;

[0125] For the metadata information of the constant comparison branch, obtain the arrival fixed value corresponding to the position of the non-constant operand in the last instruction, and check whether the arrival fixed value originates from the memory unit of the determined address;

[0126] If yes, the last instruction in the basic block is a global variable-constant comparison branch, and the ternary {last instruction, constant operand, memory unit of the determined address} is used as the metadata information of the global variable-constant comparison branch; otherwise, continue to track the source of the constant value corresponding to the position of the non-constant operand in the last instruction;

[0127] The metadata information corresponding to all global variable-constant comparison branches is stored.

[0128] According to the system of the second aspect of the present invention, the formatted string vulnerability context dynamic collection module is called to specifically perform:

[0129] Relying on the specific symbolic execution platform, the format string processing function is dynamically hooked using the API function hooking technology;

[0130] When the target format string processing function is dynamically called, the hook function of the format string vulnerability context dynamic collection module is triggered, and the hook function obtains the content of the format string to be processed and checks whether it is related to the external input;

[0131] If so, it is determined that the format string processing function causes a format string vulnerability, and the symbol value content corresponding to the format string is extracted and accumulated into the trigger context corresponding to the format string vulnerability that has occurred and is maintained globally.

[0132] According to the system of the second aspect of the present invention, given the program execution state of the global variable-constant comparison branch and the trigger context corresponding to the currently accumulated format string vulnerability, each symbol string causing the format string vulnerability to occur is traversed in the trigger context corresponding to the accumulated format string vulnerability to obtain metadata information of the global variable-constant comparison branch:

[0133] <branch_addr, branch_const, branch_operand>

[0134] Among them, branch_addr represents the branch virtual address, branch_const represents the constant operand involved in the branch operation, and branch_operand represents the non-constant operand involved in the branch operation;

[0135] Construct a format string that writes the contents of branch_const to the memory address of branch_operand:

[0136] Symstr == WRITE (branch_operand, branch_const)

[0137] Among them, Symstr represents the constructed format string, and WRITE represents the write operation;

[0138] Using the formatted string as a symbolic constraint, if the symbolic constraint is satisfied under the path constraint conditions contained in the current program execution state, the constraint solving technology is used to calculate the conjunction condition of the symbolic constraint and the path constraint contained in the current path execution state to determine the input instance that can penetrate the global variable-constant comparison branch.

[0139] The third aspect of the present invention discloses an electronic device, which includes a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the formatted string branch tampering backdoor detection method described in the first aspect of the present disclosure is implemented.

[0140] The fourth aspect of the present invention discloses a computer-readable storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the formatted string branch tampering backdoor detection method described in the first aspect of the present disclosure is implemented.

[0141] In summary, the present invention calculates all global variable-constant comparison branch information contained in a given binary program, and in the dynamic analysis process, by delaying the use of the formatted string vulnerability existing in the system, creatively generates input instances that can penetrate the global variable-constant comparison branch, and effectively detects the system backdoor while efficiently covering the deep state space. This method can provide effective technical support for security analysts to detect the formatted string branch tampering backdoor in the software system.

[0142] Please note that the technical features of the above embodiments can be combined arbitrarily. In order to make the description concise, all possible combinations of the technical features in the above embodiments are not described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification. The above-mentioned embodiments only express several implementation methods of the present application, and their descriptions are relatively specific and detailed, but they cannot be understood as limiting the scope of the invention patent. It should be pointed out that for ordinary technicians in this field, without departing from the concept of the present application, several variations and improvements can be made, which all belong to the scope of protection of the present application. Therefore, the scope of protection of the patent in this application shall be based on the attached claims.

Claims

1. A formatted string branch tampering backdoor detection method, characterized in that: Given a target binary program and a seed test case, the method includes: During the static analysis phase: Calling a global variable-constant comparison branch static identification module to analyze the target binary program to calculate all global variable-constant comparison branches contained in the target binary program, and extracting branch virtual addresses corresponding to the global variable-constant comparison branches and operands involved in the branch operation as metadata information; During the dynamic monitoring phase: Call the format string vulnerability context dynamic collection module, use the seed test case to drive the execution of the target binary program, and dynamically track the generated program execution trajectory, sequentially record the trigger context corresponding to all triggered format string vulnerabilities, and dynamically track the program execution status after the format string vulnerability occurs; The format string vulnerability delay exploitation module is called. When it is determined that the global variable-constant comparison branch is reached, the trigger context corresponding to the format string vulnerability and the metadata information of the global variable-constant comparison branch are combined to generate an input instance of the format string vulnerability to tamper with the non-constant memory operand content of the global variable-constant comparison branch; The backdoor execution monitoring module is called to analyze the execution process of the input instance. When the backdoor is found to be triggered, the input instance is output as a target input instance that can trigger the backdoor.

2. A formatted string branch tampering backdoor detection method according to claim 1, characterized in that: Call the global variable-constant comparison branch static identification module, and execute the following: Use binary program static control flow analysis technology to calculate all functions contained in the target binary program, and use the in-process arrival fixed value analysis technology to calculate the arrival fixed values ​​corresponding to each memory unit and register for each function; Check whether the last instruction in each basic block of the function is a comparison instruction of the JE or JNE form; If yes, further determine whether one of the two operands of the most recent CMP instruction before the last instruction in the basic block is a constant operand and the other is a non-constant operand; if yes, the last instruction in the basic block is a constant comparison branch, and record the triple {last instruction, constant operand, non-constant operand} as metadata information of the constant comparison branch; For the metadata information of the constant comparison branch, obtain the arrival fixed value corresponding to the position of the non-constant operand in the last instruction, and check whether the arrival fixed value originates from the memory unit of the determined address; If yes, the last instruction in the basic block is a global variable-constant comparison branch, and the ternary {last instruction, constant operand, memory unit of the determined address} is used as the metadata information of the global variable-constant comparison branch; otherwise, continue to track the source of the constant value corresponding to the position of the non-constant operand in the last instruction; The metadata information corresponding to all global variable-constant comparison branches is stored.

3. A formatted string branch tampering backdoor detection method according to claim 2, characterized in that: Call the format string vulnerability context dynamic collection module, and execute: Relying on the specific symbolic execution platform, the format string processing function is dynamically hooked using the API function hooking technology; When the target format string processing function is dynamically called, the hook function of the format string vulnerability context dynamic collection module is triggered, and the hook function obtains the content of the format string to be processed and checks whether it is related to the external input; If so, it is determined that the format string processing function causes a format string vulnerability, and the symbol value content corresponding to the format string is extracted and accumulated into the trigger context corresponding to the format string vulnerability that has occurred and is maintained globally.

4. A formatted string branch tampering backdoor detection method according to claim 3, characterized in that: Call the format string vulnerability delay exploitation module, including: Given the program execution status of the global variable-constant comparison branch and the trigger context corresponding to the currently accumulated format string vulnerability, traverse the strings that cause the format string vulnerability recorded in the trigger context corresponding to the accumulated format string vulnerability to obtain branch information: <branch_addr, branch_const, branch_operand> Among them, branch_addr represents the branch virtual address, branch_const represents the constant operand involved in the branch operation, and branch_operand represents the non-constant operand involved in the branch operation; Construct a format string that writes the contents of branch_const to the memory address of branch_operand: Symstr == WRITE (branch_operand, branch_const) Among them, Symstr represents the constructed format string, and WRITE represents the write operation; Using the formatted string as a symbolic constraint, if the symbolic constraint is satisfied under the path constraint conditions contained in the current program execution state, the constraint solving technology is used to calculate the conjunction condition of the symbolic constraint and the path constraint contained in the current path execution state to determine the input instance that can penetrate the global variable-constant comparison branch.

5. A formatted string branch tampering backdoor detection system, characterized in that: The system includes: a global variable-constant comparison branch static identification module, a format string vulnerability context dynamic collection module, a format string vulnerability delay exploitation module, and a backdoor execution monitoring module; wherein, given a target binary program and a seed test case: During the static analysis phase: Calling a global variable-constant comparison branch static identification module to analyze the target binary program to calculate all global variable-constant comparison branches contained in the target binary program, and extracting branch virtual addresses corresponding to the global variable-constant comparison branches and operands involved in the branch operation as metadata information; During the dynamic monitoring phase: Call the format string vulnerability context dynamic collection module, use the seed test case to drive the execution of the target binary program, and dynamically track the generated program execution trajectory, sequentially record the trigger context corresponding to all triggered format string vulnerabilities, and dynamically track the program execution status after the format string vulnerability occurs; The format string vulnerability delay exploitation module is called. When it is determined that the global variable-constant comparison branch is reached, the trigger context corresponding to the format string vulnerability and the metadata information of the global variable-constant comparison branch are combined to generate an input instance of the format string vulnerability to tamper with the non-constant memory operand content of the global variable-constant comparison branch; The backdoor execution monitoring module is called to analyze the execution process of the input instance. When the backdoor is found to be triggered, the input instance is output as a target input instance that can trigger the backdoor.

6. A formatted string branch tampering backdoor detection system according to claim 5, characterized in that: Call the global variable-constant comparison branch static identification module, and execute the following: Use binary program static control flow analysis technology to calculate all functions contained in the target binary program, and use the in-process arrival fixed value analysis technology to calculate the arrival fixed values ​​corresponding to each memory unit and register for each function; Check whether the last instruction in each basic block of the function is a comparison instruction of the JE or JNE form; If yes, further determine whether one of the two operands of the most recent CMP instruction before the last instruction in the basic block is a constant operand and the other is a non-constant operand; if yes, the last instruction in the basic block is a constant comparison branch, and record the triple {last instruction, constant operand, non-constant operand} as metadata information of the constant comparison branch; For the metadata information of the constant comparison branch, obtain the arrival fixed value corresponding to the position of the non-constant operand in the last instruction, and check whether the arrival fixed value originates from the memory unit of the determined address; If yes, the last instruction in the basic block is a global variable-constant comparison branch, and the ternary {last instruction, constant operand, memory unit of the determined address} is used as the metadata information of the global variable-constant comparison branch; otherwise, continue to track the source of the constant value corresponding to the position of the non-constant operand in the last instruction; The metadata information corresponding to all global variable-constant comparison branches is stored.

7. A formatted string branch tampering backdoor detection system according to claim 6, characterized in that: Call the format string vulnerability context dynamic collection module, and execute: Relying on the specific symbolic execution platform, the format string processing function is dynamically hooked using the API function hooking technology; When the target format string processing function is dynamically called, the hook function of the format string vulnerability context dynamic collection module is triggered, and the hook function obtains the content of the format string to be processed and checks whether it is related to the external input; If so, it is determined that the format string processing function causes a format string vulnerability, and the symbol value content corresponding to the format string is extracted and accumulated into the trigger context corresponding to the format string vulnerability that has occurred and is maintained globally.

8. A formatted string branch tampering backdoor detection system according to claim 7, characterized in that: Call the format string vulnerability delay exploitation module, including: Given the program execution status of the global variable-constant comparison branch and the trigger context corresponding to the currently accumulated format string vulnerability, traverse the strings that cause the format string vulnerability recorded in the trigger context corresponding to the accumulated format string vulnerability to obtain branch information: <branch_addr, branch_const, branch_operand> Among them, branch_addr represents the branch virtual address, branch_const represents the constant operand involved in the branch operation, and branch_operand represents the non-constant operand involved in the branch operation; Construct a format string that writes the contents of branch_const to the memory address of branch_operand: Symstr == WRITE (branch_operand, branch_const) Among them, Symstr represents the constructed format string, and WRITE represents the write operation; Using the formatted string as a symbolic constraint, if the symbolic constraint is satisfied under the path constraint conditions contained in the current program execution state, the constraint solving technology is used to calculate the conjunction condition of the symbolic constraint and the path constraint contained in the current path execution state to determine the input instance that can penetrate the global variable-constant comparison branch.

9. An electronic device, 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, a formatted string branch tampering backdoor detection method as described in any one of claims 1-4 is implemented.

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 the processor, the method for detecting a formatted string branch tampering backdoor according to any one of claims 1 to 4 is implemented.