A smart contract vulnerability detection method and system based on strategic Fuzzer
Through the smart contract vulnerability detection method based on the strategy-based Fuzzer, the test case reachability and execution path vulnerability policy models are trained, which solves the problems of low false negative rate and low path coverage rate of smart contract vulnerability detection in the existing technology, and achieves a better Efficient and more accurate vulnerability detection results.
Patent Information
- Application Number
- CN202210455506.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-04-27
- Publication Date
- 2024-09-17
- Estimated Expiration
- 2042-04-27
AI Technical Summary
Existing smart contract vulnerability detection methods suffer from high false negative and false positive rates due to static analysis, as well as random mutation strategies, low path coverage, long time consumption, and poor discovery results of fuzz testing methods.
Adopting a smart contract vulnerability detection method based on strategy-based Fuzzer, by training the strategy model, filtering unreachable test case inputs, determining the execution path with vulnerabilities, and guiding the fuzzy detector to achieve higher accuracy, wider coverage and Faster detection efficiency. Specific steps include building a data set, initializing test case reachability and execution path vulnerability policy models, optimizing test case collections, and dynamically updating the policy model to improve the accuracy and efficiency of vulnerability detection.
It effectively reduces the false positive rate and false negative rate of static analysis, improves the efficiency and accuracy of fuzzy detection, and achieves faster and more accurate vulnerability detection of smart contracts, which has good practical value and reference significance.
Smart Images

Figure CN115033883B
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of blockchain smart contract security, and specifically relates to a smart contract vulnerability detection method and system based on a strategy-based fuzzer. Background Art
[0002] Program vulnerabilities have seriously hindered the development of computer programming languages. Security vulnerabilities hidden in programs may cause serious security incidents such as computer system damage, information leakage or denial of service. The security issues caused by program vulnerabilities have become the focus of attention in the field of computer security. In recent years, smart contract security vulnerabilities have attracted widespread attention from relevant practitioners at home and abroad. Smart contracts are essentially a program running on the blockchain, with characteristics such as automatic execution and irreversibility. At present, the number of smart contracts deployed in the blockchain network is nearly 10 million, which has attracted many malicious attackers who try to exploit contract vulnerabilities to gain illegal benefits. Smart contract security vulnerabilities have caused huge economic losses, and effective vulnerability detection tools are urgently needed to detect smart contracts to ensure the security and reliability of contracts deployed on the blockchain.
[0003] Current smart contract vulnerability detection methods mainly involve static analysis and dynamic execution, including formal verification, symbolic execution, and fuzz testing. Static analysis methods (such as formal verification and symbolic execution) lack dynamic interaction analysis during contract execution, so they cannot discover vulnerabilities hidden deep in the program (such as those that require multiple iterations to be generated), resulting in high rates of missed reports and false positives; fuzz testing is the most widely used and effective method in the field of vulnerability analysis. It is a typical dynamic analysis method and has been applied to smart contract vulnerability detection tasks. However, traditional fuzz testing methods rely on the initial test cases and their mutation strategies, and still have pain points such as random mutation strategies, low path coverage, long vulnerability detection time, and poor vulnerability discovery effect. Summary of the invention
[0004] In response to the problems of high missed alarm rate and false alarm rate of static analysis methods and random mutation strategy and low path coverage of fuzzy testing methods, the present invention proposes a smart contract vulnerability detection method and system based on strategy-based Fuzzer. By training the strategy model, unreachable test case inputs are filtered and execution paths with vulnerabilities are determined, so as to guide the fuzzy detector Fuzzer to achieve smart contract vulnerability detection with higher accuracy, wider coverage and faster execution efficiency.
[0005] In order to achieve the above object, the present invention adopts the following technical solution:
[0006] A smart contract vulnerability detection method based on a strategic fuzzer includes the following steps:
[0007] Step 1: Build a smart contract dataset and initialize the test case reachability strategy model F1 and the execution path vulnerability strategy model F2;
[0008] Step 2: Given a contract to be tested, initialize a test case set; traverse each test case in the set, first use the test case reachability strategy model F1 to predict the reachability of the test case, and store the test case and its predicted label in the database D1;
[0009] For test cases that do not meet the reachability requirements, remove them from the initialization test case set;
[0010] For the test case that meets the reachability, obtain the execution path consisting of reachable nodes, use the execution path vulnerability strategy model F2 to predict the vulnerability of the execution path corresponding to the test case, and store the execution path and its predicted label in the database D2;
[0011] For execution paths with vulnerabilities, give priority marks to corresponding test cases;
[0012] Step 3: For the optimized test case set, prioritize test cases with higher priority for mutation and testing until the fuzz testing is completed.
[0013] As a preferred embodiment of the present invention, it also includes a process of dynamically updating the test case reachability strategy model F1 and the execution path vulnerability strategy model F2, specifically: according to the test cases with prediction labels and the execution path data set saved in the databases D1 and D2 in step 2, the test case reachability strategy model F1 and the execution path vulnerability strategy model F2 are iteratively updated respectively, so that the strategy models can be dynamically updated online at the same time during the fuzzy testing process.
[0014] As a preferred embodiment of the present invention, the initialization process of the test case reachability strategy model F1 and the execution path vulnerability strategy model F2 is specifically as follows:
[0015] Build a smart contract data set, extract the smart contract control flow graph, design test cases for each node in the control flow graph, and mark the execution path corresponding to the test cases;
[0016] Next, the reachability of the test cases and the vulnerability of the execution paths are annotated as training labels, and the test case reachability strategy model F1 and the execution path vulnerability strategy model F2 are trained respectively using the annotated test case and execution path datasets as input.
[0017] As a preferred embodiment of the present invention, a control flow execution path A in a given smart contract = {A1, A2, ..., A N}, N represents the number of nodes on the path, and a test case set B = {a, b, c, ...} covering each node is generated. The reachability label set of the test case set is Y = {y a ,y b ,y c ,…}; Each reachability label is composed of an N-dimensional 0-1 vector. If only the i-th digit in the reachability label vector is 1, the test case can reach the first i nodes on the control flow execution path A. If all the reachability label vectors are 0, the test case is unreachable.
[0018] As a preferred embodiment of the present invention, the test case reachability strategy model F1 adopts a convolutional neural network model, and the execution path vulnerability strategy model F2 adopts a recurrent neural network model.
[0019] The present invention also discloses a smart contract vulnerability detection system based on a strategy-based fuzzer, which is used to implement the above-mentioned smart contract vulnerability detection method; the smart contract vulnerability detection system comprises:
[0020] Smart contract basic analysis module, which is used to build smart contract data sets, initialize test case reachability strategy model F1 and execution path vulnerability strategy model F2;
[0021] The test case collection module is used to initialize the test case queue to be tested for a given contract to be tested and optimize the test case queue;
[0022] A test case reachability strategy model module is used to traverse each test case in the test case collection module, predict the reachability of the test case using the test case reachability strategy model F1, and store the test case and its predicted label in the database D1;
[0023] For test cases that do not meet the reachability requirements, remove them from the initialization test case set;
[0024] An execution path vulnerability strategy model is used to obtain a test case that satisfies reachability output by the test case reachability strategy model module, and obtain an execution path consisting of reachable nodes, and use the execution path vulnerability strategy model F2 to predict the vulnerability of the execution path corresponding to the test case, and store the execution path and its predicted label in the database D2;
[0025] For execution paths with vulnerabilities, give priority marks to corresponding test cases;
[0026] The fuzzy detector module is used to obtain the optimized test case queue and give priority to test cases with higher priority for mutation and testing until the fuzzy test is completed.
[0027] Furthermore, it also includes:
[0028] A strategy model update module, which is used to iteratively update the test case reachability strategy model F1 according to the test cases with prediction labels stored in the database D1 in the test case reachability strategy model module, and to iteratively update the execution path vulnerability strategy model F2 according to the execution paths with prediction labels stored in the database D2 in the execution path vulnerability strategy model.
[0029] The present invention proposes a smart contract vulnerability detection method and system based on a strategy-based fuzzer. This method trains a strategy model based on a deep neural network by analyzing the accessibility of test cases and the vulnerability of control flow execution paths, so as to guide the fuzzy detector to achieve smart contract vulnerability detection with faster efficiency, wider coverage and higher accuracy. Compared with traditional static analysis and fuzzy detection methods, this method can effectively reduce the false alarm rate and missed alarm rate of static analysis, improve the efficiency and accuracy of fuzzy detection, and not only has good practical value, but also has good reference significance. The specific innovations and beneficial effects are mainly reflected in the following four aspects:
[0030] (1) The present invention proposes a test case reachability analysis method based on a policy model, which analyzes the reachability of the test case input in the execution path, trains the corresponding policy model, and filters the unreachable test case input before executing the fuzzy test, thereby improving the efficiency of the fuzzy test;
[0031] (2) The present invention proposes an execution path vulnerability prediction method based on a policy model, which analyzes whether there are vulnerabilities in the control flow execution path, trains the corresponding policy model, predicts the vulnerability of the execution path, determines the priority of the input use case, and enables the fuzzy detector to allocate more resources to high-quality use cases;
[0032] (3) The present invention proposes a dynamic model update method in the fuzzy detection process, which inputs the test cases and the annotated data sets of the execution paths stored in the model database into the strategy model to dynamically update and generate a more robust and accurate strategy model;
[0033] (4) The present invention proposes a fuzzy detection method guided by a policy model, and realizes a smart contract vulnerability detection system based on a policy-based fuzzer, which can perform faster and more accurate vulnerability detection on smart contracts. BRIEF DESCRIPTION OF THE DRAWINGS
[0034] Figure 1 This is a flow chart of smart contract vulnerability detection based on strategy-based Fuzzer in the present invention.
[0035] Figure 2 This is a framework diagram of the smart contract vulnerability detection system based on the strategy-based Fuzzer of the present invention.
[0036] Figure 3 Schematic diagram of data set construction and model training for the strategy model of the present invention.
[0037] Figure 4 This is the overall architecture diagram of the smart contract vulnerability detection based on the strategy-based Fuzzer of the present invention. DETAILED DESCRIPTION
[0038] In order to clearly explain the present invention and make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention is clearly and completely described below in conjunction with the drawings in the embodiments of the present invention, so that those skilled in the art can implement it according to the description. The technology of the present invention is described in detail below in conjunction with the drawings in conjunction with the specific implementation methods.
[0039] like Figure 1 As shown, the smart contract vulnerability detection process based on the strategy-based fuzzer of the present invention can be divided into two parts: 1) the detection process of the fuzzy detector; 2) the strategy model training and update process. The details are as follows:
[0040] Part 1, the detection process of the fuzzy detector.
[0041] The fuzzy detector of the present invention includes two strategy models: a test case accessibility strategy model F1 and an execution path vulnerability strategy model F2; for each test case in the set, the model F1 is first used to predict the accessibility of the case input, and the test case and its predicted label are stored in a database D1; for test cases that meet the accessibility, the model F2 is further used to predict the vulnerability of the execution path corresponding to the test case, and the execution path and its predicted label are stored in a database D2; for the execution path with vulnerabilities, a priority mark is given;
[0042] Through the above process, the screening of original test cases is achieved.
[0043] Part 2: Strategy model training and update process.
[0044] Based on the introduction in the first part, the test case reachability strategy model F1 and the execution path vulnerability strategy model F2 used in the fuzzy detection process are updated dynamically online. The initialization training process of the two strategy models is as follows:
[0045] A smart contract dataset is constructed to initialize the strategy model. The smart contract control flow graph is extracted using the contract control flow graph extraction tool. Test cases are designed for each node in the control flow graph, and the execution paths corresponding to the test cases are marked. Then, the reachability of the test cases and the vulnerability of the execution paths are marked as training labels, and the test case reachability strategy model F1 and the execution path vulnerability strategy model F2 are trained respectively using the marked test cases and execution path datasets as input.
[0046] The online dynamic update process refers to using the test cases and execution paths stored in the database D1 and database D2 described in the first part as training sets and using the prediction results as labels to dynamically update the models F1 and F2.
[0047] like Figure 3 As shown, the strategy model training process of the present invention is introduced.
[0048] Pre-analyze the reachability of the test case and mark the reachability of each node on the control flow execution path, that is, whether the test case can reach a certain node on the execution path. For example, given a control flow execution path A = {A1, A2, A3, A4} containing four nodes, for different test case inputs B = {a, b, c}, their reachability labels are represented as a vector Y = {y a ,y b ,y c For example, for the test case input a, its reachability is marked as y a ={0,1,0,0}, indicating that nodes A1 and A2 on the control flow execution path can be reached by test case input a; for test case input b, its reachability is marked as y b ={1,0,0,0}, indicating that node A1 on the control flow execution path can be reached by test case input b; for test case input c, its reachability is marked as y c ={0,0,0,1}, indicating that nodes A1, A2, A3, and A4 on the control flow execution path can be reached by the test case input c.
[0049] The vulnerability of the control flow execution path to be tested is pre-analyzed, and whether the execution path has a vulnerability is marked. In this embodiment, by implementing a dynamic instrumentation tool for smart contract programs, the execution path during the contract execution process is extracted, and the execution path input to be tested is converted into a vector form using a vulnerability analyzer, and whether there is a vulnerability is marked, represented as y p ∈{0,1}, where y p =1, indicating that there is a vulnerability in the execution path, y p =0, indicating that there is no vulnerability in the execution path.
[0050] After completing the reachability analysis of the test case and the vulnerability analysis of the execution path, in this embodiment, a convolutional neural network (CNN) is used as the strategy model F1 and a recurrent neural network (RNN) is used as the strategy model F2. The test case reachability annotation dataset and the control flow path vulnerability annotation dataset are used as input, the test case and the execution path are converted into a vector form, the strategy model is initialized, and a test case reachability strategy model F1 and an execution path vulnerability strategy model F2 are trained respectively.
[0051] In this embodiment, the strategy model F1 can realize multi-classification prediction of whether each node in the control flow execution path is reachable. If there is a "1" in the prediction label, the test case can reach the corresponding node in the execution path. If the prediction labels are all "0", the test case is unreachable and filtered. There is no need to continue to predict vulnerabilities in the execution path corresponding to the test case. The present invention proposes a fuzzy detection system ST-Fuzzer guided by a strategy model, which effectively improves the detection efficiency and vulnerability discovery rate of traditional fuzzy testing methods. The overall architecture of ST-Fuzzer is as follows: Figure 2 As shown in the figure, it integrates basic modules such as smart contract crawler tools, execution path extractors, and key modules such as strategy models and fuzzy detectors. Specifically, ST-Fuzzer includes:
[0052] Smart contract basic analysis module. It is used to collect smart contracts by implementing contract crawler tools; use smart contract dynamic instrumentation tools to extract the control flow execution path during contract execution, generate test cases for each node in the control flow execution path and perform reachability annotation to obtain the test case data set; use the vulnerability analyzer to mark whether each execution path has vulnerabilities, and obtain the execution vulnerability data set.
[0053] Test case reachability strategy model: It uses a convolutional neural network model (CNN) and uses annotated test case datasets to train the corresponding strategy model F1.
[0054] Execution path vulnerability policy model: It uses a recurrent neural network model (RNN) and uses the annotated execution vulnerability dataset to train the corresponding policy model F2.
[0055] Fuzzy detector module. It integrates test case analyzer, test case mutation strategy generator, vulnerability detector and feedback mechanism to achieve accurate smart contract vulnerability detection.
[0056] As for the system embodiment, since it basically corresponds to the method embodiment, the relevant parts can be referred to the partial description of the method embodiment. The system embodiment described above is only illustrative, wherein various modules may or may not be physically separated. In addition, each functional module in the present invention may be integrated into a processing unit, or each module may exist physically separately, or two or more modules may be integrated into one unit.
[0057] The programs in the above modules are all processed by the processor when they are executed. For example, when using the above ST-Fuzzer to detect vulnerabilities in smart contracts, the smart contract to be detected is input into the new fuzzy detector ST-Fuzzer based on the policy model. The test case reachability policy model F1 is first used to predict the reachability of the test cases in the test case queue one by one, filter out the unreachable test case inputs, and save the test cases and their predicted reachability labels to the database D1; if the test case is reachable, the execution path vulnerability policy model F2 further judges the execution path corresponding to the current test case, predicts whether there are vulnerabilities in the execution path, and saves the execution path and its predicted vulnerability labels to the database D2; if the prediction result is that there is a vulnerability in the execution path, the attribute of the current test case is marked as Priority;
[0058] The data sets stored in databases D1 and D2 are input to strategy models F1 and F2 respectively to support their online dynamic update;
[0059] ST-Fuzzer updates the test cases with the attribute of Priority to the test case queue so that the next round of fuzz detector can select higher priority and more effective test cases to perform mutation and testing. After multiple rounds of iterations, ST-Fuzzer can finally accurately detect whether there are vulnerabilities in all execution paths in the smart contract.
[0060] This example uses Figure 4 Taking the smart contract vulnerability detection based on the strategy-based Fuzzer as an example, the specific detection process is as follows:
[0061] (1) Given a contract to be tested, ST-Fuzzer initializes a set of test cases and temporarily adds a test case, Case 1, to the test case queue;
[0062] (2) For the test case input Case1, ST-Fuzzer calls the trained strategy model F1 to predict the reachability of Case1, outputs the predicted label, and stores the test case and its predicted label in database D1;
[0063] If there is a "1" in the reachability prediction label, it corresponds to a reachable execution path Path1. ST-Fuzzer calls the trained strategy model F2 to predict the vulnerability of Path1, that is, y pt ∈{0,1}, and store the execution path and its predicted label in database D2; if the prediction result of strategy model F2 is that the current path has a vulnerability, then mark the attribute of the test case input Case1 in this round of detection as Priority, so as to guide Fuzzer to more reasonably allocate more resources to the path with high priority, that is, the path that is more likely to have vulnerabilities;
[0064] If there is no "1" in the reachability prediction label, Case 1 is not reachable, and Case 1 is removed from the test case queue;
[0065] Repeat the above process to traverse all test cases in the initialization test case set.
[0066] (3) Add the test case whose attribute in step (2) is marked as Priority to the test case queue, so that the next round of fuzzy detector can select higher priority and more effective test cases for mutation and testing, so that the fuzzy detector can allocate more detection resources to high-quality test cases;
[0067] While executing step (2) in a loop, the test cases and the annotated data sets of the execution paths saved in step (2) in the model databases D1 and D2 are respectively input into the strategy models F1 and F2, so that the fuzzy detector can dynamically update the strategy model online while executing the fuzzy test, thereby iteratively updating and generating a more effective and accurate strategy model.
[0068] In another implementation of the present invention, the Ethereum smart contract is taken as an example. The Ethereum smart contract is implemented in the Solidity language. It is the smart contract with the largest number and types of vulnerabilities and the most serious economic losses caused by vulnerabilities. The process of vulnerability detection for smart contracts includes:
[0069] (1) Generate control flow graph and extract execution path: For Ethereum smart contracts, we combine control flow and semantic tree analysis to implement a targeted contract control flow graph extraction tool to extract smart contract control flow graphs, generate test cases, and annotate control flow execution paths. Ethereum smart contracts can be collected from data sources such as the Ethereum official website, Github open source smart contract projects, and Ethereum smart contract blogs to construct a smart contract dataset.
[0070] (2) Reachability and vulnerability analysis, training strategy model: Analyze the reachability of test cases and the vulnerability of execution paths in different execution paths in the contract control flow graph. Take the labeled test cases and execution path datasets as input, and train the strategy models based on convolutional neural networks and recurrent neural networks respectively. Specifically, it is implemented from the following three aspects.
[0071] 2.1) Reachability analysis of test cases: The nodes involved in the control flow execution path are taken as specific analysis targets. The nodes on the control flow execution path are marked to indicate whether the test case can be executed to reach the corresponding node on the control flow execution path;
[0072] 2.2) Vulnerability analysis of execution paths: In order to enable the fuzzy detector to allocate detection resources more reasonably and effectively, that is, to allocate more resources to execution paths that may have vulnerabilities. Preliminary analysis is performed on the vulnerability of the control flow execution path to be tested, and whether the execution path has vulnerabilities is marked. Specifically, a vulnerability analyzer for the control flow path of the Ethereum smart contract is used, with the execution path in the contract control flow graph as the specific analysis target, to mark whether the control flow path has vulnerabilities;
[0073] 2.3) Initialize the strategy model: Select convolutional neural network (CNN) and recurrent neural network (RNN) as strategy models, build two strategy learning modules, take the labeled test cases and execution path data sets as input, convert the test cases and execution paths into vector form, and train a test case accessibility strategy model F1 and an execution path vulnerability strategy model F2. In this embodiment, the loss functions Cross Entropy Loss and Mean Square Error are used to optimize network training and avoid model overfitting.
[0074] (3) Policy model-guided, fuzzy detection execution: Given a smart contract to be tested, combined with the policy model trained in step (2). First, use the policy model F1 to filter unreachable test case inputs, and save these test cases and their reachability labels into the model database D1; the predicted label output by the policy model F1 is represented as or a 0 vector, where is a 0-1 vector, with 1 at the t-th position and 0 at the rest, indicating the t-th target node A on the reachable execution path of the i-th test case X t ; A 0 vector means that the test case is unreachable.
[0075] Next, the strategy model F2 is used to predict the execution path A={A1,A2,…,A t}Whether there is a vulnerability, and save the current execution path to be tested and its vulnerability prediction label to the model database D2; the prediction label output by the strategy model F2 is represented as y∈{0,1}, which indicates whether there is a vulnerability in the current execution path. If there is a vulnerability, the attribute of the test case is marked as Priority.
[0076] (4) Optimize the test case queue and dynamically update the strategy model: According to the test cases marked in step (3), update the attribute of Priority to the test case queue, so that when the next round of test cases are generated, the fuzzy detector can select test cases with better quality and higher priority as input, thereby making the selection of test cases more effective and the test case variation more directional; at the same time, the data set saved in the model database D1 and D2 in step (3) is used as the next round of input of the strategy model to support the dynamic iterative update of the model and further generate a more effective and accurate strategy model. Therefore, ST-Fuzzer can not only train a more robust and accurate strategy model, but also improve the execution efficiency of the entire fuzzy detection process.
[0077] It can be seen from the above embodiments that the smart contract vulnerability detection method based on the strategy-based Fuzzer proposed in the present invention trains and maintains a test case reachability strategy model F1 and an execution path vulnerability strategy model F2. First, the initialized test cases are subjected to reachability analysis, and unreachable test cases are filtered out, thereby improving the test efficiency. Then, the execution paths corresponding to the reachable test cases are subjected to vulnerability analysis, and priority tags are added to the test cases corresponding to the execution paths with vulnerabilities and updated to the test case set. In the subsequent mutation and vulnerability detection process, more effective test cases are directly used to accurately detect smart contract vulnerabilities.
[0078] The above description of the embodiments is to facilitate the understanding and application of the present invention by those skilled in the art. It is obvious that those skilled in the art can easily make various modifications to the above embodiments and apply the general principles described herein to other embodiments without creative work. Therefore, the present invention is not limited to the above embodiments, and improvements and modifications made to the present invention by those skilled in the art based on the disclosure of the present invention should be within the scope of protection of the present invention.
Claims
1. A smart contract vulnerability detection method based on a strategic fuzzer, characterized in that: The following steps are involved: Step 1: Build a smart contract dataset and initialize the test case reachability strategy model F1 and the execution path vulnerability strategy model F2; Step 2: Given a contract to be tested, initialize a test case set; traverse each test case in the set, first use the test case reachability strategy model F1 to predict the reachability of the test case, and store the test case and its predicted label in the database D1; For test cases that do not meet the reachability requirements, remove them from the initialization test case set; For the test case that meets the reachability, obtain the execution path consisting of reachable nodes, use the execution path vulnerability strategy model F2 to predict the vulnerability of the execution path corresponding to the test case, and store the execution path and its predicted label in the database D2; For execution paths with vulnerabilities, give priority marks to corresponding test cases; Step 3: For the optimized test case set, prioritize test cases with higher priority for mutation and testing until the fuzz testing is completed.
2. According to claim 1, a smart contract vulnerability detection method based on a strategy-based fuzzer is characterized in that: It also includes a process of dynamically updating the test case reachability strategy model F1 and the execution path vulnerability strategy model F2, specifically: according to the test cases with prediction labels and the execution path data set saved in the databases D1 and D2 in step 2, the test case reachability strategy model F1 and the execution path vulnerability strategy model F2 are iteratively updated respectively, so that the strategy models can be dynamically updated online at the same time during the fuzzy testing process.
3. According to claim 1, a smart contract vulnerability detection method based on a strategy-based fuzzer is characterized in that: The initialization process of the test case reachability strategy model F1 and the execution path vulnerability strategy model F2 is specifically as follows: Build a smart contract data set, extract the smart contract control flow graph, design test cases for each node in the control flow graph, and mark the execution path corresponding to the test cases; Next, the reachability of the test cases and the vulnerability of the execution paths are annotated as training labels, and the test case reachability strategy model F1 and the execution path vulnerability strategy model F2 are trained respectively using the annotated test case and execution path datasets as input.
4. According to claim 3, a smart contract vulnerability detection method based on a strategy-based fuzzer is characterized in that: Given a control flow execution path A in a smart contract, A = {A1, A2, ..., A N }, N represents the number of nodes on the path, and a test case set B = {a, b, c, ...} covering each node is generated. The reachability label set of the test case set is Y = {y a ,y b ,y c ,…}; Each reachability label is composed of an N-dimensional 0-1 vector. If only the i-th digit in the reachability label vector is 1, the test case can reach the first i nodes on the control flow execution path A. If all the reachability label vectors are 0, the test case is unreachable.
5. According to claim 1, a smart contract vulnerability detection method based on a strategy-based fuzzer is characterized in that: The test case reachability strategy model F1 adopts a convolutional neural network model, and the execution path vulnerability strategy model F2 adopts a recurrent neural network model.
6. A smart contract vulnerability detection system based on a strategic fuzzer, characterized in that: Used to implement the smart contract vulnerability detection method described in claim 1; The smart contract vulnerability detection system includes: Smart contract basic analysis module, which is used to build smart contract data sets, initialize test case reachability strategy model F1 and execution path vulnerability strategy model F2; The test case collection module is used to initialize the test case queue to be tested for a given contract to be tested and optimize the test case queue; A test case reachability strategy model module is used to traverse each test case in the test case collection module, predict the reachability of the test case using the test case reachability strategy model F1, and store the test case and its predicted label in the database D1; For test cases that do not meet the reachability requirements, remove them from the initialization test case set; An execution path vulnerability strategy model is used to obtain a test case that satisfies reachability output by the test case reachability strategy model module, and obtain an execution path consisting of reachable nodes, and use the execution path vulnerability strategy model F2 to predict the vulnerability of the execution path corresponding to the test case, and store the execution path and its predicted label in the database D2; For execution paths with vulnerabilities, give priority marks to corresponding test cases; The fuzzy detector module is used to obtain the optimized test case queue and give priority to test cases with higher priority for mutation and testing until the fuzzy test is completed.
7. According to claim 1, a smart contract vulnerability detection system based on a policy-based fuzzer is characterized in that: Also includes: A strategy model update module, which is used to iteratively update the test case reachability strategy model F1 according to the test cases with prediction labels stored in the database D1 in the test case reachability strategy model module, and to iteratively update the execution path vulnerability strategy model F2 according to the execution paths with prediction labels stored in the database D2 in the execution path vulnerability strategy model.
