Seed exploration potential oriented hybrid fuzzy testing method

Through the branch evaluation method that combines static analysis and dynamic information, the seed delivery priority is optimized, which solves the shortcomings of the seed selection strategy in the existing hybrid fuzz testing, improves the coverage and efficiency of the hybrid fuzz testing, and adapts to the testing needs of complex software systems. .

CN118656304APending Publication Date: 2024-09-17成都链安科技有限公司
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202410902542.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-07-07
Publication Date
2024-09-17

AI Technical Summary

Technical Problem

Existing hybrid fuzz testing does not make full use of static and dynamic information, resulting in a lack of effectiveness in seed selection strategies, making it difficult to improve test coverage, and unclear system collaboration methods, which limits efficiency improvements.

Method used

Extract static features of the program through static analysis, combine with dynamic information in the fuzz testing process, use branch-oriented evaluation methods to calculate the potential of seeds for symbolic execution, optimize seed delivery priorities, design standardized hybrid fuzz testing system structure and interaction process, and improve Seed exploration potential assessment during coordination and seed scheduling phases.

Benefits of technology

It improves the vulnerability detection efficiency of hybrid fuzz testing, obtains higher coverage and wider code coverage, adapts to the testing needs of complex software systems, and achieves efficient seed scheduling and system collaboration.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118656304A
    Figure CN118656304A
Patent Text Reader

Abstract

The invention belongs to the technical field of computers, and discloses a seed exploration potential-oriented hybrid fuzzy testing method, which comprises the following steps of: extracting key program static information from a tested program and providing a product after instrumentation by using branch-oriented evaluation as a basis for calculating seed potential through a static analyzer; testing the tested program according to a fuzzy test strategy specified by a user through a fuzzy tester to obtain a coordinator candidate seed; obtaining a seed priority through a coordinator; and obtaining seeds from the coordinator according to the exploration potential from high to low, and performing symbolic execution. According to the method, the detection efficiency of software vulnerabilities can be improved, a higher branch coverage rate can be obtained in the same time compared with the similar technology, and wider code coverage and higher vulnerability discovery capability are realized.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the field of computer technology, and relates to software security, software testing and automatic mining of software vulnerabilities, and in particular to a hybrid fuzzy testing method guided by seed exploration potential. Background Art

[0002] Software testing is a common method to ensure software quality. How to obtain high code coverage is an important and challenging research problem in this field. Fuzz testing and symbolic execution technology have been widely studied and applied. Fuzz testing triggers potential vulnerabilities by inputting a large number of random or semi-random inputs into the program, but it is difficult to generate test cases that break through complex constraints. Symbolic execution relies on constraint solvers and can generate inputs that cover complex constraints, but there will be problems of state explosion and high performance consumption in the process, which makes it difficult to meet the testing needs of large-scale and complex software systems.

[0003] Hybrid fuzz testing is based on the complementarity of fuzz testing and symbolic execution. The framework of hybrid fuzz testing usually consists of three parts: fuzz tester, symbolic executor and coordinator. Among them, the fuzz tester and symbolic executor are the main bodies of the test, while the coordinator is responsible for managing the information exchange and functional interaction between the above two. The fuzz tester tests the program under test according to a specific fuzz testing strategy. At the same time, the coordinator selects suitable seeds from the seed queue through potential evaluation according to the set interaction strategy and hands them over to the symbolic executor. The symbolic execution stage relies on the path constraint solving capability of the constraint solver. After the newly generated input is synchronized by the coordinator, the potential seeds are screened again and fed back to the seed queue of the fuzz tester to help the fuzz tester obtain greater coverage benefits. Throughout the process, the fuzz tester and symbolic executor continuously exchange seeds and collect inputs that cause program exceptions or crashes.

[0004] The seed synchronization method between fuzz testing and symbolic execution in hybrid fuzz testing will have a significant impact on the performance of hybrid fuzz testing. Symbolic execution's symbolic simulation, constraint collection, and constraint solving bring about a large performance overhead, and the speed of generating new test cases is slow; in contrast, fuzz testing can quickly generate a large number of test cases through seed mutation strategies. There is a significant difference in throughput between fuzz testing and symbolic execution. Under limited time and resource budgets, symbolic execution cannot make large-scale use of the inputs generated by fuzz testing, and fuzz testing also finds it difficult to use symbolic execution test cases to specifically reach larger code intervals. Therefore, for symbolic execution, it is particularly important to carefully select a small number of candidate sets from the many candidate seeds generated by fuzz testing, and maximize the effect of these seeds to drive symbolic execution to break through complex constraints.

[0005] N.Stephens et al. proposed that Driller uses a "demand-driven" strategy of fuzz testing and symbolic execution, and appropriately switches between hybrid execution and fuzz testing according to the growth of program coverage, proving that hybrid fuzz testing is better than separate symbolic execution and fuzz testing (see N.Stephens et al., "Driller: Augmenting fuzzing through selective symbolic execution," in NDSS, 2016, pp. 1–16). I.Yun et al. proposed QSYM to reduce the impact of the low performance of the hybrid execution engine on the overall running speed in the current hybrid fuzz testing, and designed a customized hybrid execution engine suitable for hybrid fuzz testing (see I.Yun, S.Lee, M.Xu, Y.Jang, and T.Kim, "{QSYM}: A practical concolic execution engine tailored for hybrid fuzzing," in 27th USENIX Security Symposium (USENIX Security 18), 2018, pp. 745–761). L. Jiang et al. proposed an edge-based scheduling method to improve the seed scheduling strategy (see L. Jiang, H. Yuan, M. Wu, L. Zhang, and Y. Zhang, “Evaluating and improving hybrid fuzzing,” in 2023 IEEE / ACM 45th International Conference on Software Engineering (ICSE), IEEE, 2023, pp. 410–422).

[0006] However, the existing hybrid fuzz testing does not fully utilize the static and dynamic information of the program during fuzz testing and symbolic execution to guide the seed exchange strategy, resulting in a lack of effectiveness in the seed selection strategy. It is difficult to select inputs that are beneficial to symbolic execution from the fuzz test seed queue, which limits the improvement of test coverage. In addition, the existing hybrid fuzz testing system does not clearly define the responsibilities and boundaries of each component, especially the seed synchronization strategy for the seed itself adopted by the coordination mechanism lacks a standardized system collaboration method and interaction process in the coordination mechanism, which limits the improvement of system efficiency. Summary of the invention

[0007] The purpose of the present invention is to address the problems existing in the above-mentioned prior art and to provide a hybrid fuzz testing method guided by seed exploration potential. Branch-oriented evaluation is used as the basis for calculating seed potential, and the dynamic coverage information and static feature correspondence between seeds and branches in the program structure are fully considered to promote the scheduling of hybrid fuzz testing, thereby improving the detection efficiency of hybrid fuzz testing vulnerabilities and obtaining a higher coverage rate.

[0008] The inventive concept of the present invention is: by extracting the static features of the program from static analysis, combined with the dynamic information reflected by the seed branch coverage during the fuzz test operation, a series of indicators and algorithms proposed by the present invention are used to calculate the potential of the seed for symbolic execution to break through the difficult branches, thereby determining the priority of the candidate seeds for symbolic execution. The present invention standardizes four stages and their tasks and their interaction methods in the design of the hybrid fuzz test system: preprocessing and static analysis, fuzz testing, coordination and seed scheduling, and symbolic execution, especially in the coordination and seed scheduling stage, the seed exploration potential evaluation method based on branch coverage is improved.

[0009] The hybrid fuzz testing system used in the present invention includes a static analyzer, a fuzz tester, a coordinator and a symbolic executor:

[0010] The static analyzer is used to perform static analysis on the program under test, extract key program static information and provide a product after instrumentation;

[0011] The fuzz tester is used to perform fuzz testing on the program under test to obtain a coordinator candidate seed;

[0012] The coordinator is used to determine the priority of seeds to be used for symbolic execution;

[0013] The symbolic executor is used to obtain seeds from the coordinator according to the exploration potential from high to low, and perform symbolic execution.

[0014] Based on the above hybrid fuzz testing system, the present invention provides a seed exploration potential-oriented hybrid fuzz testing method, which uses branch-oriented evaluation as a basis for calculating seed potential, and includes the following steps:

[0015] Step 1: Preprocessing and static analysis

[0016] Through the static analyzer, key program static information is extracted from the program under test and the instrumented product is provided;

[0017] Step 2: Fuzz Testing

[0018] Through the fuzz tester, the program under test is tested according to the fuzz testing strategy specified by the user to obtain the coordinator candidate seed;

[0019] Step 3: Coordination and seed scheduling, obtaining seed priority through the coordinator; this step includes the following sub-steps:

[0020] Step 3-1: Coordinator configuration; read the information obtained from the static analysis in step 1 and the information obtained during the fuzz testing process in step 2;

[0021] Step 3-2: Seed potential evaluation mechanism; the coordinator continuously reads the candidate seeds input to the coordinator in step 2, and calculates the exploration potential of each candidate seed in turn according to the information obtained from the static analysis read in step 3-1 and the information obtained during the fuzz testing process to determine the priority of the seed delivery symbolic execution;

[0022] Step 3-3: Based on the seeds calculated in step 3-2, use the priority queue PrioQueue to maintain the order of these seeds from high to low priority; the coordinator retrieves the seeds in order according to the priority and sends them to the symbolic executor;

[0023] Step 4: Symbolic execution: Get seeds from the coordinator according to the exploration potential from high to low, and perform symbolic execution.

[0024] The above seed exploration potential-oriented hybrid fuzz testing method, the preprocessing and static analysis steps include the following sub-steps:

[0025] Step 1-1: Convert the source code of the program under test into LLVM bytecode file, and export the intra-procedural control flow graph CFG and inter-procedural control flow graph iCGF information;

[0026] Step 1-2: Extract the branch and reachable basic block mapping information file Branch-ReachableBB in the control flow graph according to the bytecode file in step 1-1;

[0027] Step 1-3: Insert coverage collection logic and runtime seed coverage relationship monitoring code into the bytecode file obtained in step 1-1, that is, provide a product after the instrumentation.

[0028] The above seed exploration potential-oriented hybrid fuzz testing method, the fuzz testing step includes the following sub-steps:

[0029] Step 2-1: Configure fuzz testing strategy;

[0030] Step 2-2: Fuzz test initialization; the fuzz tester uses the initial seed to test the program under test, and collects the coverage information of the program in real time according to the coverage collection component of the fuzz tester; by analyzing the coverage information, high-value initial seeds are identified; high-value initial seeds will be saved in the seed queue Queue as input for the subsequent mutation process;

[0031] Step 2-3: Fuzz test is officially run; the seeds in the seed queue specified in step 2-2 are mutated in turn using the specified mutation strategy and transmitted to the program under test; if the program runs overtime or an exception occurs, the relevant information is recorded and stored in the corresponding directory; for seeds that run normally, their coverage information is collected; if the mutated seeds increase the program coverage, they are regarded as high-value seeds and saved in the seed queue; for seeds generated after mutation that do not increase the program coverage, no subsequent processing is performed and they are directly discarded; after each batch is completed, the new high-value seed sequence will be used as the coordinator candidate seed; then, the next batch of seeds will be selected to continue mutation and testing; this step will continue until the predetermined stop condition is reached, such as the maximum number of iterations or the specified test time; after each round of iteration, return to step 2-3, and the process will continue until the predetermined stop condition is reached;

[0032] Step 2-4: Fuzz test seed-branch relationship extraction, record the correspondence between the coverage information trace of the seed run in step 2-3 and the branch Branch in CFG.

[0033] In the above step 2-1, the fuzz testing strategy includes necessary runtime configuration information of the fuzz tester, such as the scheduled execution time, working directory, compiled product path, initial seed, number of seeds participating in each batch of fuzz testing, total rounds, etc.

[0034] In the above step 2-2, the high-value initial seed is the seed that increases the coverage of the program during the test. If a seed leads to an increase in coverage, it is identified as a high-value initial seed, and they have a higher probability of bringing greater coverage gains in subsequent fuzz testing processes.

[0035] In the above seed exploration potential-oriented hybrid fuzz testing method, step 3-2 is divided into two stages: branch potential evaluation and seed priority evaluation; specifically, it includes the following sub-steps:

[0036] Step 3-2-1: Static program definition and extraction; Based on the information obtained from static analysis, the number of basic blocks that branches can reach is statically calculated according to the control flow graph (CFG) of the program. i And the distance between the branch and the root node Depth i As the basis for static branch potential evaluation; the static potential evaluation score_static of branch i is calculated i , calculated as

[0037] Step 3-2-2: Dynamic test runtime information definition and extraction; Based on the information obtained during the fuzz testing process, obtain branch i and its sibling branch sib iAt this point, the coverage of the specified branch i and its sibling branch sib during the fuzz testing process is measured by the indicator DHC i The difference in coverage between BH i and They represent the number of times branch i and its sibling branches are covered in the fuzzy test respectively; branches with DHC values ​​greater than the specified threshold θ are added as candidate branches to the set of candidate branches brSet to narrow the range of candidates, and this set is updated after each fuzzy test iteration; the dynamic potential of branch i is evaluated as score_dynamic i , calculated as ST i Indicates the number of times the constraint corresponding to branch i is solved during symbolic execution;

[0038] Step 3-2-3: Branch potential evaluation algorithm; use the static potential evaluation of step 3-2-1 and the dynamic potential evaluation of step 3-2-2 to obtain the branch potential evaluation: br_score i =α×socre_static i +β×score_dynamic i ; According to br_score, brSet is sorted from high to low according to branch potential to obtain a set of high-potential candidate branches;

[0039] Step 3-2-4: Seed priority evaluation; evaluate the scores of each branch covered by each seed based on the coverage information trace of the seed run and the branch correspondence file Trace-Branch in CFG; if the branches covered by the seed include branches in the high-potential candidate branch set brSet, the exploration potential score of the seed is obtained by accumulating the potential evaluation scores of these branches. This score determines the priority with which this seed is used for symbolic execution.

[0040] The above seed exploration potential-oriented hybrid fuzz testing method, the symbolic execution phase includes the following steps:

[0041] Step 4-1: Get seeds from the coordinator according to the exploration potential from high to low, and perform dynamic symbolic execution;

[0042] Step 4-2: Get the new seeds generated by the symbolic executor after each run, and hand them over to the coordinator to evaluate the coverage of its high-potential candidate branches and calculate its coverage gain. After execution, return to step 4-1 until the maximum number of iterations is reached or the specified test time is exceeded.

[0043] The above seed exploration potential-oriented hybrid fuzz testing method, the coordination and seed scheduling phase also includes:

[0044] Step 3-4: Seed synchronization mechanism; after each round of symbolic execution, the coordinator evaluates the newly generated seeds of the symbolic executor, selects the appropriate seeds according to the selection strategy, and synchronizes them to the fuzz tester through the coordinator.

[0045] The selection strategy is defined as: if these seeds cover high potential candidate branches and the total coverage gain is greater than the specified threshold, these seeds are synchronously sent to the sync directory of the fuzz tester, and these seeds are recorded as sync seeds.

[0046] Compared with the prior art, the seed exploration potential-guided hybrid fuzzy testing method provided by the present invention has the following beneficial effects:

[0047] (1) The present invention utilizes the correspondence between the dynamic coverage information of the seed and the static features of the program to solve the problem that the seeds delivered to symbolic execution in the existing hybrid fuzz testing lack branch exploration targeting and it is difficult to effectively identify candidate seeds with high exploration potential for symbolic execution and give priority to delivering symbolic execution;

[0048] (2) The present invention proposes a hybrid fuzz testing system structure and corresponding interaction process to meet the requirements of the seed exploration potential-oriented seed scheduling method mentioned above; designs the collaboration method and interaction process between the static analyzer, fuzz tester, symbolic executor and coordinator; and realizes efficient seed scheduling through the coordination mechanism improvement, helping the symbolic executor to select better seeds from the fuzz tester and discover more uncovered paths, thereby improving the efficiency of hybrid fuzz testing;

[0049] (3) The present invention can improve the efficiency of software vulnerability detection and obtain higher branch coverage than similar technologies in the same period of time, thereby achieving wider code coverage and higher vulnerability discovery capabilities, and coping with the complexity challenges of modern software system testing within a limited time and resource budget. At the same time, the present invention has the advantages of strong scalability and easy combination with existing hybrid fuzz testing methods. BRIEF DESCRIPTION OF THE DRAWINGS

[0050] Figure 1 Principle architecture diagram of the seed exploration potential-oriented hybrid fuzz testing method;

[0051] Figure 2 Flowchart of the branch potential evaluation algorithm in the seed exploration potential-guided hybrid fuzz testing method;

[0052] Figure 3 Flowchart of the seed potential evaluation algorithm in the seed exploration potential-oriented hybrid fuzz testing method;

[0053] Figure 4Schematic diagram of the seed prioritization mechanism in the seed exploration potential-oriented hybrid fuzz testing method. DETAILED DESCRIPTION

[0054] The following will clearly and completely describe the technical solutions of various embodiments of the present invention in conjunction with the accompanying drawings. 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.

[0055] The following is combined with Figure 1 The components and specific implementation methods involved in the present invention are further explained.

[0056] The hybrid fuzz testing system used in this embodiment includes a static analyzer, a fuzz tester, a coordinator, and a symbolic executor:

[0057] The static analyzer is used to perform static analysis on the program under test, extract key program static information and provide a product after instrumentation;

[0058] The fuzz tester is used to perform fuzz testing on the program under test to obtain a coordinator candidate seed;

[0059] The coordinator is used to determine the priority of seeds to be used for symbolic execution;

[0060] The symbolic executor is used to obtain seeds from the coordinator according to the exploration potential from high to low, and perform symbolic execution.

[0061] like Figure 1 As shown, this embodiment provides a seed exploration potential-guided hybrid fuzz testing method to explain in detail the implementation process of the above-mentioned combined fuzz testing system.

[0062] The above-mentioned seed exploration potential-oriented hybrid fuzz testing method is generally divided into four stages: preprocessing and static analysis, fuzz testing, coordination and seed scheduling, and symbolic execution.

[0063] Step 1: Preprocessing and static analysis

[0064] Through the static analyzer, key program static information is extracted from the program under test and the instrumented product is provided.

[0065] This step includes the following sub-steps:

[0066] Step 1-1: With the help of the Whole Program LLVM (WLLVM) tool, convert the source code of the program under test into an LLVM bytecode file, and export the intra-procedural control flow graph CFG and inter-procedural control flow graph iCGF information.

[0067] Step 1-2: Based on the bytecode file in step 1-1, extract the key static structure information in the program through a static analyzer, such as the branch and reachable basic block mapping information file Branch-ReachableBB in the control flow graph. Each line of Branch-ReachableBB is in the form of "branch_id:m", where branch_id represents the branch number and m represents the number of basic blocks to which the branch leads.

[0068] Step 1-3: Use the AFL-Clang compilation tool chain to insert coverage collection logic and runtime seed coverage relationship monitoring code (i.e., the product after insertion) into the LLVM bytecode obtained in step 1-1 for coverage-guided fuzz testing.

[0069] Step 2: Fuzz Testing

[0070] Through the fuzz tester, the program under test is tested according to the fuzz testing strategy specified by the user to obtain the coordinator candidate seeds.

[0071] This step includes the following sub-steps:

[0072] Step 2-1: Configure the fuzz testing strategy; the fuzz testing strategy includes the scheduled execution time, working directory, compiled product path obtained in step 1-3, initial seed, number of seeds participating in each batch of fuzz testing, total rounds, and other necessary runtime configuration information of the fuzz tester.

[0073] Step 2-2: Fuzz test initialization; the fuzz tester uses the initial seed to test the program under test, and collects the coverage information of the program in real time according to the coverage collection component of the fuzz tester; by analyzing the coverage information, identify which seeds increase the coverage of the program during the test; if a seed leads to an increase in coverage, it is identified as a high-value initial seed, which has a higher probability of bringing greater coverage gain in subsequent fuzz testing processes; high-value initial seeds will be saved in the seed queue Queue as input for the subsequent mutation process.

[0074] Step 2-3: Fuzz testing is officially running; the fuzz tester divides the seeds in the seed queue into several batches, with the specified number of seeds as a batch. In each batch, the specified mutation strategy is applied to each seed in turn to generate new mutation seeds and input them into the program under test for testing. For seeds stored in the sync directory, the fuzz tester will prioritize and add the latest batch for testing to ensure that these seeds are processed first. Different processing methods are adopted according to the different behaviors of the program caused by the mutated seed input: (1) If the seed input generated after mutation causes the program to time out or an exception occurs, record the relevant information and mark the seed as timeout or crash, and store it in the corresponding timeout or crash directory; (2) If the seed generated after mutation causes the program coverage to increase, it is identified as a new high-value seed and saved in the seed queue Queue; (3) For the seeds generated after mutation that do not cause the program coverage to increase, no subsequent processing is performed and they are directly discarded. After each batch, the new high-value seed sequence will be used as the coordinator candidate seed. Subsequently, the seeds of the next batch are selected to continue mutation and testing. This step will continue until a predetermined stopping condition is reached, such as a maximum number of iterations or a specified test time.

[0075] Step 2-4: Fuzz test seed-branch relationship extraction; record the corresponding relationship between the trace of each seed in step 2-3 and the branch in CFG, and save it in the file Trace-Branch. The record format of each line in Trace-Branch is "id:seed_id:{branch_id_1,branch_id_2,...,branch_id_n}", seed_id represents the seed number, and branch_id_n represents the number of the branch it covers.

[0076] Step 3: Coordination and seed scheduling

[0077] The seed priorities are obtained through the coordinator. The coordinator manages the information exchange and functional interaction between the various stages within the system. In particular, this stage implements a seed synchronization and scheduling method based on exploration potential orientation.

[0078] This step includes the following sub-steps:

[0079] Step 3-1: Coordinator configuration.

[0080] Read the branch-ReachableBB mapping information file in the control flow graph generated in step 1-2 as the static information feature of the program, that is, the information obtained by static analysis. At the same time, read the coverage information trace of the seed run recorded in step 2-4 and the correspondence relationship file of the branch in the control flow graph (Trace-Branch) as the information feature of the program runtime, that is, the information obtained during the fuzz testing process.

[0081] Step 3-2: Seed potential assessment mechanism.

[0082] The coordinator continuously reads the candidate seeds input to the coordinator in step 2-3, and calculates the exploration potential of each candidate seed in turn based on the information obtained from the static analysis read in step 3-1 and the information obtained during the fuzz testing process to determine the priority of the seed's delivery symbolic execution.

[0083] The evaluation criteria for the exploration potential of the seed are based on the branch coverage of the seed, which is divided into two stages: branch potential evaluation and seed priority evaluation: (1) Branch potential evaluation: select branches in CFG whose coverage difference between sibling branches during fuzz testing is greater than a specified threshold as candidate branches. Then, based on the static information described in step 3-1 and the dynamic information collected during fuzz testing, evaluate the potential of the candidate branches through a branch potential algorithm that combines dynamic and static information, and sort them from high to low according to branch potential to obtain a set of high-potential candidate branches. The higher the branch potential, the more worthy of key exploration the branches in the program are. (2) Seed priority evaluation: Based on the candidate seeds input in step 2-3, combined with the correspondence between the trace of the seed in step 2-4 and the branches in CFG, obtain the overlap between the seed coverage information and the set of high-potential candidate branches, thereby calculating the priority Prio of the seed delivery symbolic execution.

[0084] The following is combined with Figure 2 , Attachment Figure 3 and attached Figure 4 The seed exploration potential evaluation method involved in the present invention is further explained, corresponding to the specific implementation in step 3-2, including the following steps:

[0085] Step 3-2-1: Static program definition and extraction; Based on the information from the static analysis phase, this step statically calculates the number of basic blocks that branches can reach based on the control flow graph (CFG) of the program. i (Quantity of Basic-block Reachable, the number of basic blocks that can be reached) and the distance Depth between the branch and the root node i As the basis for static branch potential evaluation. The calculated static potential evaluation score_static of branch i i , calculated as

[0086] Step 3-2-2: Branch potential evaluation algorithm.

[0087] Dynamic test runtime information definition and extraction; Based on the information of the fuzzy testing stage, the present invention proposes an indicator DHC (Difference in Hit Counts between siblings) to measure the difference in the number of hits between the specified branch i and its sibling branch sib during the fuzzy testing process. i The difference in coverage between them. A sibling branch refers to a control flow edge in CFG that originates from the same basic block and points to different target basic blocks. This is obtained when the CFG already carries the relationship between all branches and their corresponding basic blocks during the analysis in step 1-1. It can be defined as the sibling branch sib of branch i i is: given a branch i=(n,m) in the control flow graph CFG, where n is the starting basic block and m is the target basic block; its sibling branch sib i Defined as:

[0088] sib i ={j∈E|j=(n,k)∧k≠m}

[0089] E represents the set of all branches in CFG, brother branch sib i It refers to other edges j that have the same starting basic block n as branch i but different ending basic block k.

[0090] DHC is calculated as Among them, BH i and They represent the number of times branch i and its sibling branches are covered in the fuzzy test. The larger the DHC value of a branch, the greater the imbalance between the hit times of its sibling branches and itself, which means that there are difficult constraints that are difficult to reach in the fuzzy test stage. The present invention adds branches with DHC values ​​greater than the specified threshold θ (the default value is 1000) as candidate branches to the set of candidate branches brSet. The dynamic potential of branch i is evaluated as ST i It indicates the number of times the constraint corresponding to branch i is solved during the symbolic execution process. The more historical solutions there are, the greater the probability that the constraint corresponding to this branch is difficult to be solved by the current symbolic execution.

[0091] In this step, branches with DHC values ​​greater than the specified threshold θ are added as candidate branches to the set of candidate branches brSet to narrow the range of candidates. This set is updated after each fuzz test iteration. The dynamic potential of branch i is evaluated as score_dynamic i, calculated as ST i Indicates the number of times the constraint corresponding to branch i is solved during symbolic execution.

[0092] Step 3-2-3: Branch potential evaluation algorithm.

[0093] Use the weighted evaluation of the static potential evaluation in step 3-2-1 and the dynamic potential evaluation in step 3-2-2 to get the evaluation of the potential of branch i: br_score i =α×socre_static i +β×score_dynamic i The present invention uses two adjustable parameters α and β to adjust the weights of static factors and dynamic factors in branch potential evaluation. The sum of α and β is always 1, and the default value is 0.5. When exploring in different programs, by modifying the values ​​of α and β, the emphasis of the evaluation on static factors and dynamic factors is changed to achieve specific strategies for different programs. According to br_score, brSet is sorted from high to low according to branch potential to obtain a set of high-potential candidate branches. The process described in this step is as follows Figure 2 shown.

[0094] Steps 3-2-1 to 3-2-3 can be described using the following pseudo code:

[0095] Input:

[0096] cfg: control flow graph of the program under test

[0097] ctx: fuzz testing context

[0098] seedQueue: fuzz test seed queue

[0099] Output: scoreSet: score set of branches

[0100] Function: BranchScore

[0101]

[0102]

[0103] Step 3-2-4: Seed priority evaluation.

[0104] Based on the coverage information trace of the seed run, the Trace-Branch file corresponding to the branch in CFG, and the branch potential score obtained in step 3-2-3, evaluate each seed exploration potential score seed_score, which corresponds to the seed priority Prio. Figure 3This step evaluates the correspondence between the seed trace and brSet: if the branches covered by the seed contain branches of the high potential candidate branch set brSet (i.e., the intersection of the two sets), the exploration potential score of seed j is obtained by accumulating the potential evaluation scores of these branches If the branches covered by the seed are not in the set of high potential candidate branches, they will not be processed further and the seed_score will be recorded as -1. The score determines its priority for symbolic execution. The calculation process is as follows: Figure 3 As shown. Apply the above method to all seeds in the seed queue to obtain the potential scores of all candidate seeds. Use the priority queue Prio to maintain the order of these seeds, with seeds with higher potential evaluation scores at the head of the queue and seeds with lower scores at the tail of the queue. The coordinator retrieves the seeds in order according to the priority and feeds them into the symbolic executor. This process is used to convert branch potential into seed priority. Figure 4 This step method is explained.

[0105] Step 3-3: Based on the seeds calculated in step 3-2, use the priority queue PrioQueue to maintain the order of these seeds from high to low priority. The coordinator retrieves the seeds in order according to the priority and sends them to the symbolic executor.

[0106] According to the Prio calculated in step 3-2, the priority queue PrioQueue is used to maintain the order of these seeds from high to low priority, with seeds with higher priorities at the head of the queue and seeds with lower scores at the tail of the queue. The coordinator retrieves the seeds in order according to the priority and feeds them into the symbolic executor. This process is used to convert branch potential into seed priority.

[0107] Step 3-4: Seed synchronization mechanism; after each round of symbolic execution, the coordinator evaluates the newly generated seeds of the symbolic executor, selects the appropriate seeds according to the selection strategy, and synchronizes them to the fuzz tester through the coordinator.

[0108] The purpose of this step is to select a part of the seeds that are beneficial to fuzz testing to cover high-potential candidate branches from the new seeds generated by the symbolic executor and send them back to the fuzz tester. After each round of symbolic execution, the coordinator evaluates the new seeds generated by symbolic execution and selects appropriate seeds according to the selection strategy to synchronize them to the fuzz tester through the coordinator. The selection strategy is defined as: if these seeds cover high-potential candidate branches and the total coverage gain is greater than the specified threshold, these seeds are synchronized to the sync directory of the fuzz tester, and these seeds are recorded as sync seeds. Fuzz testing needs to give priority to the targeted use of these seeds that have broken through high-potential candidate branches.

[0109] Step 4: Symbolic execution: Get seeds from the coordinator according to the exploration potential from high to low, and perform symbolic execution.

[0110] This stage relies on the path constraint solving capability of the symbolic executor to help fuzz testing cover a wider range of code space.

[0111] The symbolic execution phase includes the following steps:

[0112] Step 4-1: Get seeds from the coordinator according to the exploration potential from high to low, and hand them over to the QSYM dynamic symbolic executor for dynamic symbolic execution.

[0113] Step 4-2: Get the new seeds generated after each QSYM run, and hand them over to the coordinator to evaluate the coverage of its high-potential candidate branches and calculate its coverage gain. After execution, return to step 4-1 until the maximum number of iterations is reached or the specified test time is exceeded.

[0114] In summary, the present invention has the following advantages:

[0115] (1) The present invention proposes a seed exploration potential evaluation method that combines dynamic and static information and is guided by branch coverage in the field of hybrid fuzz testing. Through the correspondence between the coverage information collected during static analysis and test runtime and the branches in the control flow graph, the key branches in the program that are worth exploring are determined. Based on this information, the seeds in the fuzz test queue are evaluated for their ability to reach key branches during the symbolic execution phase, and the seed exploration potential is obtained, which is used to guide the seed synchronization and scheduling of hybrid fuzz testing, thereby forming a hybrid fuzz testing method guided by seed exploration potential. In particular, in terms of the calculation of the exploration potential score, the present invention proposes a series of indicators and algorithms to meet the above requirements.

[0116] (2) The present invention proposes an improved method by standardizing the four stages of the hybrid fuzz testing system architecture and their tasks and interaction methods. The four stages include: preprocessing and static analysis, fuzz testing, coordination and seed scheduling, and symbolic execution. In particular, in the coordination and seed scheduling stage, the seed exploration potential evaluation method based on branch coverage and the seed prioritization mechanism are improved.

[0117] (3) The method proposed in the present invention utilizes the program information reflected in the fuzzy testing and symbolic execution process to propose a lightweight seed potential evaluation method based on branch exploration potential, providing a novel solution.

[0118] Those skilled in the art will appreciate that the embodiments herein are intended to help readers understand the principles of the present invention, and should be understood that the protection scope of the present invention is not limited to such specific statements and embodiments. Those skilled in the art can make various other specific variations and combinations that do not deviate from the essence of the present invention based on the technical revelations disclosed by the present invention, and these variations and combinations are still within the protection scope of the present invention.

Claims

1. A seed exploration potential-oriented hybrid fuzzy testing method, characterized in that: The following steps are involved: Step 1: Preprocessing and static analysis Through the static analyzer, key program static information is extracted from the program under test and the instrumented product is provided; Step 2: Fuzz Testing Through the fuzz tester, the program under test is tested according to the fuzz testing strategy specified by the user to obtain the candidate seed of the coordinator; Step 3: Coordination and seed scheduling, obtaining seed priority through the coordinator; this step includes the following sub-steps: Step 3-1: Coordinator configuration; read the information obtained from the static analysis in step 1 and the information obtained during the fuzz testing process in step 2; Step 3-2: Seed potential evaluation mechanism; the coordinator continuously reads the candidate seeds input to the coordinator in step 2, and calculates the exploration potential of each candidate seed in turn according to the information obtained from the static analysis read in step 3-1 and the information obtained during the fuzz testing process to determine the priority of the seed delivery symbolic execution; Step 3-3: Based on the seeds calculated in step 3-2, use the priority queue PrioQueue to maintain the order of these seeds from high to low priority; the coordinator retrieves the seeds in order according to the priority and sends them to the symbolic executor; Step 4: Symbolic execution: Get seeds from the coordinator according to the exploration potential from high to low, and perform symbolic execution.

2. The seed exploration potential-guided hybrid fuzzy testing method according to claim 1, characterized in that: The preprocessing and static analysis steps include the following sub-steps: Step 1-1: Convert the source code of the program under test into LLVM bytecode file, and export the intra-procedural control flow graph CFG and inter-procedural control flow graph iCGF information; Step 1-2: Extract the branch and reachable basic block mapping information file Branch-ReachableBB in the control flow graph according to the bytecode file in step 1-1; Step 1-3: Insert coverage collection logic and runtime seed coverage relationship monitoring code into the bytecode file obtained in step 1-1.

3. The seed exploration potential-guided hybrid fuzzy testing method according to claim 1, characterized in that: The fuzz testing procedure includes the following sub-steps: Step 2-1: Configure fuzz testing strategy; Step 2-2: Fuzz test initialization; the fuzz tester uses the initial seed to test the program under test, and collects the coverage information of the program in real time according to the coverage collection component of the fuzz tester; by analyzing the coverage information, high-value initial seeds are identified; high-value initial seeds will be saved in the seed queue Queue as input for the subsequent mutation process; Step 2-3: Fuzz test is officially run; the seeds in the seed queue specified in step 2-2 are mutated in turn using the specified mutation strategy and transmitted to the program under test; if the program runs overtime or an exception occurs, the relevant information is recorded and stored in the corresponding directory; for seeds that run normally, their coverage information is collected; if the mutated seeds increase the program coverage, they are regarded as high-value seeds and saved in the seed queue; for seeds generated after mutation that do not increase the program coverage, no subsequent processing is performed and they are directly discarded; after each batch, the new high-value seed sequence will be used as the candidate seed of the coordinator; then, the seeds of the next batch are selected to continue mutation and testing; this step will continue until the predetermined stop condition is reached, such as the maximum number of iterations or the specified test time; Step 2-4: Fuzz test seed-branch relationship extraction, record the coverage information trace of the seed run in step 2-3 and the correspondence between the branches in CFG.

4. The seed exploration potential-guided hybrid fuzzy testing method according to claim 1, characterized in that: Step 3-2 is divided into two stages: branch potential assessment and seed priority assessment.

5. The seed exploration potential-guided hybrid fuzzy testing method according to claim 4 is characterized in that: The step 3-2 includes the following sub-steps: Step 3-2-1: Static program definition and extraction; Based on the information obtained from static analysis, the number of basic blocks that branches can reach is statically calculated according to the control flow graph (CFG) of the program. i And the distance between the branch and the root node Depth i As the basis for static branch potential evaluation; the static potential evaluation score_static of branch i is calculated i , calculated as Step 3-2-2: Dynamic test runtime information definition and extraction; Based on the information obtained during the fuzz testing process, obtain branch i and its sibling branch sib i At this point, the coverage of the specified branch i and its sibling branch sib during the fuzz testing process is measured by the indicator DHC i The difference in coverage between The branches whose DHC values ​​are greater than the specified threshold θ are added as candidate branches to the candidate branch set brSet to narrow the selection range. This set is updated after each fuzz test iteration. The dynamic potential of branch i is evaluated as score_dynamic i , calculated as ST i Indicates the number of times the constraint corresponding to branch i is solved during symbolic execution; Step 3-2-3: Branch potential evaluation algorithm; use the static potential evaluation of step 3-2-1 and the dynamic potential evaluation of step 3-2-2 to obtain the branch potential evaluation: br_score i =α×soce_static i +β×score_dynamic i ; According to br_scoree, brSet is sorted from high to low according to branch potential to obtain a set of high-potential candidate branches; Step 3-2-4: Seed priority evaluation: Based on the coverage information trace of the seed run and the branch correspondence file Trace-Branch in CFG, evaluate the score corresponding to the branch covered by each seed; If the branches covered by the seed include branches in the high potential candidate branch set brSet, the exploration potential score of seed j is obtained by accumulating the potential evaluation scores of these branches: This score determines the priority with which this seed is used for symbolic execution.

6. The seed exploration potential-guided hybrid fuzzy testing method according to any one of claims 1 to 5, characterized in that: The symbolic execution phase includes the following steps: Step 4-1: Get seeds from the coordinator according to the exploration potential from high to low, and perform dynamic symbolic execution; Step 4-2: Obtain the new seeds generated after each run of the symbolic executor, and hand them over to the coordinator to evaluate the coverage of its high-potential candidate branches and calculate its coverage gain.

7. The seed exploration potential-guided hybrid fuzzy testing method according to claim 6, characterized in that: The coordination and seed scheduling phase also includes: Step 3-4: Seed synchronization mechanism; after each round of symbolic execution, the coordinator evaluates the newly generated seeds of the symbolic executor, selects the appropriate seeds according to the selection strategy, and synchronizes them to the fuzz tester through the coordinator.

8. The seed exploration potential-guided hybrid fuzzy testing method according to claim 7, characterized in that: The selection strategy is defined as: if these seeds cover high potential candidate branches and the total coverage gain is greater than the specified threshold, these seeds are synchronously sent to the sync directory of the fuzz tester, and these seeds are recorded as sync seeds.

Citation Information

Cited By

  • Interactive visualization method, device and equipment for fuzz test bottleneck breakthrough

    CN119248650A