A grey-box fuzz testing method integrating taint analysis and symbolic execution

By integrating taint analysis and symbolic execution into a gray-box fuzzy testing method, the problem of difficulty in covering deep paths in existing technologies is solved, achieving efficient generation of test cases and improved coverage.

CN118672927BActive Publication Date: 2024-11-26SHANGHAI ANBAN INFORMATION TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410950981.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-07-16
Publication Date
2024-11-26
Estimated Expiration
2044-07-16

AI Technical Summary

Technical Problem

Existing gray-box fuzzing methods are unable to effectively cover the deep paths of the program under test, and the generated test cases are difficult to meet the stringent branch conditions.

Method used

The gray-box fuzzing method integrating taint analysis and symbolic execution performs coverage instrumentation and taint analysis instrumentation on the program under test. It combines a mutation strategy based on coverage feedback mechanism and taint analysis, uses a seed generation tool based on symbolic execution to monitor the fuzzing state, generates new seeds covering new states, and saves test cases when the program crashes.

Benefits of technology

It improves the efficiency of fuzz testing and the coverage of deep paths. By identifying key sections and concentrating computing power, it generates high-quality test cases and improves the coverage of the program under test.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118672927B_ABST
    Figure CN118672927B_ABST
Patent Text Reader

Abstract

The present invention provides a gray-box fuzz testing method integrating taint analysis and symbolic execution, comprising: performing coverage stubbing and taint analysis stubbing on the source code of the tested program to obtain an executable program; selecting a mutated seed from a seed pool; assigning a first mutation strategy and a second mutation strategy to the mutated seed to generate a test case; inputting the test case into the tested program, and if the test case covers a new state of the tested program, using it as a new seed; a seed generation tool based on symbolic execution monitors the current state of the fuzz test, assists in generating a new seed that can cover the new state, and the new seed is added to the seed pool; if the tested program crashes, the test case is saved for subsequent further analysis. The gray-box fuzz testing method integrating taint analysis and symbolic execution provided by the present invention improves the efficiency of fuzz testing and its ability to cover deep-level paths by integrating taint analysis and symbolic execution.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present invention relate to the technical field of gray box fuzz testing, and in particular to a gray box fuzz testing method integrating taint analysis and symbolic execution. Background Art

[0002] Grey-box fuzz testing uses feedback information from the program under test to continuously evolve test cases. This feedback information is mainly obtained through instrumentation technology. Test cases generated by existing grey-box fuzz testing methods are difficult to meet demanding branch conditions and cannot effectively cover deep paths in the program under test.

[0003] Therefore, it is necessary to provide a gray-box fuzz testing method that integrates taint analysis and symbolic execution to solve the above problems. Summary of the invention

[0004] The present invention provides a grey box fuzzy testing method integrating taint analysis and symbolic execution, which improves the efficiency of fuzzy testing and its ability to cover deep-level paths by integrating taint analysis and symbolic execution.

[0005] An embodiment of the present invention provides a gray box fuzz testing method integrating taint analysis and symbolic execution, comprising:

[0006] Perform coverage and taint analysis on the source code of the program under test to obtain an executable program.

[0007] Select the mutated seeds from the seed pool;

[0008] Allocating a first mutation strategy and a second mutation strategy to the mutated seed to generate a test case, wherein the first mutation strategy is a mutation strategy based on a coverage feedback mechanism, and the second mutation strategy is a mutation strategy based on taint analysis;

[0009] Input the test case into the program under test, and if the test case covers a new state of the program under test, use it as a new seed;

[0010] A seed generation tool based on symbolic execution monitors the current state of the fuzz test, assists in generating new seeds that can cover the new state, and the new seeds are added to the seed pool;

[0011] If the program under test crashes, the test case is saved for further analysis.

[0012] Preferably, the second mutation strategy includes:

[0013] identifying constraints for branch conditions from the source code;

[0014] Extracting the type of the variable corresponding to the constraint;

[0015] Mutate the bytes of the variable that affect whether the branch condition is met;

[0016] Depending on the type of the branch condition variable, it is mutated to meet the requirements of a specific path.

[0017] Preferably, the branch condition Defined as a tuple ,in .

[0018] Preferably, mutating bytes of a variable that may affect whether a branch condition is satisfied comprises:

[0019] After propagation, the taint source acts on the convergence point where the branch condition is located, changing the bytes of the test case one by one. If the satisfaction state of the branch condition changes, the byte is a critical byte. In subsequent mutations, additional computing power is allocated to mutate the critical byte.

[0020] Preferably, the variation according to the type of the branch condition variable to meet the requirement of a specific path includes:

[0021] When the type of the variable corresponding to the constraint is an integer, a coarse-grained mutation is performed on it; when the type of the variable corresponding to the constraint is a floating-point type, a fine-grained mutation is performed on it.

[0022] Preferably, the coarse-grained variation includes increasing the number of bit flipping steps of 4 by 2 times, and the fine-grained variation includes increasing the number of bit flipping steps of 1 by 2 times.

[0023] Preferably, the seed generation tool based on symbolic execution monitors the current state of the fuzz test, including:

[0024] Compile the source code into LLVM intermediate code;

[0025] Inserting a stub into the intermediate code and embedding a Z3 solver;

[0026] Use LLVM's clang compiler to compile the instrumented intermediate code into the final binary program;

[0027] During the fuzz test, the binary program is executed using a symbolic execution auxiliary program to generate seeds that meet the constraints for the fuzz test.

[0028] Preferably, compiling the source code into the intermediate code of LLVM includes: using the clang compiler of LLVM to compile the source code of the program under test into the intermediate code of LLVM.

[0029] Preferably, the LLVM intermediate code connects the front end and the back end, the front end generates the intermediate code, the back end receives the intermediate code, and the program under test is instrumented at the level of the LLVM intermediate code.

[0030] Preferably, the Z3 solver is used to check the satisfiability of a logical expression, and if the logical expression is satisfiable, a feasible solution to the constraint is obtained by the Z3 solver.

[0031] Compared with the prior art, the technical solution of the embodiment of the present invention has the following beneficial effects:

[0032] An embodiment of the present invention provides a gray-box fuzz testing method integrating taint analysis and symbolic execution, comprising: performing coverage instrumentation and taint analysis instrumentation on the source code of the program under test to obtain an executable program; selecting a mutated seed from a seed pool; assigning a first mutation strategy and a second mutation strategy to the mutated seed to generate a test case, wherein the first mutation strategy is a mutation strategy based on a coverage feedback mechanism, and the second mutation strategy is a mutation strategy based on taint analysis; inputting the test case into the program under test, and if the test case covers the new state of the program under test, using it as a new seed; and generating a seed based on symbolic execution. The tool monitors the current state of the fuzz test, assists in generating new seeds that can cover the new state, and the new seeds are added to the seed pool; if the program under test crashes, the test case is saved for subsequent further analysis, and the first mutation strategy and the second mutation strategy are combined. On the basis of the mutation strategy based on the coverage feedback mechanism, a mutation strategy based on taint analysis is added, and the efficiency of the fuzz test is improved by identifying the key bytes of the test case and acting on the mutation process of the seed. Furthermore, the seed generation tool based on symbolic execution generates new seeds for the fuzz test as a supplement during the fuzz test operation, providing the ability of fuzz test to cover deep-level paths;

[0033] Furthermore, based on the mutation strategy of taint analysis, the fuzz tester can ignore unimportant bytes of the test case and focus the computing power on the key bytes of the test case;

[0034] Furthermore, the seed generation tool based on symbolic execution abstracts the variables of the program under test into symbols, and satisfies the constraints of specific paths by solving them. The path analysis capability of symbolic execution can generate high-quality test cases for fuzz testing. Based on symbolic execution, the fuzz tester can have both the parsing of specific paths of symbolic execution and the high efficiency of fuzz testing itself, comprehensively improving the coverage of the program under test. BRIEF DESCRIPTION OF THE DRAWINGS

[0035] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following is a brief introduction to the drawings required for use in the embodiments or the prior art descriptions. Obviously, the drawings described below are some embodiments of the present invention, not all embodiments. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative labor.

[0036] Figure 1 A flowchart of a gray box fuzz testing method integrating taint analysis and symbolic execution provided by an embodiment of the present invention;

[0037] Figure 2 A flowchart of a gray box fuzz testing method integrating taint analysis and symbolic execution provided by another embodiment of the present invention;

[0038] Figure 3 A flowchart of a gray-box fuzz testing method integrating taint analysis and symbolic execution is provided for another embodiment of the present invention. DETAILED DESCRIPTION

[0039] 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 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 creative work are within the scope of protection of the present invention.

[0040] The technical solution of the present invention is described in detail with specific embodiments below. The following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be described in detail in some embodiments.

[0041] Based on the problems existing in the prior art, an embodiment of the present invention provides a gray-box fuzz testing method that integrates taint analysis and symbolic execution. By integrating taint analysis and symbolic execution, the efficiency of fuzz testing and its ability to cover deep-level paths are improved.

[0042] Figure 1 A flowchart of a gray box fuzz testing method integrating taint analysis and symbolic execution is provided for one embodiment of the present invention. Figure 1 , provides a gray-box fuzz testing method integrating taint analysis and symbolic execution, including:

[0043] Step S101: performing coverage analysis and taint analysis on the source code of the program under test to obtain an executable program;

[0044] Step S102: selecting a mutated seed from the seed pool;

[0045] Step S103: assigning a first mutation strategy and a second mutation strategy to the mutated seed to generate a test case, wherein the first mutation strategy is a mutation strategy based on a coverage feedback mechanism, and the second mutation strategy is a mutation strategy based on taint analysis;

[0046] Step S104: input the test case into the program under test, and if the test case covers the new state of the program under test, use it as a new seed;

[0047] Step S105: The seed generation tool based on symbolic execution monitors the current state of the fuzz test, assists in generating new seeds that can cover the new state, and the new seeds are added to the seed pool;

[0048] Step S106: If the program under test crashes, the test case is saved for subsequent further analysis.

[0049] Specifically, in step S101, coverage instrumentation is performed on the source code of the program under test to support coverage feedback of traditional grey box fuzz testing, and taint analysis instrumentation is performed on the source code of the program under test to support taint analysis feedback.

[0050] In a specific implementation, the branch condition Defined as a tuple ,in .

[0051] Assuming the above and are all integer variables, then "integer" means and In a specific implementation, the mutating of the bytes of the variable that will affect whether the branch condition is satisfied includes:

[0052] After propagation, the taint source acts on the convergence point where the branch condition is located, changing the bytes of the test case one by one. If the satisfaction state of the branch condition changes, the byte is a critical byte. In subsequent mutations, additional computing power is allocated to mutate the critical byte.

[0053] Specifically, the test case contains several bytes, only a few bytes will affect and The value of .

[0054] In a specific implementation, the variation according to the type of the branch condition variable to meet the requirements of a specific path includes:

[0055] When the type of the variable corresponding to the constraint is an integer, a coarse-grained mutation is performed on it; when the type of the variable corresponding to the constraint is a floating-point type, a fine-grained mutation is performed on it.

[0056] In a specific implementation, the coarse-grained variation includes increasing the number of bit flipping steps of 4 by 2 times, and the fine-grained variation includes increasing the number of bit flipping steps of 1 by 2 times.

[0057] Figure 2 A flowchart of a gray box fuzz testing method integrating taint analysis and symbolic execution is provided for another embodiment of the present invention. Figure 2 , provides a gray-box fuzz testing method integrating taint analysis and symbolic execution, including:

[0058] Step S201: Perform coverage analysis and taint analysis on the source code of the program under test to obtain an executable program;

[0059] Step S202: selecting a mutated seed from the seed pool;

[0060] Step S203: assigning a first mutation strategy and a second mutation strategy to the mutated seed to generate a test case, wherein the first mutation strategy is a mutation strategy based on a coverage feedback mechanism, and the second mutation strategy is a mutation strategy based on taint analysis;

[0061] Step S204: identifying the constraints of branch conditions from the source code;

[0062] Step S205: extracting the type of the variable corresponding to the constraint;

[0063] Step S206: mutating the bytes of the variable that will affect whether the branch condition is satisfied;

[0064] Step S207: according to the type of the branch condition variable, mutate to meet the requirements of a specific path;

[0065] Step S208: input the test case into the program under test, and if the test case covers the new state of the program under test, use it as a new seed;

[0066] Step S209: The seed generation tool based on symbolic execution monitors the current state of the fuzz test, assists in generating new seeds that can cover the new state, and the new seeds are added to the seed pool;

[0067] Step S210: If the program under test crashes, the test case is saved for subsequent further analysis.

[0068] Figure 3A flowchart of a gray box fuzz testing method integrating taint analysis and symbolic execution is provided for another embodiment of the present invention. Figure 3 , provides a gray-box fuzz testing method integrating taint analysis and symbolic execution, including:

[0069] Step S301: Perform coverage analysis and taint analysis on the source code of the program under test to obtain an executable program;

[0070] Step S302: Selecting a mutated seed from the seed pool;

[0071] Step S303: assigning a first mutation strategy and a second mutation strategy to the mutated seed to generate a test case, wherein the first mutation strategy is a mutation strategy based on a coverage feedback mechanism, and the second mutation strategy is a mutation strategy based on taint analysis;

[0072] Step S304: input the test case into the program under test, and if the test case covers the new state of the program under test, use it as a new seed;

[0073] Step S305: The seed generation tool based on symbolic execution monitors the current state of the fuzz test, assists in generating new seeds that can cover the new state, and the new seeds are added to the seed pool;

[0074] Step S306: compile the source code into LLVM intermediate code;

[0075] Step S307: inserting a stub into the intermediate code and embedding a Z3 solver;

[0076] Step S308: Use the clang compiler of LLVM to compile the inserted intermediate code into the final binary program;

[0077] Step S309: during the fuzz test, the binary program is executed using a symbolic execution auxiliary program to generate a seed satisfying the constraints for the fuzz test;

[0078] Step S310: If the program under test crashes, the test case is saved for subsequent further analysis.

[0079] In a specific implementation, compiling the source code into the intermediate code of LLVM includes: using the clang compiler of LLVM to compile the source code of the program under test into the intermediate code of LLVM.

[0080] In a specific implementation, the LLVM intermediate code connects the front end and the back end, the front end generates the intermediate code, the back end receives the intermediate code, and the program under test is instrumented at the level of the LLVM intermediate code.

[0081] In a specific implementation, the Z3 solver is used to check the satisfiability of a logical expression. If the logical expression is satisfiable, a feasible solution to the constraint is obtained through the Z3 solver.

[0082] In summary, an embodiment of the present invention provides a gray-box fuzz testing method that integrates taint analysis and symbolic execution, including: performing coverage instrumentation and taint analysis instrumentation on the source code of the program under test to obtain an executable program; selecting a mutated seed from a seed pool; assigning a first mutation strategy and a second mutation strategy to the mutated seed to generate a test case, wherein the first mutation strategy is a mutation strategy based on a coverage feedback mechanism, and the second mutation strategy is a mutation strategy based on taint analysis; inputting the test case into the program under test, and if the test case covers the new state of the program under test, using it as a new seed; seed based on symbolic execution The generation tool monitors the current state of the fuzz test, assists in generating new seeds that can cover the new state, and the new seeds are added to the seed pool; if the program under test crashes, the test case is saved for subsequent further analysis, and the first mutation strategy and the second mutation strategy are combined, and a mutation strategy based on taint analysis is added on the basis of the mutation strategy based on the coverage feedback mechanism, and the efficiency of the fuzz test is improved by identifying the key bytes of the test case and acting on the mutation process of the seed. Furthermore, the seed generation tool based on symbolic execution generates new seeds for the fuzz test as a supplement during the fuzz test operation, providing the ability of the fuzz test to cover deep-level paths;

[0083] Furthermore, based on the mutation strategy of taint analysis, the fuzz tester can ignore unimportant bytes of the test case and focus the computing power on the key bytes of the test case;

[0084] Furthermore, the seed generation tool based on symbolic execution abstracts the variables of the program under test into symbols, and satisfies the constraints of specific paths by solving them. The path analysis capability of symbolic execution can generate high-quality test cases for fuzz testing. Based on symbolic execution, the fuzz tester can have both the parsing of specific paths of symbolic execution and the high efficiency of fuzz testing itself, comprehensively improving the coverage of the program under test.

[0085] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or replace some or all of the technical features therein with equivalents. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present invention.

Claims

1. A gray-box fuzz testing method integrating taint analysis and symbolic execution, characterized in that: include: Perform coverage and taint analysis on the source code of the program under test to obtain an executable program. Select the mutated seeds from the seed pool; Allocating a first mutation strategy and a second mutation strategy to the mutated seed to generate a test case, wherein the first mutation strategy is a mutation strategy based on a coverage feedback mechanism, and the second mutation strategy is a mutation strategy based on taint analysis; Input the test case into the program under test, and if the test case covers a new state of the program under test, use it as a new seed; A seed generation tool based on symbolic execution monitors the current state of the fuzz test, assists in generating new seeds that can cover the new state, and the new seeds are added to the seed pool; If the program under test crashes, the test case is saved for further analysis; The second mutation strategy includes: identifying constraints for branch conditions from the source code; Extracting the type of the variable corresponding to the constraint; Mutate the bytes of the variable that affect whether the branch condition is met; According to the type of the branch condition variable, mutation is performed to meet the requirements of a specific path; The variation according to the type of the branch condition variable to meet the requirements of a specific path includes: When the type of the variable corresponding to the constraint is an integer, a coarse-grained mutation is performed on it; when the type of the variable corresponding to the constraint is a floating-point type, a fine-grained mutation is performed on it.

2. The gray-box fuzz testing method integrating taint analysis and symbolic execution according to claim 1, characterized in that: The branch condition Defined as a tuple ,in .

3. The gray-box fuzz testing method integrating taint analysis and symbolic execution according to claim 1, characterized in that: The mutating of the bytes of the variable that will affect whether the branch condition is satisfied includes: After propagation, the taint source acts on the convergence point where the branch condition is located, changing the bytes of the test case one by one. If the satisfaction state of the branch condition changes, the byte is a critical byte. In subsequent mutations, additional computing power is allocated to mutate the critical byte.

4. The gray-box fuzz testing method integrating taint analysis and symbolic execution according to claim 1, characterized in that: The coarse-grained variation includes increasing the number of bit flipping steps of 4 by 2 times, and the fine-grained variation includes increasing the number of bit flipping steps of 1 by 2 times.

5. The gray-box fuzz testing method integrating taint analysis and symbolic execution according to claim 1, characterized in that: The seed generation tool based on symbolic execution monitors the current status of fuzz testing including: Compile the source code into LLVM intermediate code; Inserting a stub into the intermediate code and embedding a Z3 solver; Use LLVM's clang compiler to compile the instrumented intermediate code into the final binary program; During the fuzz test, the binary program is executed using a symbolic execution auxiliary program to generate seeds that meet the constraints for the fuzz test.

6. The gray-box fuzz testing method integrating taint analysis and symbolic execution according to claim 5, characterized in that: Compiling the source code into the intermediate code of LLVM includes: using the clang compiler of LLVM to compile the source code of the program under test into the intermediate code of LLVM.

7. The gray-box fuzz testing method integrating taint analysis and symbolic execution according to claim 6, characterized in that: The LLVM intermediate code connects the front end and the back end. The front end generates the intermediate code, and the back end receives the intermediate code, and inserts the program under test at the level of the LLVM intermediate code.

8. The gray-box fuzz testing method integrating taint analysis and symbolic execution according to claim 5, characterized in that: The Z3 solver is used to check the satisfiability of a logical expression. If the logical expression is satisfiable, a feasible solution to the constraint is obtained by the Z3 solver.