A two-stage automatic vulnerability mining method for router firmware based on GNN and angr

By combining dynamic and static hybrid analysis methods with GNN and angr, the path explosion problem in router firmware vulnerability detection is solved, efficient and accurate vulnerability detection is achieved, and the automation level and performance of detection is improved.

CN118797658BActive Publication Date: 2024-11-29SOUTHWEST PETROLEUM UNIV
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411265189.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-09-10
Publication Date
2024-11-29
Estimated Expiration
2044-09-10

AI Technical Summary

Technical Problem

The prior art faces path explosion problems in router firmware vulnerability detection, resulting in huge resource consumption and inefficiency. GNN's performance and scalability need to be further optimized when processing large-scale firmware data.

Method used

The dual-stage automatic vulnerability mining method based on GNN and angr is adopted. The control flow graph (CFG) generated by angr is combined with the efficient graph data processing capabilities of GNN, and dynamic and static hybrid analysis is performed to improve the automation level and accuracy of vulnerability detection.

Benefits of technology

Through dynamic and static hybrid analysis methods, the accuracy and reliability of vulnerability detection are improved, the path explosion problem in traditional symbol execution is avoided, and the symbol execution strategy for MIPS and ARM type firmware is implemented.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118797658B_ABST
    Figure CN118797658B_ABST
Patent Text Reader

Abstract

The present invention relates to the field of computer security and network technology, and discloses a two-stage automatic vulnerability mining method for router firmware based on GNN and angr, including generating a control flow graph from the router firmware using a dynamic and static hybrid analysis tool; performing data conversion and data enhancement processing on the control flow graph; using a pre-trained graph neural network model to identify vulnerabilities in the processed control flow graph, and prioritizing program execution paths with vulnerabilities; based on the ranking results of program execution paths with vulnerabilities, using a dynamic and static hybrid analysis tool to perform symbolic execution on the program execution path to obtain a router firmware vulnerability mining result. The present invention improves the automation level and accuracy of vulnerability detection by combining angr's in-depth dynamic and static hybrid analysis capabilities with GNN's efficient graph data processing capabilities, and at the same time solves the path explosion problem encountered by traditional binary analysis tools when processing complex firmware.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer security and network technology, and in particular to a two-stage automatic vulnerability mining method for router firmware based on GNN and angr. Background Art

[0002] With the popularity of network devices and the key role of routers in daily life and business activities, the security of router firmware is particularly important. Security vulnerabilities in firmware may lead to serious information leakage and network attacks. Therefore, timely discovery and patching of these vulnerabilities is an important task in the field of network security.

[0003] Traditional vulnerability detection techniques, such as static analysis and symbolic execution, can detect vulnerabilities to a certain extent, but these methods often face multiple challenges. However, dynamic analysis is often plagued by the path explosion problem, that is, the number of potential execution paths is too large, resulting in huge resource consumption and low efficiency in the analysis process.

[0004] In order to overcome these problems, in recent years, research has begun to explore the use of graph neural networks (GNNs) to analyze CFGs generated by static analysis tools. GNNs can effectively process graph-structured data and improve the accuracy and efficiency of vulnerability identification by learning the complex relationships between nodes in the graph. The introduction of GNNs provides a new technical means for the automatic detection of firmware vulnerabilities, which can better understand and predict potential security issues in program behavior. However, the application of GNNs to firmware vulnerability detection still faces some technical challenges, including how to effectively extract features from CFGs, how to design a GNN architecture that is suitable for firmware analysis, and whether the analysis results are accurate. In addition, the performance and scalability of existing GNN models need to be further optimized when processing large-scale firmware data. Summary of the invention

[0005] In view of the above-mentioned deficiencies in the prior art, the present invention provides a two-stage automatic vulnerability mining method for router firmware based on GNN and angr. By combining angr's in-depth dynamic and static hybrid analysis capabilities and GNN's efficient graph data processing capabilities, the automation level and accuracy of vulnerability detection are improved, and the path explosion problem encountered by traditional binary analysis tools when processing complex firmware is solved. The dynamic and static hybrid analysis tool angr can generate a detailed control flow graph (CFG) to help analyze the behavior pattern of the software. angr's dynamic and static hybrid analysis cleverly combines the advantages of static analysis and dynamic analysis. At the static level, angr infers possible execution paths by analyzing the binary code of the program without actually running the program; at the dynamic level, it simulates program execution, tracks state changes, and uses runtime information. angr's symbolic execution engine allows the use of concrete values ​​and symbolic values ​​at the same time, and can flexibly switch between concrete execution and symbolic execution during the analysis process. This hybrid analysis method enables angr to fully explore multiple execution paths of a program without actually running the program, while using dynamic information to improve the accuracy and efficiency of the analysis, thereby achieving a deeper and more comprehensive program analysis.

[0006] In order to achieve the above-mentioned object of the invention, the technical solution adopted by the present invention is:

[0007] A two-stage automatic vulnerability mining method for router firmware based on GNN and angr, comprising the following steps:

[0008] Generate control flow graphs from router firmware using static analysis tools;

[0009] Perform data transformation and data enhancement on the control flow graph;

[0010] Use the pre-trained graph neural network model to identify vulnerabilities in the processed control flow graph and prioritize the program execution paths with vulnerabilities;

[0011] Based on the sorting results of program execution paths with vulnerabilities, the program execution paths are symbolically executed using dynamic and static hybrid analysis tools to obtain the router firmware vulnerability mining results.

[0012] Preferably, performing data conversion on the control flow graph includes:

[0013] Convert the control flow graph into JSON data format and record the instruction type and jump condition of each node and edge in the control flow graph.

[0014] Preferably, performing data enhancement processing on the control flow graph includes:

[0015] Randomly delete nodes in the control flow graph;

[0016] Randomly delete edges in the control flow graph;

[0017] Add new nodes and edges to the control flow graph, or modify the attribute information of existing nodes and edges.

[0018] Preferably, the priority sorting of program execution paths with vulnerabilities includes:

[0019] Calculate the path priority score of each node based on the priorities of different vulnerability categories and the predicted probability of vulnerability categories output by the graph neural network model;

[0020] The vulnerable program execution paths are prioritized according to the path priority score of each node.

[0021] Preferably, the path priority score of each node is calculated as follows:

[0022]

[0023] in, is the path priority score of node i, is the importance weight of vulnerability category c, is the predicted probability that node i belongs to vulnerability category c, is the total number of vulnerability categories.

[0024] Preferably, using a dynamic and static hybrid analysis tool to perform symbolic execution on a program execution path includes:

[0025] According to different vulnerability types, the detection logic and constraint conditions are optimized for the instruction sets, operation modes and register configurations under different architectures.

[0026] As a preferred method, when using a dynamic and static hybrid analysis tool to perform symbolic execution on the program execution path,

[0027] For buffer overflow vulnerabilities, the instruction characteristics of the ARM firmware architecture and the MIPS firmware architecture monitor write operations on the stack, monitor changes in specific registers to detect overflows caused by possible tampering of the return address, and verify whether the stack pointer points to a legitimate stack area.

[0028] As a preferred method, when using a dynamic and static hybrid analysis tool to perform symbolic execution on the program execution path,

[0029] For the permission bypass vulnerability, in the context of symbolic execution, it is detected that the permission check function returns a successful authorization flag even when the input parameters are tampered.

[0030] As a preferred method, when using a dynamic and static hybrid analysis tool to perform symbolic execution on the program execution path,

[0031] For command injection vulnerabilities, we detect whether external input affects the command execution logic and monitor the input calls to the system command execution function.

[0032] As a preferred method, when using a dynamic and static hybrid analysis tool to perform symbolic execution on the program execution path,

[0033] For use-after-free vulnerabilities, symbolic execution is used to monitor whether there are illegal references by tracking memory allocation and release events. The specific strategy is to mark the memory block as allocated after each memory allocation operation and mark the memory block as released after each memory release. For each memory access, the status of the relevant memory block is checked. If the access is to a released memory block, a UAF alarm is triggered.

[0034] The present invention has the following beneficial effects:

[0035] The GNN-based dynamic and static hybrid analysis method of the present invention obtains detailed program execution path information through the CFG generated by angr, further improves the generalization ability and prediction accuracy of the model through data preprocessing and enhancement technology, and conducts targeted model training and vulnerability classification in combination with data characteristics, thereby enhancing the accuracy of detection while maintaining high efficiency; the dynamic analysis method based on symbolic execution performs pruning according to the preliminary results of static analysis to avoid the path explosion problem in traditional symbolic execution, and implements the symbolic execution strategy for MIPS and ARM type firmware binary programs; through the combination of dynamic analysis and static analysis, the accuracy and reliability of router firmware vulnerability detection are comprehensively improved. BRIEF DESCRIPTION OF THE DRAWINGS

[0036] Figure 1 This is a flowchart of a two-stage automatic vulnerability mining method for router firmware based on GNN and angr. DETAILED DESCRIPTION

[0037] The specific implementation modes of the present invention are described below so that those skilled in the art can understand the present invention. However, it should be clear that the present invention is not limited to the scope of the specific implementation modes. For those of ordinary skill in the art, as long as various changes are within the spirit and scope of the present invention as defined and determined by the attached claims, these changes are obvious, and all inventions and creations utilizing the concept of the present invention are protected.

[0038] like Figure 1 As shown, an embodiment of the present invention provides a two-stage automatic vulnerability mining method for router firmware based on GNN and angr, comprising the following steps S1 to S4:

[0039] S1. Generate a control flow graph from the router firmware using static analysis tools;

[0040] In an optional embodiment of the present invention, step S1 uses a dynamic and static hybrid analysis tool angr to analyze the router firmware to construct a control flow graph (CFG), and the generated CFG data will serve as necessary input data for subsequent graph neural network (GNN) model training.

[0041] Compared with IDA Pro, Ghidra mainly relies on pure static analysis and may not be able to fully parse dynamically generated code or complex control structures. The dynamic and static hybrid analysis tool angr uses static analysis combined with symbolic execution technology when building CFG, which can dynamically parse indirect jumps and conditional branches, significantly improving the integrity and accuracy of CFG. After testing firmware of three different architectures, it was found that the dynamic and static hybrid analysis tool angr has a much higher parsing rate for effective execution paths than traditional tools.

[0042] S2, perform data conversion and data enhancement processing on the control flow graph;

[0043] In an optional embodiment of the present invention, step S1 of performing data conversion on the control flow graph includes:

[0044] Convert the control flow graph into JSON data format and record the instruction type and jump condition of each node and edge in the control flow graph.

[0045] Step S2 performs data enhancement processing on the control flow graph, including:

[0046] Randomly delete nodes in the control flow graph;

[0047] Randomly delete edges in the control flow graph;

[0048] Add new nodes and edges to the control flow graph, or modify the attribute information of existing nodes and edges.

[0049] Exemplarily, in order to convert the control flow graph (CFG) generated by angr into a data format more suitable for graph neural network (GNN) learning, this embodiment converts the CFG generated by angr into a JSON format with good flexibility and scalability. During the conversion process, detailed information of each node and edge, such as instruction type and jump condition, will be accurately recorded. In addition, in order to ensure the accuracy of subsequent control flow logic analysis of CFG, this embodiment retains the type information of the edge, such as direct call, indirect call and conditional branch. The following is a partial data diagram:

[0050] {"node_dict": {"4447556": {"node_name": "main", "node_label": "92", "insns": [[4447556, "lui", "$gp, 7"], [4447560, "addiu", "$gp, $gp, -0x744"]…}

[0051] In order to specifically train the GNN model's ability to mine router vulnerabilities, this embodiment mainly takes the following two measures for paths with known vulnerabilities: 1) Labeling known vulnerability paths: Labeling paths and functions with known vulnerabilities in CFG, providing additional contextual information, such as the types of vulnerabilities involved and related security warnings. 2) Adding path relevance features: For paths involving known vulnerabilities, this embodiment adds features such as path sensitivity identification, operation frequency on specific paths, and specific instruction usage to strengthen the weight of these paths in model training.

[0052] At the same time, in order to improve the efficiency of subsequent data processing, this embodiment will adopt the following strategies to appropriately simplify the graph structure: 1) Merge redundant nodes: merge basic block nodes with similar functions or repeated logic to reduce the size of the graph and reduce the computational burden of GNN. 2) Optimize edge connections: simplify edges that do not have a significant impact on the function, such as some loop jumps, and optimize the connectivity of the graph.

[0053] Since binary features in router firmware, such as instruction density and call frequency, may show large differences in numerical ranges in different firmwares, this embodiment uses Z-score normalization and takes corresponding measures to perform data enhancement to preprocess the data to ensure data quality and the generalization ability of the model. This embodiment eliminates the mean and standard deviation differences of feature data of different firmwares through Z-score normalization, avoiding the deviation caused by different feature scales during model training. At the same time, the standardized data has a unified scale, which helps to stabilize the model training process and improve learning efficiency. At the same time, the model has better generalization ability for new firmware samples that have not been seen. The Z-score normalization calculation formula is as follows:

[0054] in: is the original data value, is the mean of the feature, is the normalization of the feature, is the normalized value.

[0055] This embodiment enhances the feature expression capability of graph data through data preprocessing technology, including: 1) Simulating possible missing code paths or unexecuted functional blocks in the program by randomly deleting nodes in the graph to help the model learn how to effectively predict vulnerabilities in the presence of incomplete information. 2) By randomly deleting edges in the graph, it is possible to simulate situations where possible branches are not triggered during program execution, which not only enhances the program's understanding of different paths, but also improves the model's judgment ability when faced with abnormal control flow. 3) By adding new nodes and edges to the graph, or modifying the properties of existing nodes and edges, it is possible to simulate the state of the program after it has been updated or modified. This can help the model better understand and identify the manifestations of vulnerabilities after changes to the program structure or logic, especially new vulnerabilities that are accidentally introduced by patching old vulnerabilities.

[0056] S3. Use the pre-trained graph neural network model to identify vulnerabilities in the processed control flow graph and prioritize the program execution paths with vulnerabilities.

[0057] In an optional embodiment of the present invention, step S3 of prioritizing the program execution paths with vulnerabilities includes:

[0058] Calculate the path priority score of each node based on the priorities of different vulnerability categories and the predicted probability of vulnerability categories output by the graph neural network model;

[0059] The vulnerable program execution paths are prioritized according to the path priority score of each node.

[0060] For example, in the field of firmware security analysis, the effective use of control flow graphs (CFGs) is the key to identifying potential vulnerabilities. To achieve this, this embodiment uses graph neural networks (GNNs), especially graph convolutional networks (GCNs), which provide a new methodology for router firmware vulnerability mining with their excellent performance on graph structured data.

[0061] First, this embodiment defines a graph convolution layer, which uses the information propagation of the graph structure and updates the node features. The graph convolution operation is implemented in the following way:

[0062]

[0063] in, It is The node feature matrix of the layer, is the adjacency matrix with self-connection added , is the identity matrix. yes The degree matrix of Each element in (indicates the existence of an edge from node i to node j. i and j represent the node indexes in the graph, ranging from [1, n], where n is the total number of nodes). The corresponding element in , that is, the degree of node i, is calculated as . It is the first The weight matrix of the layer, is the non-linear activation function applied to this layer, such as ReLU.

[0064] At each layer, graph convolution operations achieve feature aggregation by integrating information from neighboring nodes, strengthening the model's perception of local graph patterns:

[0065]

[0066] in Is a node In the The feature vector of the layer, Representation Node The set of neighbor nodes of Indicates that when updating features, itself (i.e., the self-loop) and all its critical nodes, and The nodes are and The degree. It is The weight matrix of the layer, is a non-linear activation function, such as ReLU.

[0067] In order to extract the global information of the entire graph, this embodiment adopts the global average pooling technology (GAP). GAP extracts the global feature vector by calculating the weighted average of the features of all nodes in the graph. , this operation is defined as:

[0068]

[0069] in, Indicates that global average pooling is applied to the last layer of the graph neural network, which is done by weighted averaging the feature vectors of all nodes. represents the node matrix features of the last layer, Is a node The feature vector at the last layer, Is a node The attention coefficient of node The importance of n is the total number of nodes in the graph, indicating that the information of all these nodes is integrated in the calculation of the global eigenvector. A nonlinear activation function, such as LeRU, is applied to the weighted average to extract useful features for further analysis.

[0070] Finally, one or more fully connected layers are used to extract the global features of the graph. Predict the probability of each vulnerability existing.

[0071]

[0072] in and are the weights and biases of the fully connected layer, sofgmax is the normalization function to ensure that the vector The elements of are probability distributions.

[0073] Using the training data preprocessed in step S2, this embodiment starts training the GNN model to identify vulnerability features. During the training process, this embodiment uses a series of technologies to ensure the accuracy and stability of the model.

[0074] For model optimization, this embodiment uses the Adam optimizer because it can automatically adjust the learning rate when training deep learning models and effectively avoid local minima. The update rule of Adam is as follows:

[0075]

[0076] in, is the time step The value of represents a specific weight or bias of the model during training. This parameter is adjusted according to the gradient of the loss function relative to this parameter to improve the performance of the model. is the learning rate, which controls the magnitude of each update step. and They are the first-order (mean of the gradient) and second-order (unsquared mean of the gradient) moment estimates after bias correction, which are used to adjust the direction and size of each parameter update to make the update process smoother and more stable. is a small constant that prevents division by zero.

[0077] For model training, this embodiment is carried out in a supervised learning environment. The network parameters are gradually adjusted to minimize the prediction error. This process involves forward propagation and back propagation. In forward propagation, the features of the nodes are passed and updated through the graph convolution layer, and finally the feature representation for classification is output; in back propagation, the parameters are adjusted by calculating the gradient of the loss function relative to the network parameters, and the gradient descent method is used to optimize the network performance.

[0078] In order to alleviate the explosion problem of subsequent symbolic execution of the path, this embodiment designs a training algorithm to guide angr to analyze those paths that are more likely to have vulnerabilities through the prediction results of GNN. Specifically, this embodiment introduces the path priority score , calculated as follows:

[0079]

[0080] in Represents the total number of categories, that is, the number of vulnerability categories that the model needs to distinguish. Yes Category These weights reflect the priority of different categories in vulnerability detection, helping angr focus more on those categories with high risk or importance. Is a node Belongs to category The prediction probability is calculated by the GNN model based on node features and graph structure. Represents the node index in the graph, used to specify a specific path or node in symbolic execution.

[0081] To prevent overfitting, this embodiment uses both dropout technology and L2 regularization, and the regularized loss function The calculation of is as follows:

[0082]

[0083] in, is the original loss function, which measures the difference between the model prediction and the actual data. is a regularization parameter that controls the influence of the L2 penalty term. Represents the set of weights of all neural network layers. is the L2 norm (sum of squares) of the weights, which is used to penalize large weight values ​​to promote the generalization ability of the model.

[0084] After the GNN model is ready, the next step is to apply the model for accurate vulnerability detection and classification. Here, this embodiment defines the output of the GNN model as a vector , where each element represents the probability that a network node (i.e., a basic block in CFG) belongs to a certain vulnerability type. The total number of categories of vulnerability classification, ,in represents the set of real numbers, Each element of is a real number, whose value is between 0 and 1, representing the probability. The model output is converted into a probability distribution through the softmax function, so that the probability value of each category is:

[0085]

[0086] in, Is the node belongs to The original output score of . ,in , indicating that the original output score of the node belongs to each category score. is the total number of categories, which represents the total number of different types that the model needs to predict. Indicates that given node features, the node belongs to the category The node is classified into the class with the highest posterior probability:

[0087]

[0088] in is the class predicted by the model.

[0089] For the vulnerability detection part, first calculate the feature vector of each node from the data These features include instruction type, operands used, statistics of instruction sequence, etc. Then the feature vector is input into the trained GNN model to obtain the output vector of each node For probability analysis and classification, the softmax function is used to calculate the probability of each node belonging to each vulnerability category, and then the classification decision rule is applied to determine the vulnerability category of the node. Finally, the security assessment of the entire firmware is based on the detection results of a single CFG node. If any node is classified as having a vulnerability, the entire firmware is marked as having a security risk.

[0090] In order to comprehensively evaluate the performance of the model, the following evaluation indicators are defined:

[0091] Precision: measures the proportion of vulnerabilities identified by the model that are actually vulnerabilities:

[0092]

[0093] Recall: measures the proportion of vulnerabilities identified by the model to all actual vulnerabilities:

[0094]

[0095] Among them, TP stands for True Positive, which refers to the number of cases where the model correctly predicts the positive class. For example, the model predicts that a firmware with a vulnerability does contain a vulnerability. FP stands for False Positive, which refers to the number of cases where the model incorrectly predicts the positive class. FN stands for False Negative, which refers to the number of cases where the model incorrectly predicts the negative class.

[0096] F1 score: The harmonic average of precision and recall, an important indicator for measuring model accuracy:

[0097]

[0098] By calculating key indicators such as precision, recall, and F1 score, the model's performance on the labeled dataset is verified to help confirm whether the model has achieved the expected performance when it was designed.

[0099] Confusion Matrix: Provides an intuitive way to see how the model performs in various predictions:

[0100]

[0101] in are true negatives (correctly predicted non-vulnerable nodes).

[0102] Classification accuracy: indicates the proportion of correct predictions made by the model among all predictions:

[0103]

[0104] Micro-average: summing up the categories , , Post-calculation , which is suitable for cases with imbalanced categories.

[0105]

[0106] in, Indicates The true number of examples of the class, that is, the model correctly identifies The number of instances of the class. Indicates The number of false positive examples of the class, that is, the number of false positive examples incorrectly marked as Non-class The number of class instances. Indicates The number of false negatives for the class, i.e., the number of missed The number of class instances.

[0107] The model performance evaluation module ensures that the model maintains efficient and accurate vulnerability detection performance before and after actual deployment, while also ensuring that the system can adapt to future challenges and emerging vulnerabilities.

[0108] S4. Based on the ranking results of program execution paths with vulnerabilities, the program execution paths are symbolically executed using dynamic and static hybrid analysis tools to obtain the router firmware vulnerability mining results.

[0109] In an optional embodiment of the present invention, step S4 uses a dynamic and static hybrid analysis tool to perform symbolic execution on the program execution path, including:

[0110] According to different vulnerability types, the detection logic and constraint conditions are optimized for the instruction sets, operation modes and register configurations under different architectures.

[0111] Among them, when using dynamic and static hybrid analysis tools to perform symbolic execution on the program execution path,

[0112] For buffer overflow vulnerabilities, the instruction characteristics of the ARM firmware architecture and the MIPS firmware architecture monitor write operations on the stack, monitor changes in specific registers to detect overflows caused by possible tampering of the return address, and verify whether the stack pointer points to a legitimate stack area.

[0113] Among them, when using dynamic and static hybrid analysis tools to perform symbolic execution on the program execution path,

[0114] For the permission bypass vulnerability, in the context of symbolic execution, it is detected that the permission check function returns a successful authorization flag even when the input parameters are tampered.

[0115] Among them, when using dynamic and static hybrid analysis tools to perform symbolic execution on the program execution path,

[0116] For command injection vulnerabilities, we detect whether external input affects the command execution logic and monitor the input calls to the system command execution function.

[0117] Among them, when using dynamic and static hybrid analysis tools to perform symbolic execution on the program execution path,

[0118] For use-after-free vulnerabilities, symbolic execution is used to monitor whether there are illegal references by tracking memory allocation and release events. The specific strategy is to mark the memory block as allocated after each memory allocation operation and mark the memory block as released after each memory release. For each memory access, the status of the relevant memory block is checked. If the access is to a released memory block, a UAF alarm is triggered.

[0119] For example, combined with the prediction results of GNN, we use angr for symbolic execution to prioritize the paths that are more likely to contain vulnerabilities. Symbolic execution, as a dynamic program analysis technology, can execute all possible paths of the program and check for errors that may occur under different conditions. Compared with traditional static analysis, symbolic execution not only analyzes the code structure, but also simulates the specific behavior and data status during code execution. Combined with the prediction results of GNN, we can more specifically explore those high-risk and more likely to contain vulnerabilities paths, which can greatly improve the efficiency and accuracy of vulnerability detection.

[0120] In order to effectively discover vulnerabilities in router firmware, we have optimized the symbolic execution strategy for ARM and MIPS architectures. According to different vulnerability types, such as buffer overflow, permission bypass, command injection, etc., we have made adjustments based on the particularity of router firmware, especially the instruction set, operation mode and register configuration under different architectures:

[0121] 1) Buffer overflow vulnerability: Based on the instruction characteristics of ARM and MIPS, monitor the write operation to the stack and monitor the changes of specific registers such as $ra to find overflows caused by possible tampering of the return address. Verify whether the stack pointer, such as the SP register, points to a legal stack area. The logic diagram is as follows:

[0122]

[0123]

[0124] 2) Permission bypass: In the context of symbolic execution, the permission check function returns a successful authorization flag even when the input parameters are tampered with. The logic is as follows:

[0125]

[0126] in, Represents the permission check function, Indicates tampered input, Indicates the return value of successful authorization.

[0127] 3) Command injection: Command injection usually involves insufficiently filtered or validated input being used as an execution command, which can be detected by detecting how external input affects the command execution logic. Symbolic execution constraints monitor input calls to system command execution functions. The logic is as follows:

[0128]

[0129] in, Represents the function that executes the command. Indicates external input.

[0130] 4) Use-After-Free (UAF) vulnerability: UAF vulnerability involves the problem that the program mistakenly uses the memory resource again after releasing the resource. In symbolic execution, illegal references can be monitored by tracking memory allocation and release events. The specific strategy is as follows: ① After each memory allocation operation, mark the memory block as "allocated". ② After each memory release, mark the memory block as "released". ③ For each memory access, check the status of the relevant memory block. If the "released" memory block is accessed, a UAF alarm is triggered. The logic diagram is as follows:

[0131]

[0132]

[0133] in, Indicates the access operation to memory. Indicates the memory block being accessed, The function is used to return the current state of the memory block. is the alarm that was triggered.

[0134] This embodiment organizes the vulnerabilities detected during the analysis process into a structured report and outputs it. According to the data transmitted from the graph neural network and the symbolic execution engine, the identified vulnerabilities will be detailed with their types, specific locations, potential impacts, and repair suggestions. In addition, users are allowed to query, filter, and sort the report content as needed to quickly locate critical vulnerabilities. The report can also be exported to multiple formats, such as PDF or HTML, for easy sharing and further analysis between security audit and firmware development teams, thereby accelerating the response and repair process. In this way, not only the efficiency of collaboration between teams is enhanced, but also the timeliness and effectiveness of vulnerability response are ensured.

[0135] This paper proposes an automatic router firmware vulnerability mining system that combines graph neural network (GNN), angr analysis tool and symbolic execution, named "CFG-GNN-SYM". Compared with traditional static analysis or machine learning-based methods, this system achieves more accurate and efficient identification of potential vulnerabilities in router firmware by integrating deep learning and symbolic execution techniques. The system first uses angr to generate a control flow graph (CFG) from the router firmware. Compared with the CFG generated by traditional tools, the CFG generated by angr provides more detailed program execution path information, providing rich basic data for the deep learning model. This detailed path analysis can reveal the complex logic in the program and provide key information for subsequent vulnerability identification. Then, the system converts the CFG into a graph data format that can be processed by GNN, and enhances the feature expression ability of the graph data through data preprocessing technology. By introducing node and edge feature normalization and graph data enhancement technology, the system improves the accuracy and generalization ability of model learning, which is often not fully utilized in traditional methods. Especially when dealing with firmware with complex structures, this method can better capture the subtle features related to vulnerabilities. The pre-trained GNN model is used to analyze CFG, identify potential vulnerability patterns, and prioritize paths. The GNN model of this system is optimized specifically for CFG. Compared with the general neural network model, it can more effectively parse the structural information in the control flow graph, thereby improving the accuracy of vulnerability detection. According to the analysis results of GNN, combined with symbolic execution technology, the paths that are more likely to contain vulnerabilities are explored first. This system significantly alleviates the path explosion problem through intelligent path priority analysis, which is a significant challenge in traditional symbolic execution tools. In addition, for specific firmware architectures (such as ARM and MIPS), the system designs a special symbolic execution strategy, and implements targeted detection logic and constraints for different vulnerability types (such as buffer overflow, permission bypass, and command injection), so as to achieve better detection efficiency and effect.

[0136] The invention proposes a two-stage automatic vulnerability mining method for router firmware based on GNN and angr, which combines the advantages of static analysis and dynamic analysis: the static analysis method based on GNN obtains detailed program execution path information through CFG generated by angr, further improves the generalization ability and prediction accuracy of the model through data preprocessing and enhancement technology, and conducts targeted model training and vulnerability classification in combination with data characteristics, thereby enhancing the accuracy of detection while maintaining high efficiency; the dynamic analysis method based on symbolic execution performs pruning according to the preliminary results of static analysis, avoids the path explosion problem in traditional symbolic execution, and implements the symbolic execution strategy for MIPS and ARM type firmware binary programs. Combined with data characteristics, GNN has unique advantages in processing graph structure data such as CFG, can effectively learn the control flow information of the program, and improve the accuracy of vulnerability identification; at the same time, the graph structure processing ability of GNN has a significant optimization effect on symbolic execution path selection. The two-stage method avoids the problem of GNN's large data demand and verification accuracy, and also alleviates the common path explosion problem of symbolic execution. At the same time, the prediction results of static analysis are verified and optimized through dynamic analysis, which improves the analysis efficiency and accuracy. The present invention comprehensively improves the accuracy and reliability of router firmware vulnerability detection by combining dynamic analysis and static analysis.

[0137] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0138] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0139] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.

[0140] The present invention uses specific embodiments to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only used to help understand the method of the present invention and its core idea. At the same time, for those skilled in the art, according to the idea of ​​the present invention, there will be changes in the specific implementation methods and application scope. In summary, the content of this specification should not be understood as a limitation on the present invention.

[0141] Those skilled in the art will appreciate that the embodiments described 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 two-stage automatic vulnerability mining method for router firmware based on GNN and angr, characterized in that: The following steps are involved: Generate control flow graphs from router firmware using static analysis tools; Performing data conversion and data enhancement processing on the control flow graph; wherein the data enhancement processing on the control flow graph includes: randomly deleting nodes in the control flow graph; randomly deleting edges in the control flow graph; adding new nodes and edges in the control flow graph, or modifying attribute information of existing nodes and edges; The pre-trained graph neural network model is used to identify vulnerabilities in the processed control flow graph and prioritize the program execution paths with vulnerabilities. The prioritization of the program execution paths with vulnerabilities includes: Calculate the path priority score of each node based on the priorities of different vulnerability categories and the predicted probability of vulnerability categories output by the graph neural network model; prioritize the program execution paths with vulnerabilities based on the path priority score of each node; The path priority score of each node is calculated as follows: in, is the path priority score of node i, is the importance weight of vulnerability category c, is the predicted probability that node i belongs to vulnerability category c, is the total number of vulnerability categories; Based on the sorting results of program execution paths with vulnerabilities, the program execution paths are symbolically executed using dynamic and static hybrid analysis tools to obtain the router firmware vulnerability mining results.

2. According to claim 1, a two-stage automatic vulnerability mining method for router firmware based on GNN and angr is characterized in that: Data transformation of the control flow graph includes: Convert the control flow graph into JSON data format and record the instruction type and jump condition of each node and edge in the control flow graph.

3. According to claim 1, a two-stage automatic vulnerability mining method for router firmware based on GNN and angr is characterized in that: Using dynamic and static hybrid analysis tools to perform symbolic execution on program execution paths includes: According to different vulnerability types, the detection logic and constraint conditions are optimized for the instruction sets, operation modes and register configurations under different architectures.

4. According to claim 3, a two-stage automatic vulnerability mining method for router firmware based on GNN and angr is characterized in that: When using dynamic and static hybrid analysis tools to perform symbolic execution on the program execution path, For buffer overflow vulnerabilities, the instruction characteristics of the ARM firmware architecture and the MIPS firmware architecture monitor the write operations on the stack, monitor the changes in the registers to detect overflows caused by tampering with the return address, and verify whether the stack pointer points to a legitimate stack area.

5. According to claim 4, a two-stage automatic vulnerability mining method for router firmware based on GNN and angr is characterized in that: When using dynamic and static hybrid analysis tools to perform symbolic execution on the program execution path, For the permission bypass vulnerability, in the context of symbolic execution, it is detected that the permission check function returns a successful authorization flag even when the input parameters are tampered.

6. According to claim 5, a two-stage automatic vulnerability mining method for router firmware based on GNN and angr is characterized in that: When using dynamic and static hybrid analysis tools to perform symbolic execution on the program execution path, For command injection vulnerabilities, we detect whether external input affects the command execution logic and monitor the input calls to the system command execution function.

7. According to claim 6, a two-stage automatic vulnerability mining method for router firmware based on GNN and angr is characterized in that: When using dynamic and static hybrid analysis tools to perform symbolic execution on the program execution path, For use-after-free vulnerabilities, symbolic execution is used to monitor whether there are illegal references by tracking memory allocation and release events. The specific strategy is to mark the memory block as allocated after each memory allocation operation and mark the memory block as released after each memory release. For each memory access, the status of the relevant memory block is checked. If the access is to a released memory block, a UAF alarm is triggered.

Citation Information

Patent Citations

  • Internet-of-things firmware vulnerability detection method, system and device and medium

    CN115758385A

  • Binary software vulnerability prediction method based on machine learning

    CN116361788A