Network program state variable positioning and inferring method and system based on key obstacle point analysis

Through the analysis method of key obstacle points, the problem of inaccurate state representation and high false alarm rate in fuzzy test is solved, the accuracy of network program state capture and state transfer coverage of fuzzy test is improved, and efficient state sensitive scheduling test is realized .

CN119046145APending Publication Date: 2024-11-29Chinese People's Liberation Army Cyberspace Force Information Engineering University
View PDF 0 Cites 2 Cited by

Patent Information

Application Number
CN202411058793.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-08-02
Publication Date
2024-11-29

AI Technical Summary

Technical Problem

In the existing fuzz testing technology, the state representation is inaccurate and the false positive rate of state variable extraction is high, which makes it difficult to accurately represent the state transfer model and lacks guidance for the expected state transfer model.

Method used

Using a method based on key obstacle point analysis, we use test cases to determine obstacle points in the execution path, evaluate the importance of obstacle points, narrow the search space of state variables, and build a state model to infer state transfer.

Benefits of technology

The capture accuracy of network program state and the state transition coverage of fuzzy testing are improved, and efficient state sensitive scheduling testing is achieved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119046145A_ABST
    Figure CN119046145A_ABST
Patent Text Reader

Abstract

The invention provides a network program state variable positioning and deducing method and system based on key obstacle point analysis. The method comprises the following steps: performing fuzzy testing on a target network program by using a test case to determine an obstacle point encountered in an execution path; the obstacle points refer to nodes located on the boundary of the coverage area in the CFG of the target network program; positioning an initial search space of the state variable by using the obstacle point; evaluating the importance of all the obstacle points, and selecting the obstacle point with a relatively high importance score as a key obstacle point; reducing an initial search space of a state variable based on the key obstacle point to determine a final search space, and positioning the state variable from the final search space according to state variable characteristics; and analyzing a flow direction relationship between different values of the state variable to construct a state model, and performing state transition inference based on the state model.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, and in particular to a method and system for locating and inferring network program state variables based on key obstacle point analysis. Background Art

[0002] The current mainstream gray-box protocol fuzz testing technology introduces state feedback to guide the testing of deep-level code, thereby improving the lack of execution feedback limitations of black-box fuzz testing and the low efficiency of gray-box fuzz testing due to lack of state perception. Common mainstream tools include AFLNET, SnapFuzz, StateAFL, and SGFuzz. Existing research uses response codes, memory hashes, or state variables to construct state models for testing, but these methods have problems such as inaccurate state representation or high false positive rate of state variable extraction, which are specifically manifested in the following aspects: (1) The transition model is difficult to accurately represent the protocol implementation state space, resulting in redundant state transfer; (2) The state transfer depends on the test execution process, which is highly random and lacks the guidance of the expected state transfer model. Summary of the invention

[0003] In view of the problem that the state model constructed in the existing fuzzy testing scheme has inaccurate state representation or high false alarm rate of state variable extraction, the present invention provides a network program state variable positioning and inference method and system based on key obstacle point analysis.

[0004] On the one hand, the present invention provides a method for locating and inferring network program state variables based on key obstacle point analysis, comprising:

[0005] Step 1: Use the test case to perform fuzz testing on the target network program to determine the obstacle points encountered in the execution path; the obstacle points refer to the nodes located on the boundary of the coverage area in the CFG of the target network program;

[0006] Step 2: Use the obstacle points to locate the initial search space of the state variables;

[0007] Step 3: Evaluate the importance of all obstacles and select the obstacles with higher importance scores as key obstacles;

[0008] Step 4: narrowing the initial search space of the state variable based on the key obstacle point to determine the final search space, and locating the state variable from the final search space according to the state variable characteristics;

[0009] Step 5: Analyze the flow relationship between different values ​​of the state variable to build a state model, and perform state transition inference based on the state model.

[0010] Furthermore, step 1 specifically includes:

[0011] After fuzz testing the target network program using the test case, collect coverage information;

[0012] According to the coverage information, all nodes in the CFG of the target network program are divided into an unvisited node set and a visited node set;

[0013] For each unvisited node in the unvisited node set, if its neighbor node is in the visited set, then the neighbor node is regarded as an obstacle point.

[0014] Furthermore, step 1 also includes: screening the obstacle points, specifically including:

[0015] Check whether there is an input s in the target network program. When executing input s, there is an execution path from obstacle point n to neighbor node m. If not, obstacle point n is a real obstacle point, otherwise it is not a real obstacle point, where m is an unvisited node.

[0016] Furthermore, step 2 specifically includes:

[0017] Backtrack the function call paths of all the obstacle points, find the common prefix of the function call paths of all the obstacle points, and use the last function call of the common prefix as the boundary function of the loop;

[0018] The first loop including the boundary function is used as a message processing loop, and the message processing loop is an initial search space for state variables.

[0019] Furthermore, in step 3, the importance of all obstacle points is evaluated based on Katz centrality.

[0020] Furthermore, in step 3, the importance of all obstacle points is evaluated based on Katz centrality and historical execution information; wherein the historical execution information includes the total number of executions of fuzz testing of the target network program and the number of times each obstacle point is covered in the fuzz testing.

[0021] Furthermore, in step 3, the importance of all obstacle points is evaluated according to the following formula:

[0022] S i =(1+U i / T)C i

[0023] Among them, S i represents the importance score of obstacle point i, U i represents the number of times obstacle point i is covered in the fuzz test, T represents the total number of executions of the fuzz test on the target network program, and C i Represents the Katz centrality of obstacle point i.

[0024] Furthermore, in step 5, the flow relationship between different values ​​of the state variable is analyzed to construct a state model, which specifically includes:

[0025] Each value of the state variable is regarded as a node in the state model to be constructed;

[0026] Expand the message processing loop, perform path reachability analysis on all assignment statements related to the state variable in the program after the loop is expanded to determine the flow relationship between different values ​​of the state variable, and use the directed flow relationship between different nodes as the directed edge in the state model to be constructed, and finally obtain the constructed state model.

[0027] On the other hand, the present invention provides a network program state variable location and inference system based on key obstacle point analysis, comprising:

[0028] The obstacle point location module is used to perform fuzzy testing on the target network program using test cases to determine the obstacle points encountered in the execution path; the obstacle points refer to nodes located on the boundary of the coverage area in the CFG of the target network program;

[0029] A state variable search space module is used to locate the initial search space of state variables using obstacle points;

[0030] The key obstacle point screening module is used to evaluate the importance of all obstacle points and select obstacle points with higher importance scores as key obstacle points;

[0031] A state variable positioning module, used to narrow down the initial search space of the state variable based on the key obstacle point to determine a final search space, and locate the state variable from the final search space according to the state variable characteristics;

[0032] The state variable inference module is used to analyze the flow relationship between different values ​​of the state variable to build a state model, and perform state transition inference based on the state model.

[0033] Beneficial effects of the present invention:

[0034] (1) The present invention collects obstacle points and determines the initial search space of state variables during the initial test process. Then, the key obstacle points and the characteristics of state variables in controlling program execution are utilized. On the basis of the initial search space, the search space of state variables is further reduced and the state variables are located. Finally, by tracking these state variables, the state and state transition of the target network service program are captured, thereby improving the accuracy of capturing the network program state.

[0035] (2) The present invention proposes a state variable location and inference method, which uses path-sensitive reachability analysis to construct an efficient state model, realizes state-sensitive scheduling test optimization, solves the problem of identifying state transition relationships, and can assist fuzzy testing based on state transitions to improve the state transition coverage during fuzzy testing. BRIEF DESCRIPTION OF THE DRAWINGS

[0036] Figure 1 One of the flow charts of a method for locating and inferring state variables of a network program based on key obstacle point analysis provided by an embodiment of the present invention;

[0037] Figure 2 A second flow chart of a method for locating and inferring state variables of a network program based on key obstacle point analysis provided by an embodiment of the present invention;

[0038] Figure 3 A schematic diagram of the process of constructing a state model provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0039] In order to make the purpose, technical solution and advantages of the present invention clearer, the technical solution in the embodiment of the present invention will be clearly described below in conjunction with the drawings in the embodiment of the present invention. Obviously, the described embodiment is a part of the embodiment of the present invention, not all 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] like Figure 1 As shown, an embodiment of the present invention provides a method for locating and inferring network program state variables based on key obstacle point analysis, comprising the following steps:

[0041] S101: Perform fuzz testing on the target network program using a test case to determine an obstacle point encountered in the execution path; the obstacle point refers to a node located on the boundary of the coverage area in the CFG of the target network program;

[0042] S102: using the obstacle point to locate the initial search space of the state variable;

[0043] S103: Evaluate the importance of all obstacle points, and select obstacle points with higher importance scores as key obstacle points;

[0044] S104: narrowing down the initial search space of the state variable based on the key obstacle point to determine a final search space, and locating the state variable from the final search space according to the state variable characteristics;

[0045] S105: Analyze the flow relationship between different values ​​of the state variable to construct a state model, and perform state transition inference based on the state model.

[0046] The network program state variable positioning and inference method based on key obstacle point analysis provided by the embodiment of the present invention collects obstacle points and determines the initial search space of state variables during the initial testing process, and then uses the characteristics of key obstacle points and state variables to control program execution. On the basis of the initial search space, the search space of state variables is further reduced and the state variables are located. Finally, by tracking these state variables, the state and state transfer of the target network service program are captured, thereby improving the accuracy of capturing the network program state.

[0047] like Figure 2 As shown, in one embodiment, the following method is used to discover the obstacle points in the target network program during the stage testing process: after fuzz testing the target network program using test cases, coverage information is collected; all nodes in the CFG of the target network program are divided into an unvisited node set and a visited node set according to the coverage information; for each unvisited node in the unvisited node set, if its neighbor node is in the visited set, the neighbor node is used as an obstacle point.

[0048] It can be understood that coverage information refers to the execution of each basic block (i.e., node in CFG) in the target network program with the test case as input; specifically, if the execution path of the test case can reach a certain node, the node is said to be covered (or visited), otherwise, the node is said to be uncovered (or unvisited). Based on the definition of obstacle points, if the set of visited nodes is recorded as V, the set of unvisited nodes is recorded as U, and the set of obstacle points is recorded as H, the process of discovering obstacle points can be formalized as follows:

[0049]

[0050] H={u|v∈V,u∈U,v.parent==u}

[0051] Among them, S represents the target network program, s represents any program code in the target network program, CFG represents the control flow graph of the target network program, n represents any node in CFG, V_node represents a node in the set V, ﹁ represents the logical conjunction "not", and v.parent represents the neighbor node of node v. In other words, if a node u itself has been covered, but one or more nodes directly adjacent to the node have not been covered, then the node u is recorded as an obstacle point.

[0052] It should be noted that the obstacle points in the above-discovered obstacle point set may not be real obstacle points. Therefore, further, the obstacle points in the above-discovered obstacle point set H may be preliminarily screened. The process is as follows:

[0053] Check whether there is an input s in the target network program. When executing input s, there is an execution path from the obstacle point n to the adjacent node m. If not, the obstacle point n is a real obstacle point. Otherwise, it will be deleted from the obstacle point set H.

[0054] like Figure 2 As shown, in one embodiment, in order to determine the scope of the state variable, an obstacle point is used to locate the specific interval (also called the initial search space) where the state variable should be located, specifically including: backtracking the function call path of all obstacle points, finding the common prefix of the function call path of all obstacle points, and taking the last function call of the common prefix as the boundary function of the loop; taking the first loop containing the boundary function as the message processing loop, and the message processing loop is the initial search space of the state variable.

[0055] like Figure 2 As shown, in one embodiment, the importance of all obstacle points is evaluated based on Katz centrality.

[0056] It can be understood that if the Katz centrality score of a certain obstacle point is higher, it means that the importance score of the obstacle point is higher.

[0057] Specifically, suppose there are n nodes in a message processing loop, let A be an n×n adjacency matrix of a graph structure with n nodes; if there is an edge connecting node i to node j in the graph structure, then the element A in the matrix A is ij =1, otherwise, A ij = 0. Let C represent the Katz centrality vector of size n. Assuming that node i is an obstacle point, the Katz centrality vector C corresponding to the obstacle point is i The definition is as follows:

[0058]

[0059] Katz centrality has two main parameters: α is used to control the relative importance of direct and indirect relationships. The larger the value, the greater the contribution of indirect relationships to centrality. When α is 0, only direct relationships are considered to calculate degree centrality. As α increases, more indirect relationships at longer distances are gradually considered. β is used to control the degree of influence of relationship distance. The smaller the value, the faster the influence of long-distance relationships will decrease, and as the relationship distance increases, the relationship weight will decay to 0 faster.

[0060] When formula (1) is solved in matrix form, the inverse matrix needs to be solved linearly. However, in large graph structures, calculating the inverse of the matrix is ​​very expensive. In practical applications, a power iteration method is used to approximate C based on the following equation. The power iteration method uses the following formula to calculate the tth iteration.

[0061] C(t)=αAC(t-1)+β

[0062] Furthermore, in one embodiment, in order to more accurately evaluate the importance of the obstacle points, the importance score of the obstacle points is further optimized using the historical execution information, that is, the importance of all obstacle points is evaluated by combining the Katz centrality and the historical execution information. As an implementable method, the calculation formula is as follows:

[0063] S i =(1+U i / T)C i

[0064] Among them, S i represents the importance score of obstacle point i, U i represents the number of times obstacle point i is covered in the fuzz test, T represents the total number of executions of the fuzz test on the target network program, and C i Represents the Katz centrality of obstacle point i.

[0065] It can be understood that the more times the obstacle point is covered, the more important the obstacle point is, and the more likely it is to control program execution. This method is used to score and evaluate the selected obstacle points, and the obstacle points with higher scores are taken as key obstacle points, and then the state variables are located based on the key obstacle points to reduce the search space of the state variables.

[0066] like Figure 3 As shown, in one embodiment, the following method is used to analyze the flow relationship between different values ​​of the state variable to construct a state model, specifically including: taking each value of the state variable as a node in the state model to be constructed; expanding the message processing loop, and performing path reachability analysis on all assignment statements related to the state variable in the program after the loop is expanded to determine the flow relationship between different values ​​of the state variable, and the directed flow relationship between different nodes is taken as the directed edge in the state model to be constructed, and finally a constructed state model is obtained.

[0067] It can be understood that state variables usually take finite integer values, which are represented by enumeration values ​​or macro definitions, that is, the state variables are assigned directly using macro identifiers. Therefore, when the state variables are known, their values ​​can be directly tracked using program analysis to determine their value range. Summarize all assignment statements for state variables, use static code analysis tools to automate the tracking process, find the definition points and usage points of the assigned variables, and determine the final value of the state variables by analyzing the logical path of the code and the variable assignment statements.

[0068] The state variables reflect the various states of the program execution process through their different values, and these values ​​form different nodes in the state model. The key to building a state model is to clearly describe the transfer relationship between these state nodes.

[0069] This embodiment determines whether there is a directionality between the values ​​of different state variables, thereby determining whether the corresponding states have a potential transition relationship. In addition, the position of the successfully inferred state transition is recorded at the same time to assist the fuzzy test based on state transition, such as Figure 2 Therefore, the present invention can provide important guidance for fuzzy testing based on unknown state transition coverage.

[0070] 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 make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. A network program state variable location and inference method based on key obstacle point analysis, characterized in that: include: Step 1: Use test cases to perform fuzz testing on the target network program to determine the obstacles encountered in the execution path; The obstacle point refers to a node located on the boundary of the coverage area in the CFG of the target network program; Step 2: Use the obstacle points to locate the initial search space of the state variables; Step 3: Evaluate the importance of all obstacles and select the obstacles with higher importance scores as key obstacles; Step 4: narrowing the initial search space of the state variable based on the key obstacle point to determine the final search space, and locating the state variable from the final search space according to the state variable characteristics; Step 5: Analyze the flow relationship between different values ​​of the state variable to build a state model, and perform state transition inference based on the state model.

2. According to the method of claim 1, the method of locating and inferring network program state variables based on key obstacle point analysis is characterized in that: Step 1 specifically includes: After fuzz testing the target network program using the test case, collect coverage information; According to the coverage information, all nodes in the CFG of the target network program are divided into an unvisited node set and a visited node set; For each unvisited node in the unvisited node set, if its neighbor node is in the visited set, then the neighbor node is regarded as an obstacle point.

3. A method for locating and inferring network program state variables based on key obstacle point analysis according to claim 2, characterized in that: Step 1 also includes: screening of obstacle points, including: Check whether there is an input s in the target network program. When executing input s, there is an execution path from obstacle point n to neighbor node m. If not, obstacle point n is a real obstacle point, otherwise it is not a real obstacle point, where m is an unvisited node.

4. The method for locating and inferring network program state variables based on key obstacle point analysis according to claim 1, characterized in that: Step 2 specifically includes: Backtrack the function call paths of all the obstacle points, find the common prefix of the function call paths of all the obstacle points, and use the last function call of the common prefix as the boundary function of the loop; The first loop including the boundary function is used as a message processing loop, and the message processing loop is an initial search space for state variables.

5. The method for locating and inferring network program state variables based on key obstacle point analysis according to claim 1, characterized in that: In step 3, the importance of all obstacle points is evaluated based on Katz centrality.

6. A method for locating and inferring network program state variables based on key obstacle point analysis according to claim 1, characterized in that: In step 3, the importance of all obstacle points is evaluated based on Katz centrality and historical execution information; wherein the historical execution information includes the total number of executions of fuzz testing of the target network program and the number of times each obstacle point is covered in the fuzz testing.

7. A method for locating and inferring network program state variables based on key obstacle point analysis according to claim 6, characterized in that: In step 3, the importance of all obstacle points is evaluated according to the following formula: S i =(1+U i / T)C i Among them, S i represents the importance score of obstacle point i, U i represents the number of times obstacle point i is covered in the fuzz test, T represents the total number of executions of the fuzz test on the target network program, and C i Represents the Katz centrality of obstacle point i.

8. A method for locating and inferring network program state variables based on key obstacle point analysis according to claim 4, characterized in that: In step 5, the flow relationship between different values ​​of the state variables is analyzed to construct a state model, which specifically includes: Each value of the state variable is regarded as a node in the state model to be constructed; Expand the message processing loop, perform path reachability analysis on all assignment statements related to the state variable in the program after the loop is expanded to determine the flow relationship between different values ​​of the state variable, and use the directed flow relationship between different nodes as the directed edge in the state model to be constructed, and finally obtain the constructed state model.

9. A network program state variable location and inference system based on key obstacle point analysis, characterized in that: include: The obstacle point location module is used to perform fuzz testing on the target network program using test cases to determine the obstacle points encountered in the execution path; The obstacle point refers to a node located on the boundary of the coverage area in the CFG of the target network program; A state variable search space module is used to locate the initial search space of state variables using obstacle points; The key obstacle point screening module is used to evaluate the importance of all obstacle points and select obstacle points with higher importance scores as key obstacle points; A state variable positioning module, used to narrow down the initial search space of the state variable based on the key obstacle point to determine a final search space, and locate the state variable from the final search space according to the state variable characteristics; The state variable inference module is used to analyze the flow relationship between different values ​​of the state variable to build a state model, and perform state transition inference based on the state model.

Citation Information

Cited By

  • Computer network security software debugging method and system

    CN120145379A

  • A computer network security software debugging method and system

    CN120145379B