Defect key path point extraction method and device based on triggering data taint inference
Through the method of triggering data stain inference, the critical path points of defects are extracted, which solves the problem of insufficient attention to defect causes by the directional fuzzy testing method, realizes timely discovery and deep logical understanding of regional reproduction defects, and provides a In-depth analysis.
Patent Information
- Application Number
- CN202411042561.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-31
- Publication Date
- 2024-11-08
Smart Images

Figure CN118916286A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of network security technology, and in particular to a method and device for extracting defect key path points based on trigger data stain inference. Background Art
[0002] There is a certain probability that the code module where the defects that have been exposed and fixed in the past are located will have security defects again, which is called regional reproduction defects. Because some developers debug based on the stack trace information when the program crashes when fixing the defects, they only impose surface restrictions on the variables that cause the crash, such as constraining the variable length, to prevent the program from crashing. However, this approach does not deeply explore and analyze the causes of the defects, and fails to thoroughly understand the deep logic and data flow characteristics of the defects. Existing directed fuzz testing methods do not pay enough attention to the defect evolution process and causes, and it is difficult to mine regional reproduction defects. Existing fuzz testing methods lack attention to the introduction and repair process of defects and the causes of defects. The mining of regional reproduction defects lacks clue guidance methods combined with historical defect cause analysis, which makes it difficult to be discovered in time. Summary of the invention
[0003] Aiming at the problem that existing directed fuzz testing methods lack attention to the causes and evolution processes of defects and are difficult to discover regional recurrence defects, the present invention proposes a defect key path point extraction method and device based on trigger data taint inference, which guides the generation of crash test cases and non-crash test cases similar to the execution path of historical defect PoC (vulnerability verification program) through grouped taint inference, analyzes the execution path differences between the two groups of test cases and calculates the defect correlation score of the code in the execution path, obtains the key path points of the defect cause, and provides clues and guidance for directed fuzz testing.
[0004] In order to achieve the above object, the present invention adopts the following technical solutions:
[0005] On the one hand, the present invention proposes a method for extracting key defect path points based on trigger data stain inference, comprising:
[0006] Step 1: Collect the defect trigger PoC and the source code of the corresponding version corresponding to the historical defects, use binary instrumentation to track the execution of test cases, and record whether the test cases trigger the program crash state;
[0007] Step 2: For each historical defect, take the PoC corresponding to each defect as the initial seed set, use byte taint inference to identify and fix the key bytes related to the crash path, mutate other bytes, and obtain a set of test suites containing crash test cases and non-crash test cases;
[0008] Step 3: Execute the test cases in the test suite in the original program, collect crash and non-crash path information, calculate the defect relevance score at the code line granularity, and retain the program code with a higher relevance score as the historical defect key path point.
[0009] Furthermore, in step 2, the relationships identified by the byte taint inference include variable dependencies and branch dependencies.
[0010] Furthermore, in step 3, the defect relevance score at the code line granularity is calculated in the following manner:
[0011]
[0012] Where Vulnerability_score represents the branch point b i Defect relevance score, #(X i =1ΛC=1) represents the number of test cases that observed bi and triggered defects, #(X i =0ΛC=0) represents the number of test cases where bi is not observed and no defects are triggered, #(C=1) represents the number of test cases that trigger defects, and #(C=0) represents the number of test cases that do not trigger defects.
[0013] Furthermore, in the step 3, before calculating the defect correlation score at the code line granularity, the following is further included:
[0014] Remove duplicate execution paths.
[0015] Another aspect of the present invention provides a device for extracting defect key path points based on trigger data stain inference, comprising:
[0016] The execution path tracking module is used to collect the defect triggering PoC and the corresponding version of the source code corresponding to the historical defects, use binary stubs to track the execution of test cases, and record whether the test cases trigger the program crash state;
[0017] The taint inference module is used to identify and fix the key bytes related to the crash path for each historical defect, and mutate other bytes to obtain a set of test suites including crash test cases and non-crash test cases.
[0018] The defect key path point extraction module is used to execute the test cases in the test suite in the original program, collect crash and non-crash path information, calculate the defect correlation score at the code line granularity, and retain the program code with a higher correlation score as the historical defect key path point.
[0019] Furthermore, in the taint inference module, the relationships identified by the byte taint inference include variable dependencies and branch dependencies.
[0020] Furthermore, in the defect key path point extraction module, the defect correlation score at the code line granularity is calculated in the following manner:
[0021]
[0022] Where Vulnerability_score represents the branch point b i Defect relevance score, #(X i =1ΛC=1) represents the number of test cases that observed bi and triggered defects, #(X i =0ΛC=0) represents the number of test cases where bi is not observed and no defects are triggered, #(C=1) represents the number of test cases that trigger defects, and #(C=0) represents the number of test cases that do not trigger defects.
[0023] Furthermore, in the defect key path point extraction module, before calculating the defect correlation score at the code line granularity, it also includes:
[0024] Remove duplicate execution paths.
[0025] Compared with the prior art, the present invention has the following beneficial effects:
[0026] The cause exists in deeper program logic, and the conventional test cases generated by fuzz testing may deviate from the execution path of PoC early, and the deep path cannot be observed. The present invention uses taint inference to fix the bytes related to the control flow at the front end of the path sequence, and can mutate on the premise of reaching a deeper position in the trigger path sequence, to obtain crash test cases and non-crash test cases similar to the execution path of historical defect trigger data. Further, by effectively analyzing the execution path differences of the test cases and calculating the defect correlation scores of the codes in the execution path, the key path points of the defect cause are obtained, and on this basis, it is conducive to the extraction of defect clues. BRIEF DESCRIPTION OF THE DRAWINGS
[0027] Figure 1 A flowchart of a defect key path point extraction method based on trigger data stain inference according to an embodiment of the present invention;
[0028] Figure 2 An algorithm pseudo code for generating crash path related test cases based on taint inference according to an embodiment of the present invention;
[0029] Figure 3 This is an example diagram of defect correlation scoring in an embodiment of the present invention;
[0030] Figure 4The present invention is a schematic diagram of the structure of a device for extracting critical defect path points based on trigger data stain inference according to an embodiment of the present invention. DETAILED DESCRIPTION
[0031] The present invention will be further explained below with reference to the accompanying drawings and specific embodiments:
[0032] like Figure 1 As shown, a defect key path point extraction method based on trigger data stain inference includes:
[0033] First, we collect the defect triggering PoC and the corresponding version of the source code corresponding to the historical defects, and use the current advanced lightweight binary instrumentation tool to perform binary instrumentation on the program to facilitate dynamic tracking of test case execution. We track the execution of test cases, monitor the program memory information, and record whether the test case triggers the program crash state.
[0034] Then, the cause analysis is performed on each historical defect in turn. The PoC corresponding to each defect is used as the initial seed set. Multi-byte taint inference is used to identify and fix the key bytes related to the crash path, and other bytes are mutated to obtain a set of test suites containing crash test cases and non-crash test cases.
[0035] Finally, the test cases in the test suite are executed in the original program, the crash and non-crash path information (including crash instructions and non-crash instructions) is collected, the defect correlation score at the code line granularity is calculated, and the program code with a high correlation score (such as more than 0.9) is retained as the historical defect key path point.
[0036] The method specifically includes:
[0037] 1. Generation of crash path related test cases based on taint inference
[0038] (Program execution path corresponding to the defect trigger input) ordered sequence T = {t1, t2, ..., t i} Input I for program P to execute crash poc This path specifically records all branch decision points from the start of program execution to the crash (or completion of execution).
[0039] Cause analysis requires that the generated test cases fit the path of the crash trigger data PoC until t j-1 , for t j-1 The subsequent paths can be mutated. However, t j-1 and t j It may appear in deeper program paths. Conventional test cases generated by fuzz testing may appear in t j-1 The execution path of the PoC was deviated before, and t j-1If we can fix all the influences {t1,...,t j-1} to the corresponding value in the defect trace, then any mutation made to the remaining bytes will generate a j-1 The test case of the previous predecessor path needs to record the relationship between each branch condition and input data through the taint inference method.
[0040] Based on i PoC Mutation generation test suite, random mutation may cause the program to j I was offset before PoC If we can fix all the defects affecting {t1,...,t j-1} to the corresponding value in the defect trace, then any mutation made to the remaining bytes will generate a new test case, which is likely to satisfy t j Specifically, if the input i∈I contains q bytes, each byte is represented by s k (k∈{1,2,...,q}). This method tracks the different input bytes for each t j The effect of monitoring input bytes s k With t j Whether there is a taint inference relationship (Taintinference) between them, the taint inference relationship includes variable dependency and branch dependency.
[0041] The pseudo code of the algorithm for generating crash path related test cases based on taint inference is as follows: Figure 2 As shown, the crash test case i PoC As the initial input, a set of test cases are generated by fuzz testing, starting from t1 to explore each t j , in each loop iteration, confirm that the program reaches t j-1 After that, fix and reach t j-1 The control flow related bytes remain unchanged, ensuring that the test case is executed to t j-1 , continue to randomly mutate other bytes and continue to explore and observe t j-1 After that, t can or cannot be observed j different paths to obtain enough observations of event Y j =1 and Y j =0 test case.
[0042] 2. Extraction of critical path points based on defect correlation
[0043] After the defect-related test cases are generated, the different branch points b i In the correlation evaluation, the output of the program is a binary classification, that is, triggered output and untriggered output. If the branch point b is executedi After the corresponding branch instance, a program defect is triggered, then b i The defect trigger output is predicted. The branch points that can accurately output all programs are high-quality branch points, that is, if there is a branch point b m , so that P(C=1|X m =1) =1(X m =1 indicates branch point b m is executed), that is, as long as b is executed m The corresponding branch instance can trigger the defect, but in the actual defect correlation analysis process, it is difficult to find a perfect branch point to predict all defect triggering outputs. Based on the test suite generated in the first part to count the defect correlation ranking of the code, first you need to delete the duplicate execution paths from the test suite to avoid affecting the weight of some execution paths. Then calculate each branch point b i First, calculate the following four indicators:
[0044] ①The number of test cases that observed bi and triggered defects (#(X i =1ΛC=1));
[0045] ②The number of test cases where bi was not observed and no defects were triggered (#(X i =0ΛC=0));
[0046] ③The number of test cases that trigger defects (#(C=1));
[0047] ④The number of test cases that did not trigger defects (#(C=0)).
[0048] Calculate the branch point b based on the above four indicators i Vulnerability relevance scores for:
[0049]
[0050] by Figure 3 b 127 As an example, the calculation process of defect correlation score is explained. (#(C=1)) is 932, (#(X i =1ΛC=1)) is 917, (#(C=0)) is 757, (#(X i =0ΛC=0)) is 51.
[0051] According to formula 1, we can calculate The defect relevance score Vulnerability_score is obtained as the weight of the corresponding code in the regional reproduction defect clue, sorted by weight, and the defect key points are extracted.
[0052] Based on the above embodiments, Figure 4As shown, the present invention also proposes a defect critical path point extraction device based on trigger data stain inference, comprising:
[0053] The execution path tracking module is used to collect the defect triggering PoC and the corresponding version of the source code corresponding to the historical defects, use binary stubs to track the execution of test cases, and record whether the test cases trigger the program crash state;
[0054] The taint inference module is used to identify and fix the key bytes related to the crash path for each historical defect, and mutate other bytes to obtain a set of test suites including crash test cases and non-crash test cases.
[0055] The defect key path point extraction module is used to execute the test cases in the test suite in the original program, collect crash and non-crash path information, calculate the defect correlation score at the code line granularity, and retain the program code with a higher correlation score as the historical defect key path point.
[0056] Furthermore, in the taint inference module, the relationships identified by the byte taint inference include variable dependencies and branch dependencies.
[0057] Furthermore, in the defect key path point extraction module, the defect correlation score at the code line granularity is calculated in the following manner:
[0058]
[0059] Where Vulnerability_score represents the branch point b i Defect relevance score, #(X i =1ΛC=1) represents the number of test cases that observed bi and triggered defects, #(X i =0ΛC=0) represents the number of test cases where bi is not observed and no defects are triggered, #(C=1) represents the number of test cases that trigger defects, and #(C=0) represents the number of test cases that do not trigger defects.
[0060] Furthermore, in the defect key path point extraction module, before calculating the defect correlation score at the code line granularity, it also includes:
[0061] Remove duplicate execution paths.
[0062] In summary, the present invention fixes the control flow related bytes through the method of group taint inference, thereby guiding the generation of crash test cases and non-crash test cases that are similar to the execution path of historical defect triggering data (such as PoC). Then, the indicators such as the number of crashes triggered and not triggered by the observed test cases are counted respectively, and the probability of correlation between the path (branch) points and the defect triggering is calculated, thereby obtaining the key path points of the defect cause. The present invention can discover regional reproduction defects and provide clues for guided fuzz testing.
[0063] The above is only a preferred embodiment of the present invention. It should be pointed out that a person skilled in the art can make several improvements and modifications without departing from the principle of the present invention. These improvements and modifications should also be regarded as within the scope of protection of the present invention.
Claims
1. A defect key path point extraction method based on trigger data stain inference, characterized in that: include: Step 1: Collect the defect trigger PoC and the source code of the corresponding version corresponding to the historical defects, use binary instrumentation to track the execution of test cases, and record whether the test cases trigger the program crash state; Step 2: For each historical defect, take the PoC corresponding to each defect as the initial seed set, use byte taint inference to identify and fix the key bytes related to the crash path, mutate other bytes, and obtain a set of test suites containing crash test cases and non-crash test cases; Step 3: Execute the test cases in the test suite in the original program, collect crash and non-crash path information, calculate the defect relevance score at the code line granularity, and retain the program code with a higher relevance score as the historical defect key path point.
2. According to the method for extracting defect key path points based on trigger data stain inference according to claim 1, it is characterized in that: In step 2, the relationships identified by the byte taint inference include variable dependencies and branch dependencies.
3. The defect key path point extraction method based on trigger data stain inference according to claim 1 is characterized in that: In step 3, the defect relevance score at the code line granularity is calculated in the following manner: Where Vulnerability_score represents the branch point b i Defect relevance score, #(X i =1ΛC=1) represents the number of test cases that observed bi and triggered defects, #(X i =0ΛC=0) represents the number of test cases where bi is not observed and no defects are triggered, #(C=1) represents the number of test cases that trigger defects, and #(C=0) represents the number of test cases that do not trigger defects.
4. The defect critical path point extraction method based on trigger data stain inference according to claim 1 is characterized in that: In the step 3, before calculating the defect relevance score at the code line granularity, the following is also included: Remove duplicate execution paths.
5. A defect key path point extraction device based on trigger data stain inference, characterized in that: include: The execution path tracking module is used to collect the defect triggering PoC and the corresponding version of the source code corresponding to the historical defects, use binary stubs to track the execution of test cases, and record whether the test cases trigger the program crash state; The taint inference module is used to identify and fix the key bytes related to the crash path for each historical defect, and mutate other bytes to obtain a set of test suites including crash test cases and non-crash test cases. The defect key path point extraction module is used to execute the test cases in the test suite in the original program, collect crash and non-crash path information, calculate the defect correlation score at the code line granularity, and retain the program code with a higher correlation score as the historical defect key path point.
6. The device for extracting defect key path points based on trigger data stain inference according to claim 5, characterized in that: In the taint inference module, the relationships identified by the byte taint inference include variable dependencies and branch dependencies.
7. The device for extracting defect key path points based on trigger data stain inference according to claim 5, characterized in that: In the defect key path point extraction module, the defect correlation score at the code line granularity is calculated in the following manner: Where Vulnerability_score represents the branch point b i Defect relevance score, #(X i =1ΛC=1) represents the number of test cases that observed bi and triggered defects, #(X i =0ΛC=0) represents the number of test cases where bi is not observed and no defects are triggered, #(C=1) represents the number of test cases that trigger defects, and #(C=0) represents the number of test cases that do not trigger defects.
8. The device for extracting defect key path points based on trigger data stain inference according to claim 5, characterized in that: In the defect key path point extraction module, before calculating the defect correlation score at the code line granularity, it also includes: Remove duplicate execution paths.
Citation Information
Cited By
Vulnerability cause positioning method based on data richness and migration cost perception
CN120805142A
A vulnerability cause localization method based on data richness and migration cost perception
CN120805142B
