Intelligent contract fuzzy testing method based on artificial intelligence

By combining fuzzy testing and symbol execution in smart contracts, using artificial intelligence reinforcement learning and neural networks to imitate symbol execution expert behavior, the problems of low vulnerability detection and limited coverage in smart contracts are solved, and more efficient and accurate vulnerability detection is achieved, improving the overall security of smart contracts.

CN119807072APending Publication Date: 2025-04-11XIAMEN SLOWMIST TECHNOLOGY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510013006.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-01-06
Publication Date
2025-04-11

AI Technical Summary

Technical Problem

The existing technology has problems such as low testing efficiency, limited coverage and poor scalability in vulnerability detection in smart contracts, making it difficult to discover vulnerabilities in complex programs and generate attack vectors.

Method used

Using a smart contract fuzz testing method based on artificial intelligence, combining fuzz testing and symbol execution, through reinforcement learning and neural networks to imitate symbol execution expert behavior, smart contract input sequences are generated to achieve end-to-end vulnerability detection.

Benefits of technology

It improves the efficiency and coverage of vulnerability detection in smart contracts, enhances the accuracy and scalability of detection, and improves the overall security of smart contracts.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure HDA0005228984480000011
    Figure HDA0005228984480000011
  • Figure HDA0005228984480000021
    Figure HDA0005228984480000021
Patent Text Reader

Abstract

The invention discloses an intelligent contract fuzzy test method based on artificial intelligence, and belongs to the technical field of block chains, and the technical scheme is characterized in that the method comprises the following steps: using a fuzzy test as a Markov decision process MDP to define a state, an action and a reward function; learning a fuzzy test strategy by simulating a symbolic execution expert, and learning and training a neural network to simulate the behavior of the expert by simulating the symbolic execution expert based on the state and reward of the expert; a neural network NN architecture is used for representing the learned fuzzy test strategy, the neural network NN architecture simulates the fuzzy test strategy for generating an intelligent contract input sequence, and a gating loop unit GRU is used for tracking sequence history and generating a new input sequence; an end-to-end system is realized, the end-to-end system supports semantic feature representation for the smart contract, practical symbol execution of the smart contract and a group of key vulnerability detectors, and the method has the effect of improving the efficiency and effectiveness of automatic detection of vulnerabilities in the smart contract.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of blockchain technology, and more specifically to an artificial intelligence-based smart contract fuzz testing method. Background Art

[0002] With the continuous innovation of blockchain technology and the continuous expansion of commercial applications, the demand and application of smart contracts on the blockchain are becoming more and more extensive. Smart contracts are distributed applications that run on the blockchain and can automatically execute contract terms. However, since the code of smart contracts is public and cannot be changed, they are vulnerable to attacks and vulnerabilities.

[0003] In order to solve this problem, existing researchers have proposed many automated software vulnerability detection tools, such as fuzz testing and symbolic execution. However, these methods have some limitations, such as low testing efficiency and insufficient coverage. The traditional fuzz testing and symbolic execution methods have the following main defects:

[0004] 1. Fuzz testing methods usually generate input randomly, which has low testing efficiency and can only find some simple vulnerabilities. For complex programs and input spaces, its effect is limited;

[0005] 2. Symbolic execution methods can automatically deduce all execution paths of a program, but for large programs and complex input spaces, their computational cost is very high, resulting in poor scalability;

[0006] 3. The path constraints generated by the symbolic execution method are usually complex Boolean expressions that need to be solved by a constraint solver. The efficiency of the constraint solver will also affect the efficiency of symbolic execution.

[0007] 4. Symbolic execution methods can usually only handle simple data types and operations, and their coverage of complex data types and operations in smart contracts is limited;

[0008] 5. Symbolic execution methods can usually only discover vulnerabilities in the program, but cannot generate attack vectors or detect the harmfulness of the vulnerabilities.

[0009] In view of this, the inventors have designed a more efficient, accurate and scalable automated software vulnerability detection tool to solve these problems. Summary of the invention

[0010] In view of the shortcomings of the prior art, the purpose of the present invention is to provide an artificial intelligence-based smart contract fuzz testing method, which has the advantage of improving the efficiency and effectiveness of automatic vulnerability detection in smart contracts, combining the advantages of fuzz testing and symbolic execution, and learning an effective and fast fuzz testing mechanism from symbolic execution. This method solves the limitations of traditional fuzzy and symbolic execution methods, such as low testing efficiency, limited coverage and scalability problems, and can achieve higher detection coverage in smart contracts, improve vulnerability discovery efficiency, and thus improve the overall security of smart contracts.

[0011] To achieve the above object, the present invention provides the following technical solution: a smart contract fuzz testing method based on artificial intelligence, comprising the following steps:

[0012] S1: Fuzz testing is defined as a Markov decision process (MDP) to define states, actions and reward functions, and the fuzz testing can apply reinforcement learning techniques to learn effective fuzz testing strategies;

[0013] S2: learning fuzz testing strategies by imitating symbolic execution experts, wherein the imitating symbolic execution experts learn to train a neural network to imitate the behavior of the experts based on the experts’ states and rewards;

[0014] S3: Use a neural network (NN) architecture to represent the learned fuzz testing strategy, which simulates the fuzz testing strategy for generating smart contract input sequences and uses a gated recurrent unit (GRU) to track sequence history and generate new input sequences;

[0015] S4: Implement an end-to-end system that supports semantic feature representation for smart contracts, practical symbolic execution of smart contracts, and a set of critical vulnerability detectors.

[0016] The present invention preferably: the neural network NN architecture generates transactions including the following steps: S21: using a gated recurrent unit GRU to track the current state, including the current transaction, the current contract state and the current symbolic execution path condition;

[0017] S22: using another gated recurrent unit GRU to generate a new transaction sequence, wherein the gated recurrent unit GRU uses the current state and the previously generated transaction sequence as input and outputs a sampling function f(i) for generating the next transaction;

[0018] S23: Generate an integer parameter using a fully connected neural network FCN. The fully connected neural network FCN uses the current state and the previously generated transaction sequence as input and outputs an integer parameter;

[0019] S24: Generate a sender using another fully connected neural network FCN. The fully connected neural network FCN uses the current state and the previously generated transaction sequence as input and outputs a sender;

[0020] S25: Use another fully connected neural network FCN to generate a transaction amount. The fully connected neural network FCN uses the current state and the previously generated transaction sequence as input and outputs a transaction amount.

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

[0022] 1. High code coverage: The system achieves high code coverage on real-world smart contracts, which helps improve the efficiency and accuracy of detecting critical vulnerabilities;

[0023] 2. Improved vulnerability detection: The system is better than existing smart contract security tools in terms of detecting vulnerabilities, both in terms of the type of vulnerabilities detected and the speed of vulnerabilities detected;

[0024] 3. Fast and scalable: The system is fast and scalable, suitable for analyzing large-scale smart contracts. BRIEF DESCRIPTION OF THE DRAWINGS

[0025] Figure 1 is a flow chart of the smart contract fuzzy test involved in the implementation of this embodiment;

[0026] Figure 2 It is a flowchart of a transaction generated by the neural network NN architecture involved in the implementation of this embodiment. DETAILED DESCRIPTION

[0027] The present invention is further described in detail below in conjunction with the accompanying drawings.

[0028] An artificial intelligence-based smart contract fuzz testing method, such as Figure 1 As shown, the following steps are included: S1: define the state, action and reward function by taking fuzz testing as a Markov decision process MDP, and fuzz testing can apply reinforcement learning technology to learn effective fuzz testing strategies;

[0029] S2: Learn fuzz testing strategies by imitating symbolic execution experts. Based on the status and rewards of symbolic execution experts, learn to train a neural network to imitate the behavior of experts.

[0030] S3: The learned fuzz testing strategy is represented by a neural network NN architecture. The neural network NN architecture simulates the fuzz testing strategy for generating smart contract input sequences, and uses a gated recurrent unit GRU to track sequence history and generate new input sequences, such as Figure 2 As shown, the neural network NN architecture generates transactions including the following steps:

[0031] S21: Use a gated recurrent unit GRU to track the current state, including the current transaction, the current contract state, and the current symbolic execution path condition;

[0032] S22: Generate a new transaction sequence using another gated recurrent unit GRU, which uses the current state and the previously generated transaction sequence as input and outputs a sampling function f(i) that is used to generate the next transaction;

[0033] S23: Generate an integer parameter using a fully connected neural network FCN. The fully connected neural network FCN uses the current state and the previously generated transaction sequence as input and outputs an integer parameter;

[0034] S24: Generate a sender using another fully connected neural network FCN. The fully connected neural network FCN uses the current state and the previously generated transaction sequence as input and outputs a sender;

[0035] S25: Use another fully connected neural network FCN to generate a transaction amount. The fully connected neural network FCN uses the current state and the previously generated transaction sequence as input and outputs a transaction amount.

[0036] S4: Implement an end-to-end system that supports semantic feature representation for smart contracts, practical symbolic execution of smart contracts, and a set of critical vulnerability detectors.

[0037] The working process and beneficial effects of the present invention are as follows: The system improves the efficiency and accuracy of fuzz testing by combining fuzz testing and symbolic execution and using deep learning technology to learn fuzz testing strategies. The key points include:

[0038] 1. Combining fuzz testing and symbolic execution: This system combines fuzz testing and symbolic execution to improve the efficiency and accuracy of fuzz testing by learning the behavior of symbolic execution experts.

[0039] 2. Using machine imitation to learn fuzz testing strategies: This system implements learning fuzz testing strategies by using imitation learning, which improves the efficiency and accuracy of fuzz testing by training neural networks to imitate the behavior of symbolic execution experts.

[0040] 3. Use neural network architecture to represent fuzz testing strategy: This system uses a neural network architecture to represent the learned fuzz testing strategy, which simulates the fuzz testing strategy for generating smart contract input sequences. The architecture uses a gated recurrent unit GRU to track sequence history and generate new input sequences.

[0041] 4. Semantic feature representation for smart contracts: This system supports semantic feature representation for smart contracts, which helps improve the efficiency and accuracy of fuzz testing.

[0042] This technical solution combines the advantages of fuzz testing and symbolic execution, and learns an effective and fast fuzz testing mechanism from symbolic execution. This method solves the limitations of traditional fuzzy and symbolic execution methods, such as low testing efficiency, limited coverage, and scalability issues. It can also achieve higher detection coverage in smart contracts, improve vulnerability discovery efficiency, and thus improve the overall security of smart contracts.

[0043] The above are only preferred embodiments of the present invention and are not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the design concept of the present invention should be included in the protection scope of the present invention.

Claims

1. A smart contract fuzz testing method based on artificial intelligence, characterized by: The following steps are included: S1: Fuzz testing is defined as a Markov decision process (MDP) to define states, actions and reward functions, and the fuzz testing can apply reinforcement learning techniques to learn effective fuzz testing strategies; S2: learning fuzz testing strategies by imitating symbolic execution experts, wherein the imitating symbolic execution experts learn to train a neural network to imitate the behavior of the experts based on the experts’ states and rewards; S3: Use a neural network (NN) architecture to represent the learned fuzz testing strategy, which simulates the fuzz testing strategy for generating smart contract input sequences and uses a gated recurrent unit (GRU) to track sequence history and generate new input sequences; S4: Implement an end-to-end system that supports semantic feature representation for smart contracts, practical symbolic execution of smart contracts, and a set of critical vulnerability detectors.

2. According to the artificial intelligence-based smart contract fuzz testing method of claim 1, it is characterized by: The neural network NN architecture generates transactions including the following steps: S21: Use a gated recurrent unit GRU to track the current state, including the current transaction, the current contract state, and the current symbolic execution path condition; S22: using another gated recurrent unit GRU to generate a new transaction sequence, wherein the gated recurrent unit GRU uses the current state and the previously generated transaction sequence as input and outputs a sampling function f(i) for generating the next transaction; S23: Generate an integer parameter using a fully connected neural network FCN, wherein the fully connected neural network FCN uses the current state and a previously generated transaction sequence as input and outputs an integer parameter; S24: Generate a sender using another fully connected neural network FCN, wherein the fully connected neural network FCN uses the current state and the previously generated transaction sequence as input and outputs a sender; S25: Use another fully connected neural network FCN to generate a transaction amount, wherein the fully connected neural network FCN uses the current state and the previously generated transaction sequence as input and outputs a transaction amount.