Intelligent contract vulnerability detection method and system based on multi-modal fusion and information entropy

By using a smart contract vulnerability detection method based on multimodal fusion and information entropy, this method parses multiple modal data of smart contracts and performs weighted vector fusion, solving the problem of low vulnerability detection accuracy in existing technologies and achieving efficient detection of access control vulnerabilities, reentrancy vulnerabilities, and timestamp dependency vulnerabilities.

CN119720209BActive Publication Date: 2025-11-25INSTITUTE OF INFORMATION ENGINEERING CHINESE ACADEMY OF SCIENCES
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411567489.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-11-05
Publication Date
2025-11-25
Estimated Expiration
2044-11-05

AI Technical Summary

Technical Problem

Existing smart contract vulnerability detection methods suffer from low accuracy, especially in detecting access control vulnerabilities, reentrancy vulnerabilities, and timestamp-dependent vulnerabilities. Furthermore, existing methods rely on expert rules, which are time-consuming and prone to errors, and deep learning models based on single features have limited perspectives.

Method used

By employing multimodal fusion and information entropy methods, token sequences are generated by parsing the source code, bytecode, and opcodes of smart contracts. These sequences are then vectorized using the Word2Vec tool. Information entropy is calculated using recurrent neural networks and long short-term memory networks, and weighted vector fusion is performed to ultimately generate vulnerability detection results.

Benefits of technology

It improves the accuracy and scalability of vulnerability detection, enables a more comprehensive learning of the essential characteristics of vulnerabilities, reduces the impact of noisy data, and enhances the detection capabilities for access control vulnerabilities, reentrancy vulnerabilities, and timestamp-dependent vulnerabilities.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119720209B_ABST
    Figure CN119720209B_ABST
Patent Text Reader

Abstract

The application discloses a kind of based on multi-modal fusion and information entropy's smart contract vulnerability detection method and system, belong to blockchain security technical field.The method includes: the source code of smart contract, get bytecode and operation code, and generate source code token sequence, bytecode token sequence and operation code token sequence;The source code token sequence, the bytecode token sequence and the operation code token sequence are vectorized, and the information entropy of source code, bytecode and operation code is combined to carry out weighted vector fusion;Based on weighted fusion vector, generate the vulnerability detection result of smart contract.The present application can effectively detect permission control vulnerability, reentrant vulnerability and timestamp dependency vulnerability.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the field of blockchain security technology, and particularly relates to a smart contract vulnerability detection method and system based on multi-modal fusion and information entropy. BACKGROUND

[0002] Blockchain technology is widely used in modern information technology due to its key features such as tamper resistance and decentralization. As one of the core components of blockchain technology, smart contracts are widely used in various fields such as finance and gaming. A smart contract is a pre-defined logic segment that can automatically execute, record and control related events in a blockchain.

[0003] Although smart contracts are widely used, there is a lack of execution standards in smart contracts, which are often exploited as vulnerabilities to penetrate blockchain systems. Permission control vulnerabilities, re-entrant vulnerabilities and timestamp-dependent vulnerabilities are common vulnerabilities in blockchain systems. Permission control vulnerabilities: smart contracts assign different permissions to different roles, and if the permission configuration is incorrect, it can cause significant economic losses. The cross-chain bridge Poly Network was stolen $611 million due to a permission control vulnerability; re-entrant vulnerabilities: attackers recursively call contracts to transfer all internal funds of the contract. The DAO contract was stolen 3600000 ETH due to a re-entrant vulnerability; timestamp-dependent vulnerabilities: miners can modify the value of the timestamp to some extent, which makes smart contracts that rely on timestamps no longer secure. Fomo3D is a Ponzi scheme game, and the game result is strongly dependent on the timestamp. Miners increase the probability of winning the game by modifying the value of the timestamp to obtain all the funds in the contract pool. Therefore, permission control vulnerabilities, re-entrant vulnerabilities and timestamp-dependent vulnerabilities pose a serious threat to blockchain systems.

[0004] In order to detect permission control vulnerabilities, re-entrant vulnerabilities and timestamp-dependent vulnerabilities before deploying smart contracts to a blockchain, an efficient vulnerability detection method must be designed.

[0005] Currently, there are several methods for detecting vulnerabilities in smart contracts, including the following:

[0006] Scheme 1: Smart contract vulnerability detection based on expert rules. Predefined rules or manually defined patterns are used to identify vulnerabilities in smart contract code.

[0007] However, this scheme relies heavily on expert rules and is a very time-consuming and error-prone process. This scheme may produce false positives or false negatives, thereby undermining the effectiveness of accurate vulnerability detection.

[0008] Scheme 2: Deep learning-based smart contract vulnerability detection. First, a smart contract dataset is collected and labeled. Then, a deep learning model is built, and the labeled dataset is input into the model for model training. Finally, the smart contract to be detected is input into the model for vulnerability detection.

[0009] However, the existing scheme has certain limitations, i.e., mainly focusing on using a single type of feature as the input of the deep learning model. The disadvantage is that the limited perspective makes it difficult for the deep learning model to deeply analyze the nature of the vulnerability features. At the same time, equal treatment of different types of features will reduce the vulnerability detection performance of the deep learning model to some extent. Therefore, due to the low accuracy and other technical defects, the existing scheme cannot effectively detect permission control vulnerabilities, reentrant vulnerabilities, and timestamp-dependent vulnerabilities. SUMMARY

[0010] To solve the above problems, the present application discloses a smart contract vulnerability detection method and system based on multi-modal fusion and information entropy, which can effectively detect permission control vulnerabilities, reentrant vulnerabilities, and timestamp-dependent vulnerabilities.

[0011] To achieve the above-mentioned application purposes, the technical scheme of the present application includes the following contents.

[0012] A smart contract vulnerability detection method based on multi-modal fusion and information entropy, the method comprising:

[0013] Parsing the source code of the smart contract to obtain bytecode and operation code, and generating a source code token sequence, a bytecode token sequence, and an operation code token sequence;

[0014] Vectorizing the source code token sequence, the bytecode token sequence, and the operation code token sequence, and combining the information entropy of the source code, bytecode, and operation code for weighted vector fusion;

[0015] Based on the weighted fusion vector, a vulnerability detection result of the smart contract is generated.

[0016] Further, the source code token sequence is generated, comprising:

[0017] Performing first denoising processing on the source code, the first denoising processing comprising: deleting blank lines, comments, and redundant spaces in the smart contract source code;

[0018] Using the Jieba tool to perform word segmentation processing on the first denoising processed source code to obtain an original source code token sequence;

[0019] Based on a fixed length, performing consistent length processing on the original source code token sequence to obtain a source code token sequence.

[0020] Further, the generating the bytecode token sequence comprises:

[0021] performing second denoising processing on the bytecode, the second denoising processing comprising: deleting deployment code and auxdata code in the bytecode;

[0022] grouping every two bytes of the bytecode after the second denoising processing as a group and performing segmentation using a regular expression to obtain an original bytecode token sequence;

[0023] performing length-consistent processing on the original bytecode token sequence based on a fixed length to obtain a bytecode token sequence.

[0024] Further, the generating the opcode token sequence comprises:

[0025] performing third denoising processing on the opcode, the third denoising processing comprising: deleting parameters after a PUSH instruction;

[0026] generating an original opcode sequence by replacing the PUSH instruction with PUSH1-PUSH32 instructions, replacing the DUP instruction with DUP1-DUP16 instructions, replacing the SWAP instruction with SWAP1-SWAP16 instructions, and replacing the LOG instruction with LOG1-LOG4 instructions;

[0027] performing length-consistent processing on the original opcode token sequence based on a fixed length to obtain an opcode token sequence.

[0028] Further, vectorizing the source code token sequence, the bytecode token sequence, and the opcode token sequence, and combining information entropy of source code, bytecode, and opcode for weighted vector fusion, comprising:

[0029] using a Word2Vec tool to respectively map each token in the source code token sequence, the bytecode token sequence, and the opcode token sequence into a vector to obtain a source code token vector sequence, a bytecode token vector sequence, and an opcode token vector sequence;

[0030] taking the source code token vector sequence as input of a recurrent neural network to obtain a source code vector representation;

[0031] taking the bytecode token vector sequence as input of a gated recurrent neural network to obtain a bytecode vector representation;

[0032] taking the opcode token vector sequence as input of a long short-term memory neural network to obtain an opcode vector representation;

[0033] respectively calculating average information entropy of source code, bytecode, and opcode;

[0034] weighting vector fusion is performed on the source code vector representation, the bytecode vector representation and the operation code vector representation based on average information entropy of source code, bytecode and operation code to obtain a weighted fusion vector.

[0035] Further, the average information entropy of the source code is calculated, including:

[0036] obtaining the length T of the source code token sequence and the probability p(t) of each token t in the source code token sequence appearing in the source code token sequence;

[0037] based on the length T of the source code token sequence and the probability p(t), the average information entropy of the source code is obtained.

[0038] Further, the weighted fusion vector is used to generate a vulnerability detection result of the smart contract, including:

[0039] performing BatchNormalization processing and Dropout processing on the weighted fusion vector V to obtain a weighted fusion vector V';

[0040] using a Dense layer to perform dimension reduction processing on the weighted fusion vector V' to obtain a weighted fusion vector V";

[0041] performing BatchNormalization processing and Dropout processing on the weighted fusion vector V" to obtain a weighted fusion vector V''' ;

[0042] using a Dense layer to perform dimension reduction processing on the weighted fusion vector V''' to obtain a probability that the smart contract has a vulnerability risk.

[0043] A smart contract vulnerability detection system based on multi-modal fusion and information entropy, characterized in that the system comprises:

[0044] a parsing module for parsing the source code of the smart contract to obtain bytecode and operation code, and generating a source code token sequence, a bytecode token sequence and an operation code token sequence;

[0045] a mapping module for vectorizing the source code token sequence, the bytecode token sequence and the operation code token sequence, and performing weighted vector fusion in combination with the information entropy of source code, bytecode and operation code;

[0046] a detection module for generating a vulnerability detection result of the smart contract based on the weighted fusion vector.

[0047] An electronic device, characterized in that the electronic device comprises: a processor and a memory storing computer program instructions; the processor, when executing the computer program instructions, implements the smart contract vulnerability detection method based on multimodal fusion and information entropy as described in any one of the preceding claims.

[0048] A computer-readable storage medium, characterized in that the computer-readable storage medium stores computer program instructions, which, when executed by a processor, implement the smart contract vulnerability detection method based on multimodal fusion and information entropy as described in any one of claims 1-7.

[0049] Compared with the prior art, the present invention has at least the following beneficial effects.

[0050] 1. This method achieves good accuracy. Specifically: denoising reduces the impact of noisy data on vulnerability detection accuracy; assigning higher weights to modal features containing more information helps the artificial neural network learn more vulnerability-related information, thereby improving vulnerability detection accuracy; multimodal weighted vector fusion enables the artificial neural network to learn the essential features of vulnerabilities from multiple angles and perspectives, thus improving vulnerability detection accuracy.

[0051] 2. This method has good scalability. Specifically, it is easy to integrate new modal features into existing models. Attached Figure Description

[0052] Figure 1 This is a schematic diagram of a smart contract vulnerability detection method based on multimodal fusion and information entropy according to the present invention. Detailed Implementation

[0053] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described in detail below through specific implementations and in conjunction with the accompanying drawings.

[0054] like Figure 1 As shown, a smart contract vulnerability detection method based on multimodal fusion and information entropy includes the following steps:

[0055] Step 1: Perform noise reduction, word segmentation, and length consistency processing on the smart contract source code.

[0056] Specifically, step 1 includes the following steps:

[0057] Step 1.1: Delete blank lines, comments, and extra spaces.

[0058] Step 1.2: Use the 'Jieba' tool to perform word segmentation on the smart contract source code to obtain the source code token sequence.

[0059] Step 1.3: Set a fixed length of the source code token sequence. If the length of the source code token sequence is greater than the fixed length, perform a truncation process. Specifically, delete the source code tokens that exceed the fixed length. If the length of the source code token sequence is less than the fixed length, perform a padding process. Specifically, use'' to fill the source code tokens that are less than the fixed length. <pad>The character fills the source code token sequence, so that its length is equal to the fixed length.

[0060] Step 2: parse the smart contract source code into bytecode and perform denoising processing, segmentation processing and length consistency processing on it.

[0061] Specifically, step 2 includes the following steps:

[0062] Step 2.1: parse the smart contract source code into bytecode using the py-solc package.

[0063] Step 2.2: the bytecode is composed of deployment code, running code and auxdata code. The running code and auxdata code are stored on the blockchain after the deployment code runs. The deployment code is not stored on the blockchain. The auxdata code contains some auxiliary information of the smart contract, such as compilation version information, etc. These information and vulnerability features are irrelevant. Therefore, delete the deployment code and auxdata code, and only keep the running code.

[0064] Step 2.3: every two bytes of bytecode is a group, and the running code is segmented using regular expressions to obtain a bytecode token sequence.

[0065] Step 2.4: set the fixed length of the bytecode token sequence. If the length of the bytecode token sequence is greater than the fixed length, perform truncation processing. The specific operation is to delete the excess bytecode tokens. If the length of the bytecode token sequence is less than the fixed length, perform padding processing. The specific operation is to use'to fill the source code token sequence, so that its length is equal to the fixed length. <pad>The bytecode token sequence is padded with the character to make its length equal to the fixed length.

[0066] Step 3: Parse the smart contract source code into operation codes and perform denoising and length consistency processing thereon.

[0067] Specifically, step 3 includes the following steps:

[0068] Step 3.1: Parse the smart contract source code into operation codes using the py-solc package.

[0069] Step 3.2: The parameters after the PUSH instruction in the operation code are irrelevant to the vulnerability characteristics, and all the parameters after the PUSH instruction in the operation code are deleted, thereby obtaining the denoised operation code.

[0070] Step 3.3: Simplify the denoised operation code, specifically, replace ‘PUSH1-PUSH32’ with ‘PUSH’, replace ‘DUP1-DUP16’ with ‘DUP’, replace ‘SWAP1-SWAP16’ with ‘SWAP’, and replace ‘LOG1-LOG4’ with ‘LOG’, to obtain the denoised operation code token sequence.

[0071] Step 3.4: Set the fixed length of the operation code token sequence. If the length of the operation code token sequence is greater than the fixed length, perform truncation processing. Specifically, delete the operation code tokens that exceed the fixed length. If the length of the operation code token sequence is less than the fixed length, perform padding processing. Specifically, use the character to pad the operation code token sequence to the fixed length. <pad>The 'char pad opcode token sequence is padded to a fixed length.

[0072] Step 4: Map each token in the source code token sequence, the bytecode token sequence, and the opcode token sequence into a numerical vector through a code embedding technique to obtain a source code token vector sequence, a bytecode token vector sequence, and an opcode token vector sequence. The code embedding technique refers to mapping code into a numerical vector.

[0073] Specifically, step 4 includes the following steps:

[0074] Step 4.1: Map each token in the smart contract source code token sequence into a 256-dimensional numerical vector using the Word2Vec tool. That is, code = [C1, C2, C3…C n ] is mapped to code_vector = [V1, V2, V3…V n ]. Wherein C n represents the nth token in the source code token sequence, and V n represents the 256-dimensional numerical vector corresponding to the nth token.

[0075] Step 4.2: Map each token in the smart contract bytecode token sequence into a 256-dimensional numerical vector using the Word2Vec tool. That is, bytecode = [B1, B2, B3…B n ] is mapped to bytecode_vector = [V1, V2, V3…V n ]. Wherein B n represents the nth token in the bytecode token sequence, and V n represents the 256-dimensional numerical vector corresponding to the nth token.

[0076] Step 4.3: Map each token in the smart contract opcode token sequence into a 256-dimensional numerical vector using the Word2Vec tool. That is, opcode = [O1, O2, O3…O n ] is mapped to opcode_vector = [V1, V2, V3…V n ]. Wherein O n represents the nth token in the opcode token sequence, and V n represents the 256-dimensional numerical vector corresponding to the nth token.

[0077] Step 5: Smart contract source code vectorization, smart contract bytecode vectorization, and smart contract opcode vectorization.

[0078] Specifically, step 5 includes the following steps:

[0079] Step 5.1: The token vector sequence corresponding to the token sequence of the smart contract source code is input into a recurrent neural network (RNN), and a 64-dimensional numerical vector representing the smart contract source code vector is output.

[0080] Step 5.2: The token vector sequence corresponding to the token sequence of the smart contract bytecode is input into a gated recurrent unit (GRU) model, and a 64-dimensional numerical vector representing the smart contract bytecode vector is output.

[0081] Step 5.3: The token vector sequence corresponding to the token sequence of the smart contract operation code is input into a long short-term memory (LSTM) neural network, and a 64-dimensional numerical vector representing the smart contract operation code vector is output.

[0082] Step 6: Calculation of the average information entropy of the smart contract source code, bytecode, and operation code. The information entropy is a measure of the amount of information contained in the information.

[0083] Specifically, step 6 includes the following steps:

[0084] Step 6.1: Calculate the average information entropy of the smart contract source code based on formula (1). Where T represents the length of the token sequence of the smart contract source code, t represents a token in the token sequence of the smart contract source code, and p(t) represents the probability of token t appearing in the token sequence of the source code.

[0085] Step 6.2: Calculate the average information entropy of the smart contract bytecode based on formula (1). Where T represents the length of the token sequence of the smart contract bytecode, t represents a token in the token sequence of the smart contract bytecode, and p(t) represents the probability of token t appearing in the token sequence of the bytecode.

[0086] Step 6.3: Calculate the average information entropy of the smart contract operation code based on formula (1). Where T represents the length of the token sequence of the smart contract operation code, t represents a token in the token sequence of the smart contract operation code, and p(t) represents the probability of token t appearing in the token sequence of the operation code.

[0087]

[0088] Step 7: Weighted vector fusion of the smart contract source code, bytecode, and operation code.

[0089] Specifically, step 7 includes the following steps:

[0090] Step 7.1: Multiply the smart contract source code vector and the average information entropy of the smart contract source code to obtain the source code weighted vector. The source code weighted vector has a dimension of 64.

[0091] Step 7.2: The bytecode weighted vector is obtained by multiplying the smart contract bytecode vector and the average information entropy of the smart contract bytecode. The bytecode weighted vector has a dimension of 64.

[0092] Step 7.3: The opcode weighted vector is obtained by multiplying the smart contract opcode vector and the average information entropy of the smart contract opcode. The opcode weighted vector has a dimension of 64.

[0093] Step 7.4: The source code weighted vector, the bytecode weighted vector, and the opcode weighted vector are horizontally spliced to obtain the weighted fusion vector. The weighted fusion vector has a dimension of 192.

[0094] Step 8: The potential features of the weighted fusion vector are learned by an artificial neural network, and vulnerability detection is performed.

[0095] Specifically, step 8 includes the following steps:

[0096] Step 8.1: Perform BatchNormalization processing and Dropout processing on the weighted fusion vector.

[0097] Step 8.2: Perform dimension reduction processing on the processed weighted fusion vector using a Dense layer. The dimension of the reduced vector is 64.

[0098] Step 8.3: Perform BatchNormalization processing and Dropout processing on the 64-dimensional vector.

[0099] Step 8.4: Perform dimension reduction processing on the 64-dimensional vector using a Dense layer. The dimension of the reduced vector is 1. This value represents the probability of the smart contract having a vulnerability risk.

[0100] Next, a specific experiment is used to illustrate the smart contract vulnerability detection method based on multi-modal fusion and information entropy provided by the present application.

[0101] Experimental hardware configuration: The experiment was conducted on a server computing node with a CentOS operating system, and the computing node was equipped with Intel Xeon E5-2620 v4 processors. The processor model is 2.40GHz, 6 cores. The memory is 64GiB.

[0102] Experimental software configuration: The code is written in Python 3.7.3, and the third-party libraries used during the process include Keras2.11.0, Numpy 1.21.6, etc.

[0103] Experimental data:

[0104]

[0105] wherein document 1 refers to the algorithm proposed by Duy et al. (Duy PT, Khoa NH, Quyen NH, et al (2023) Vulnsense: Efficient vulnerability detection in ethereum smart contracts by multimodal learning with graph neural network and language model. arXiv preprint arXiv:230908474.).

[0106] The above is one of the embodiments of the present application, and the present application should not be limited to the content disclosed in the embodiment and the drawings. Any equivalent or modification made without departing from the spirit disclosed in the present application falls within the scope of protection of the present application.< / pad> < / pad> < / pad>

Claims

1. A smart contract vulnerability detection method based on multimodal fusion and information entropy, characterized in that, The method includes: Parse the source code of the smart contract to obtain bytecode and opcode, and generate source code token sequence, bytecode token sequence and opcode token sequence; The source code token sequence, the bytecode token sequence, and the opcode token sequence are vectorized, and weighted vector fusion is performed by combining the information entropy of the source code, bytecode, and opcode. Based on the weighted fusion vector, vulnerability detection results for smart contracts are generated; The process of vectorizing the source code token sequence, the bytecode token sequence, and the opcode token sequence, and then performing weighted vector fusion by combining the information entropy of the source code, bytecode, and opcode, includes: Using the Word2Vec tool, each token in the source code token sequence, the bytecode token sequence, and the opcode token sequence is mapped to a vector to obtain the source code token vector sequence, the bytecode token vector sequence, and the opcode token vector sequence, respectively. The source code token vector sequence is used as input to a recurrent neural network to obtain a source code vector representation; The bytecode token vector sequence is used as input to a gated recurrent neural network to obtain a bytecode vector representation; The opcode token vector sequence is used as input to a long short-term memory neural network to obtain an opcode vector representation; The average information entropy of the smart contract source code is calculated based on the length of the smart contract source code token sequence, the token t1 in the smart contract source code token sequence, and the probability of the token t1 appearing in the source code token sequence. The average information entropy of the smart contract bytecode is calculated based on the length of the smart contract bytecode token sequence, the token t2 in the smart contract bytecode token sequence, and the probability of the token t2 appearing in the bytecode token sequence. The average information entropy of the smart contract opcode is calculated based on the length of the smart contract opcode token sequence, the token t3 in the smart contract opcode sequence, and the probability of the token t3 appearing in the opcode token sequence. Multiply the source code vector representation by the average information entropy of the smart contract source code to obtain the source code weighted vector; Multiply the bytecode vector representation by the average information entropy of the smart contract bytecode to obtain the bytecode weighted vector; Multiply the opcode vector representation by the average information entropy of the smart contract opcode to obtain the opcode weighted vector; The source code weighted vector, bytecode weighted vector, and opcode weighted vector are horizontally concatenated to obtain a weighted fusion vector; The generation of smart contract vulnerability detection results based on weighted fusion vectors includes: Perform BatchNormalization and Dropout processing on the weighted fusion vector V to obtain the weighted fusion vector V0. ′ ; Use a Dense layer to weight the fusion vector V ′ Dimensionality reduction is performed to obtain the weighted fusion vector V″; Perform BatchNormalization and Dropout processing on the weighted fusion vector V″ to obtain the weighted fusion vector V″′; The Dense layer is used to reduce the dimensionality of the weighted fusion vector V″′ to obtain the probability that the smart contract has a vulnerability risk.

2. The method according to claim 1, characterized in that, The generated source code token sequence includes: The source code is subjected to a first denoising process, which includes: deleting blank lines, comments, and extra spaces in the smart contract source code; The source code after the first denoising process is segmented using the Jieba tool to obtain the original source code token sequence; based on a fixed length, the original source code token sequence is subjected to length consistency processing to obtain the source code token sequence.

3. The method according to claim 1, characterized in that, The generation of the bytecode token sequence includes: The bytecode is subjected to a second denoising process, which includes: removing deployment code and auxdata code from the bytecode; For the bytecode after the second denoising process, group every two bytes together and split them using a regular expression to obtain the original bytecode token sequence; Based on a fixed length, the original bytecode token sequence is processed to achieve length consistency, resulting in a bytecode token sequence.

4. The method according to claim 1, characterized in that, The generation of the opcode token sequence includes: The opcode is subjected to a third denoising process, which includes deleting the parameters after the PUSH instruction. The original opcode sequence is generated by replacing the PUSH instruction with PUSH1-PUSH32 instructions, the DUP instruction with DUP1-DUP16 instructions, the SWAP instruction with SWAP1-SWAP16 instructions, and the LOG instruction with LOG1-LOG4 instructions. Based on a fixed length, the original opcode token sequence is processed to achieve length consistency, resulting in an opcode token sequence.

5. A smart contract vulnerability detection system based on multimodal fusion and information entropy, characterized in that, The system includes: The parsing module is used to parse the source code of smart contracts, obtain bytecode and opcode, and generate source code token sequences, bytecode token sequences, and opcode token sequences. The mapping module is used to vectorize the source code token sequence, the bytecode token sequence, and the opcode token sequence, and to perform weighted vector fusion by combining the information entropy of the source code, bytecode, and opcode. The detection module is used to generate vulnerability detection results for smart contracts based on weighted fusion vectors. The process of vectorizing the source code token sequence, the bytecode token sequence, and the opcode token sequence, and then performing weighted vector fusion by combining the information entropy of the source code, bytecode, and opcode, includes: Using the Word2Vec tool, each token in the source code token sequence, the bytecode token sequence, and the opcode token sequence is mapped to a vector to obtain the source code token vector sequence, the bytecode token vector sequence, and the opcode token vector sequence, respectively. The source code token vector sequence is used as input to a recurrent neural network to obtain a source code vector representation; The bytecode token vector sequence is used as input to a gated recurrent neural network to obtain a bytecode vector representation; The opcode token vector sequence is used as input to a long short-term memory neural network to obtain an opcode vector representation; The average information entropy of the smart contract source code is calculated based on the length of the smart contract source code token sequence, the token t1 in the smart contract source code token sequence, and the probability of the token t1 appearing in the source code token sequence. The average information entropy of the smart contract bytecode is calculated based on the length of the smart contract bytecode token sequence, the token t2 in the smart contract bytecode token sequence, and the probability of the token t2 appearing in the bytecode token sequence. The average information entropy of the smart contract opcode is calculated based on the length of the smart contract opcode token sequence, the token t3 in the smart contract opcode sequence, and the probability of the token t3 appearing in the opcode token sequence. Multiply the source code vector representation by the average information entropy of the smart contract source code to obtain the source code weighted vector; Multiply the bytecode vector representation by the average information entropy of the smart contract bytecode to obtain the bytecode weighted vector; Multiply the opcode vector representation by the average information entropy of the smart contract opcode to obtain the opcode weighted vector; The source code weighted vector, bytecode weighted vector, and opcode weighted vector are horizontally concatenated to obtain a weighted fusion vector; The generation of smart contract vulnerability detection results based on weighted fusion vectors includes: Perform BatchNormalization and Dropout processing on the weighted fusion vector V to obtain the weighted fusion vector V0. ′ ; Use a Dense layer to weight the fusion vector V ′ Dimensionality reduction is performed to obtain the weighted fusion vector V″; Perform BatchNormalization and Dropout processing on the weighted fusion vector V″ to obtain the weighted fusion vector V″′; The Dense layer is used to reduce the dimensionality of the weighted fusion vector V″′ to obtain the probability that the smart contract has a vulnerability risk.

6. An electronic device, characterized in that, The electronic device includes: a processor and a memory storing computer program instructions; when the processor executes the computer program instructions, it implements the smart contract vulnerability detection method based on multimodal fusion and information entropy as described in any one of claims 1-4.

7. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer program instructions, which, when executed by a processor, implement the smart contract vulnerability detection method based on multimodal fusion and information entropy as described in any one of claims 1-4.

Citation Information

Patent Citations

  • Intelligent contract vulnerability detection method and system based on multiple modes

    CN118940272A

  • Malicious code detection method, device and equipment based on multi-modal feature fusion

    CN120470585A