Intelligent contract vulnerability detection method and device based on multi-source data and electronic equipment

By integrating multi-source data and analyzing feature differences, the problem of insufficient accuracy in smart contract vulnerability detection has been solved, enabling more efficient vulnerability detection and security assessment, reducing manual intervention, and improving the security of smart contracts.

CN119299196AActive Publication Date: 2025-01-10BEIHANG UNIV
View PDF 7 Cites 0 Cited by

Patent Information

Application Number
CN202411451730.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-10-17
Publication Date
2025-01-10
Estimated Expiration
2044-10-17

AI Technical Summary

Technical Problem

Existing smart contract vulnerability detection methods cannot effectively integrate multiple data sources, resulting in insufficient accuracy in vulnerability detection and a high risk of missed or false detections, which affects the security of smart contracts.

Method used

By acquiring multi-source data, including vulnerable source code and bytecode, features at the source code layer, build layer, and bytecode layer are extracted, these features are fused to determine key feature differences, and vulnerability detection algorithms are used to monitor the contract's running status in real time, reducing human intervention.

Benefits of technology

It improves the accuracy of smart contract vulnerability detection, reduces missed and false detections, enhances the security assessment of contracts, enables the timely detection of potential security issues, and improves development efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119299196A_ABST
    Figure CN119299196A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of network data security, in particular to an intelligent contract vulnerability detection method and device based on multi-source data and electronic device.The method comprises the steps that vulnerability information data are acquired, and the vulnerability information data comprise vulnerability source codes and vulnerability byte codes; extraction is carried out based on the vulnerability information data, key features are determined, and the key features comprise source code layer features, construction layer features and byte code layer features; based on the source code layer features, the construction layer features and the byte code layer features, determining fusion layer features; based on the key features, the fusion layer features and a vulnerability detection algorithm, determining feature differences; and based on the feature difference, determining the smart contract vulnerability. According to the invention, the accuracy of vulnerability detection of the smart contract is greatly improved, missing detection and false detection are reduced, and thus the security judgment of the smart contract is enhanced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of network data security technology, and in particular to a smart contract vulnerability detection method, device and electronic device based on multi-source data. Background Art

[0002] With the rapid development of blockchain technology, smart contracts, as an important tool for realizing decentralized applications, are being widely used in finance, supply chain management, the Internet of Things and other fields. Smart contracts automatically execute contract terms through programming codes, and have the characteristics of being tamper-proof and self-executing, which can effectively reduce transaction costs and improve efficiency. However, the security issues of smart contracts have also become prominent. Since the code of smart contracts cannot be modified once deployed on the blockchain, its vulnerabilities may lead to serious consequences such as financial losses and data leakage, bringing huge risks to users and developers. The emergence of smart contract vulnerabilities is mainly due to imperfect codes, logical errors and lack of programming specifications. Common vulnerabilities include reentrancy attacks, integer overflows, timestamp dependencies, etc. If these vulnerabilities are not discovered and repaired in time, they will have adverse social impacts and reduce users' trust in blockchain technology.

[0003] In view of this, this application is filed. Summary of the invention

[0004] In order to solve the above technical problems or at least partially solve the above technical problems, the embodiments of the present disclosure provide a smart contract vulnerability detection method, device and electronic device based on multi-source data, which can effectively improve the accuracy of vulnerability detection, reduce missed detections and false detections, and thus enhance the security judgment of smart contracts.

[0005] In a first aspect, an embodiment of the present disclosure provides a smart contract vulnerability detection method based on multi-source data, the method comprising:

[0006] Acquire vulnerability information data, wherein the vulnerability information data includes vulnerability source code and vulnerability bytecode;

[0007] Extracting based on the vulnerability information data, determining key features, the key features including source code layer features, build layer features, and bytecode layer features;

[0008] Determining fusion layer features based on the source code layer features, the construction layer features, and the bytecode layer features;

[0009] Determining feature differences based on the key features, the fusion layer features, and the vulnerability detection algorithm;

[0010] Based on the feature differences, the smart contract vulnerability is determined.

[0011] In a second aspect, the disclosed embodiment further provides a smart contract vulnerability detection device for multi-source data, the device comprising:

[0012] A first acquisition module, used to acquire vulnerability information data, wherein the vulnerability information data includes vulnerability source code and vulnerability bytecode;

[0013] A first determination module is used to extract and determine key features based on the vulnerability information data, wherein the key features include source code layer features, construction layer features, and bytecode layer features;

[0014] A second determination module determines a fusion layer feature based on the source code layer feature, the construction layer feature and the bytecode layer feature;

[0015] A third determination module is used to determine feature differences between the key features, the fusion layer features and the vulnerability detection algorithm;

[0016] The fourth determination module is used to determine the smart contract vulnerability based on the feature difference.

[0017] In a third aspect, an embodiment of the present disclosure further provides an electronic device, comprising: one or more processors; a storage device for storing one or more programs; when the one or more programs are executed by the one or more processors, the one or more processors implement the smart contract vulnerability detection method based on multi-source data as described above.

[0018] In a fourth aspect, an embodiment of the present disclosure further provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the smart contract vulnerability detection method based on multi-source data as described above.

[0019] The multi-source data smart contract vulnerability detection method provided by the embodiment of the present disclosure, by fusing source code layer features, construction layer features and bytecode layer features from different sources, is conducive to more accurate identification of vulnerabilities and security risks in contracts, and by enhancing the security of smart contracts, and then using a smart contract vulnerability detection algorithm to determine the difference between key features and fusion layer features to obtain smart contract vulnerabilities. The vulnerability detection algorithm can monitor the running status of the contract in real time, promptly discover and report potential security issues, reduce the need for manual intervention, further improve the accuracy of vulnerability detection, reduce missed detections and false detections, and thus enhance the security judgment of smart contracts. BRIEF DESCRIPTION OF THE DRAWINGS

[0020] The above and other features, advantages and aspects of the embodiments of the present disclosure will become more apparent with reference to the following detailed description in conjunction with the accompanying drawings. Throughout the accompanying drawings, the same or similar reference numerals represent the same or similar elements. It should be understood that the drawings are schematic and the originals and elements are not necessarily drawn to scale.

[0021] Figure 1 The present invention is a flowchart of a method for detecting smart contract vulnerabilities in multi-source data in an embodiment of the present invention.

[0022] Figure 2 Schematic diagram of the structure of a smart contract vulnerability detection device based on multi-source data in an embodiment of the present disclosure.

[0023] Figure 3 It is a structural schematic diagram of an electronic device in an embodiment of the present disclosure. DETAILED DESCRIPTION

[0024] Embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although certain embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be construed as being limited to the embodiments described herein, which are instead provided for a more thorough and complete understanding of the present disclosure. It should be understood that the drawings and embodiments of the present disclosure are only for exemplary purposes and are not intended to limit the scope of protection of the present disclosure.

[0025] It should be noted that the concepts such as "first" and "second" mentioned in the present disclosure are only used to distinguish different devices, modules or units, and are not used to limit the order or interdependence of the functions performed by these devices, modules or units.

[0026] The names of the messages or information exchanged between multiple devices in the embodiments of the present disclosure are only used for illustrative purposes and are not used to limit the scope of these messages or information.

[0027] At present, the main detection methods for smart contract vulnerabilities include static analysis, dynamic analysis, and formal verification. These methods have their own advantages and disadvantages. Static analysis can quickly discover potential problems in the code, but it is easy to produce false positives; dynamic analysis can be detected when the contract is actually running, which can more realistically reflect the operation of the contract, but it requires more test cases and environment settings, and the amount of data collected is large, and the efficiency is low; formal verification can theoretically provide a higher security guarantee, but the implementation is complex and has high requirements for developers. With the increasing application scenarios of blockchain, different types of data sources are also gradually increasing, such as transaction data, on-chain data, user behavior data, etc. Traditional vulnerability detection methods often only focus on static or dynamic analysis at the code level, while ignoring the integration and in-depth analysis of data from other sources.

[0028] In response to the above problems, the embodiments of the present disclosure provide a smart contract vulnerability detection method based on multi-source data, which effectively improves the accuracy of smart contract vulnerability detection, reduces missed detections and false detections, thereby enhancing the security judgment of smart contracts, and can monitor the running status of contracts in real time, promptly discover and report potential security issues, reduce the need for manual intervention, and improve development efficiency.

[0029] Figure 1 1 is a flow chart of a smart contract vulnerability detection method based on multi-source data in an embodiment of the present disclosure. The method can be executed by a smart contract vulnerability detection device based on multi-source data, which can be implemented in software and / or hardware, and can be configured in an electronic device. Figure 1 As shown, the method may specifically include the following steps:

[0030] S110. Acquire vulnerability information data, where the vulnerability information data includes vulnerability source code and vulnerability bytecode.

[0031] Among them, the vulnerability information data can be the vulnerability source code and vulnerability bytecode data of multiple vulnerabilities corresponding to the transaction records, event logs, state changes and other information of the smart contract obtained from the blockchain network. The vulnerability source code data and vulnerability bytecode data can be used to analyze the historical behavior and usage patterns of the smart contract.

[0032] S120: extracting based on the vulnerability information data to determine key features, where the key features include source code layer features, build layer features, and bytecode layer features.

[0033] Specifically, feature extraction is performed on the vulnerability source code and vulnerability bytecode in the above vulnerability information data, and data that can reflect the security and potential risks of smart contract behavior is extracted as key features. The key features include source code layer features, construction layer features, and bytecode layer features. The source code layer is the initial stage of smart contract development and is written in a readable high-level programming language. Separate semantic representations of vulnerability source code and comments can generate source code layer features. ,The source code layer features reflect the high-level semantics and structure of the ,smart contract, and are a direct reflection of the developer’s intention and ,contract logic.

[0034] Among them, the expression of source code layer features is: ,

[0035] in, Represents source code layer features, Represents a text sequence of the source code of the vulnerability, The encoding features representing the vulnerable source code text sequence, The offset term representing the text sequence of the vulnerable source code, express The length of the sequence.

[0036] It should be noted that the encoding features of the source code text sequence are the conversion of the source code text sequence into numerical form. These encoding features are extracted from the source code, including the encoding of the code's keywords, structure, control flow, data flow, etc.

[0037] Then, the construction layer involves the compilation process of the smart contract. The construction layer extracts the abstract syntax tree features from the vulnerable source code. and code semantic features The abstract syntax tree is a tree-like structure representation of the source code, which captures the organization of the code and the complex dependencies of the control flow and data flow. The construction layer features contain rich syntactic and structural information, such as node types, control flow structures, and expression types. These features reveal the inherent connection of the contract logic. The expression of the abstract syntax tree feature is: ,

[0038] The expression of the code semantic feature is: ,

[0039] in, Represents source code layer features, Represents a text sequence of the source code of the vulnerability, express Midpoint Type , Represents control flow structure , Indicates the expression type , Represents the semantic features of the code, express Medium parameter variables , express Medium Function , express Medium data type .

[0040] It should be noted that Represents a specific type of node Whether it exists in the abstract syntax tree of the source code. It is used to indicate whether a specific syntax structure appears in the code. Different types of nodes represent different syntax elements. For example, a node may represent an if statement. If this statement exists, the node is encoded as 1, otherwise it is 0. , , , as well as and If it exists in the source code, it is encoded as 1, if it does not exist, it is encoded as 0.

[0041] It is understandable that the bytecode layer is a low-level representation of the compiled smart contract, usually composed of a series of opcodes, which are specific instructions that the virtual machine can execute. The bytecode of the smart contract is converted into assembly code that is easier to analyze through a disassembler to obtain the bytecode layer features. Bytecode layer features can include opcodes, control flow structures, and access modifiers. These features are low-level descriptions of smart contract behavior and are closer to the code executed by the blockchain virtual machine. The bytecode of the smart contract vulnerability is converted into assembly code that is easier to analyze through a disassembler to obtain the bytecode layer features, where the expression of the bytecode layer features is: ,

[0042] in, Represents bytecode-level features, express Medium opcode , express Control flow structure , express Access modifiers .

[0043] In this embodiment, the multi-source features of the smart contract are constructed through the feature extraction of the above three layers of modalities. Each layer provides a different perspective of the contract. The key features of the smart contract provide comprehensive data support for security testing. Secondly, the specific methods and implementation plans of feature selection and extraction are protected to ensure their uniqueness and application effect, and enhance the accuracy of vulnerability detection.

[0044] It should be noted that the node type (NodeType): each component of the source code (such as variables, functions, control structures, expressions, etc.) is represented as a "node". Each node type describes the role or type of the node in the syntax tree. For example: variable node: represents the declaration or use of a variable. Function node: represents the definition or call of a function. Control structure node: represents the structure of a conditional statement (such as if, switch) or a loop (such as for, while). Expression node: represents the structure of a calculation expression (such as arithmetic operations, logical operations). Different node type designs reflect the structure and logic of the source code, enabling analysis tools to understand the intent and behavior of the code. Control flow structure (ControlStructure): refers to the grammatical structure in the source code that determines the execution order of the program. This includes: conditional statements: such as if, else, switch, etc., used to determine the execution of different code blocks based on conditions. Loop structures: such as for, while, do-while, etc., used to repeatedly execute a code block until a certain condition is no longer met. Jump statements: such as break, continue, return, etc., used to change the normal execution flow. Control flow structures are crucial to the logical control of a program and are therefore crucial in vulnerability detection, as many vulnerabilities are related to the execution path of a program. Expression Type: describes the different types of expressions used in source code. An expression is composed of operands and operators and is a representation of a computable value. Common expression types include: Arithmetic expressions: calculations involving operators such as addition, subtraction, multiplication, and division. Logical expressions: Boolean operations using logical operators such as AND, OR, NOT. Relational expressions: comparison operations such as less than, greater than, greater than or equal to, etc. Assignment expressions: expressions used for assignment, such as a = b + c.

[0045] S130: Determine fusion layer features based on the source code layer features, the construction layer features, and the bytecode layer features.

[0046] In one embodiment, determining the fusion layer feature based on the source code layer feature, the construction layer feature and the bytecode layer feature includes:

[0047] Based on the source code layer feature, the abstract syntax tree feature, the code semantic feature and the bytecode layer feature and their corresponding weight factors, a fusion layer feature is determined.

[0048] On the basis of the above embodiment, after the source code layer features, the construction layer features and the bytecode layer features are obtained, the source code layer features, the construction layer features and the bytecode layer features are fused to obtain the fusion layer features. Specifically, the source code layer features and their corresponding weight factors, the abstract syntax tree features and their corresponding weight factors, the code semantic features and their corresponding weight factors, and the bytecode layer features and their corresponding weight factors are fused to obtain the fusion layer features.

[0049] The expression of the fusion layer feature is: ,

[0050] in, represents the fusion layer features, express The corresponding weight factor is express The corresponding weight factor is express The corresponding weight factor is express The corresponding weight factor is express The corresponding weight factor is represents the first fusion factor, represents the second fusion factor, Indicates feature point addition operation, Represents the feature point multiplication operation.

[0051] In this embodiment, the source code layer features, construction layer features and bytecode layer features from different sources are integrated, which is conducive to more accurately identifying vulnerabilities and security risks in the contract, thereby enhancing the security of the smart contract.

[0052] It should be noted that multi-source data refers to data from different sources, and the data sources can be transaction records, event logs, and status changes of smart contracts.

[0053] S140: Determine feature differences based on the key features, the fusion layer features, and the vulnerability detection algorithm.

[0054] In one embodiment, before determining the feature difference based on the key feature, the fusion layer feature and the vulnerability detection algorithm, the method includes:

[0055] A vulnerability detection algorithm is determined based on the key feature, the fusion layer feature, the feature size of the key feature, the feature size of the fusion layer feature, a first feature difference adjustment factor, a second feature difference adjustment factor, and a third feature difference adjustment factor.

[0056] In smart contract vulnerability detection, by taking advantage of the fusion of multi-source data, a more intelligent and comprehensive detection model can be established by comprehensively analyzing on-chain transaction data, historical attack samples, user behavior patterns and other information. For example, combined with the historical vulnerability database of smart contracts, we can analyze past attack events of similar contracts, thereby providing an important reference for vulnerability detection of new contracts. In addition, with the development of machine learning and artificial intelligence technology, smart contract vulnerability detection methods based on model learning have gradually attracted attention. By training deep learning models, potential vulnerability patterns can be learned from a large number of contract features. If combined with multi-source data, not only can the detection accuracy of the model be improved, but also the false alarm rate can be greatly reduced. In order to achieve this goal, it is necessary to design a representative feature set to extract key features of smart contracts from multiple aspects such as code structure, call relationship, transaction history, etc. The advantages of integrating multi-source data make the vulnerability detection system not only limited to the analysis of the internal code of the contract, but also introduce the influence of external environmental factors, such as the historical records of contract interactions and the behavior patterns of user accounts.

[0057] Exemplarily, before the key features and the fusion layer features are input into the vulnerability detection algorithm, it is necessary to construct the vulnerability detection algorithm. Specifically, the vulnerability detection algorithm is constructed based on the key features, the fusion layer features, the feature size of the key features, the feature size of the fusion layer features, the first feature difference adjustment factor, the second feature difference adjustment factor, the third feature difference adjustment factor, the feature period adjustment factor and the Spearman rank correlation coefficient, wherein the expression of the vulnerability detection algorithm is: ,

[0058] in, Indicates feature differences, Represents the key features, represents the first characteristic difference adjustment factor, represents the characteristic period adjustment factor, express The characteristic size of represents the second characteristic difference adjustment factor, express The characteristic size of represents the third characteristic difference adjustment factor, represents the Spearman rank correlation coefficient.

[0059] It should be noted that the key features for constructing and training vulnerability detection algorithms are the key features extracted from the vulnerability information data of the above-mentioned embodiments, which belong to the key features of different time periods. The vulnerability detection algorithm is constructed using the key features corresponding to historical time. The feature period adjustment factor affects the periodic properties in the feature difference calculation. The cosine and sine functions in the formula, these two trigonometric functions, are very sensitive to changes in the period. By changing the feature period adjustment factor, the difference between the key features and the fusion layer features can be "magnified" or "reduced" at different frequencies.

[0060] The vulnerability detection algorithm in this embodiment can automatically detect vulnerabilities in existing smart contracts, identify potential security vulnerabilities and risks, effectively improve the accuracy of vulnerability detection, reduce missed detections and false detections, and thus enhance the security judgment of smart contracts. It also combines the periodic function cosine and sine and correlation metrics to evaluate the difference, performs vulnerability detection based on the difference between the fusion feature and the key feature, determines the smart contract vulnerability, and can monitor the running status of the contract in real time, discover and report potential security issues in a timely manner, reduce the need for manual intervention, and improve development efficiency.

[0061] S150. Determine the smart contract vulnerability based on the feature difference.

[0062] Based on the above embodiments, the difference between the key features and the fusion layer features, i.e., the feature difference, can be determined through the vulnerability detection algorithm, and then the feature differences of different features can be aggregated to determine the feature differences with significant differences, and further analyze their specific role and potential security impact in the smart contract to determine whether there are vulnerabilities. For example: when the feature difference exceeds the set threshold, it is determined to be a significant difference and there is a vulnerability in the smart contract.

[0063] The smart contract vulnerability detection method based on multi-source data provided in this embodiment, by fusing source code layer features, construction layer features and bytecode layer features from different sources, is conducive to more accurate identification of vulnerabilities and security risks in contracts, and by enhancing the security of smart contracts, and then using the smart contract vulnerability detection algorithm to determine the difference between key features and fusion layer features, to obtain smart contract vulnerabilities. The vulnerability detection algorithm can monitor the running status of the contract in real time, promptly discover and report potential security issues, reduce the need for manual intervention, further improve the accuracy of vulnerability detection, reduce missed detections and false detections, and thus enhance the security judgment of smart contracts.

[0064] Figure 2 FIG. 1 is a schematic diagram of the structure of a smart contract vulnerability detection device based on multi-source data in an embodiment of the present disclosure. Figure 2As shown: the device includes: a first acquisition module 210, a first determination module 220, a second determination module 230, a third determination module 240 and a fourth determination module 250.

[0065] A first acquisition module 210 is used to extract and determine key features based on the vulnerability information data, wherein the key features include source code layer features, construction layer features, and bytecode layer features;

[0066] A first determination module 220 is used to extract and determine key features based on the vulnerability information data, wherein the key features include source code layer features, construction layer features, and bytecode layer features;

[0067] A second determination module 230 determines a fusion layer feature based on the source code layer feature, the construction layer feature and the bytecode layer feature;

[0068] A third determination module 240, configured to determine feature differences based on the key features, the fusion layer features, and the vulnerability detection algorithm;

[0069] The fourth determination module 250 is used to determine the smart contract vulnerability based on the feature difference.

[0070] The expression of the source code layer feature is: ,

[0071] in, Represents source code layer features, Represents a text sequence of the source code of the vulnerability, The encoding features representing the vulnerable source code text sequence, The offset term representing the text sequence of the vulnerable source code, express The length of the sequence.

[0072] The construction layer features include abstract syntax tree features and code semantic features, wherein the expression of the abstract syntax tree features is: ,

[0073] The expression of the code semantic feature is: ,

[0074] in, Represents source code layer features, Represents a text sequence of the source code of the vulnerability, express Midpoint Type , Represents control flow structure , Indicates the expression type , Represents the semantic features of the code, express Medium parameter variables , express Medium Function , express Medium data type .

[0075] The expression of the bytecode layer feature is: ,

[0076] in, Represents bytecode-level features, express Medium opcode , express Control flow structure , express Access modifiers .

[0077] Optionally, the second determination module is further used to determine the fusion layer features based on the source code layer features, the abstract syntax tree features, the code semantic features and the bytecode layer features and their corresponding weight factors.

[0078] Among them, the expression of the fusion layer feature is: ,

[0079] in, represents the fusion layer features, express The corresponding weight factor is express The corresponding weight factor is express The corresponding weight factor is express The corresponding weight factor is express The corresponding weight factor is represents the first fusion factor, represents the second fusion factor, Indicates feature point addition operation, Represents the feature point multiplication operation.

[0080] The device also includes a fifth determination module, which is used to determine a vulnerability detection algorithm based on the key feature, the fusion layer feature, the feature size of the key feature, the feature size of the fusion layer feature, the first feature difference adjustment factor, the second feature difference adjustment factor and the third feature difference adjustment factor.

[0081] Among them, the expression of the vulnerability detection algorithm is: ,

[0082] in, Indicates feature differences, Represents the key features, represents the first characteristic difference adjustment factor, represents the characteristic period adjustment factor, express The characteristic size of represents the second characteristic difference adjustment factor, express The characteristic size of represents the third characteristic difference adjustment factor, represents the Spearman rank correlation coefficient.

[0083] The smart contract vulnerability detection device based on multi-source data provided in the embodiment of the present disclosure can execute the steps of the smart contract vulnerability detection method based on multi-source data provided in the embodiment of the method of the present disclosure, and the execution steps and beneficial effects are no longer repeated here.

[0084] Figure 3 Schematic diagram of the structure of an electronic device in the embodiment of the present disclosure. Figure 3 , which shows a structural schematic diagram of an electronic device 500 suitable for implementing the embodiments of the present disclosure. Figure 3 The electronic device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present disclosure.

[0085] like Figure 3As shown, the electronic device 500 may include a processing device 501, a ROM 502, a RAM 503, a bus 504, an input / output (I / O) interface 505, an input device 506, an output device 507, a storage device 508, and a communication device 509. The processing device (e.g., a central processing unit, a graphics processor, etc.) 501 can perform various appropriate actions and processes according to the program stored in the read-only memory (ROM) 502 or the program loaded from the storage device 508 to the random access memory (RAM) 503 to implement the smart contract vulnerability detection method based on multi-source data of the embodiment described in the present disclosure. In the RAM 503, various programs and data required for the operation of the electronic device 500 are also stored. The processing device 501, the ROM 502, and the RAM 503 are connected to each other through the bus 504. The input / output (I / O) interface 505 is also connected to the bus 504.

[0086] In particular, according to an embodiment of the present disclosure, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present disclosure includes a computer program product, which includes a computer program carried on a non-transitory computer-readable medium, and the computer program contains a program code for executing the method shown in the flowchart, thereby implementing the smart contract vulnerability detection method based on multi-source data as described above. In such an embodiment, the computer program can be downloaded and installed from the network through the communication device 509, or installed from the storage device 508, or installed from the ROM 502. When the computer program is executed by the processing device 501, the above-mentioned functions defined in the method of the embodiment of the present disclosure are executed.

[0087] It should be noted that the computer-readable medium mentioned above in the present disclosure may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present disclosure, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, device or device. In the present disclosure, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, which carries a computer-readable program code. This propagated data signal may take a variety of forms, including but not limited to an electromagnetic signal, an optical signal, or any suitable combination of the above. Computer readable signal media may also be any computer readable medium other than computer readable storage media, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer readable medium may be transmitted using any appropriate medium, including but not limited to: wires, optical cables, RF (radio frequency), etc., or any suitable combination of the above.

[0088] The computer-readable medium may be included in the electronic device; or it may exist independently without being installed in the electronic device. The computer-readable medium carries one or more programs. When the one or more programs are executed by the electronic device, the electronic device: obtains vulnerability information data, including vulnerability source code and vulnerability bytecode; extracts based on the vulnerability information data to determine key features, including source code layer features, construction layer features, and bytecode layer features; determines fusion layer features based on source code layer features, construction layer features, and bytecode layer features; determines feature differences based on key features, fusion layer features, and vulnerability detection algorithms; and determines smart contract vulnerabilities based on feature differences.

[0089] Optionally, when the above one or more programs are executed by the electronic device, the electronic device may also execute other steps described in the above embodiments.

[0090] In the context of the present disclosure, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or device, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.

[0091] The above description is only a preferred embodiment of the present disclosure and an explanation of the technical principles used. Those skilled in the art should understand that the scope of disclosure involved in the present disclosure is not limited to the technical solutions formed by a specific combination of the above technical features, but should also cover other technical solutions formed by any combination of the above technical features or their equivalent features without departing from the above disclosed concept. For example, the above features are replaced with the technical features with similar functions disclosed in the present disclosure (but not limited to) by each other to form a technical solution.

Claims

1. A smart contract vulnerability detection method based on multi-source data, characterized in that: The method comprises: Acquire vulnerability information data, wherein the vulnerability information data includes vulnerability source code and vulnerability bytecode; Extracting based on the vulnerability information data, determining key features, the key features including source code layer features, build layer features, and bytecode layer features; Determining fusion layer features based on the source code layer features, the construction layer features, and the bytecode layer features; Determining feature differences based on the key features, the fusion layer features, and the vulnerability detection algorithm; Based on the feature differences, the smart contract vulnerability is determined.

2. The method according to claim 1, characterized in that The expression of the source code layer feature is: , in, Represents source code layer features, Represents a text sequence of the source code of the vulnerability, The encoding features representing the vulnerable source code text sequence, The offset term representing the text sequence of the vulnerable source code, express The length of the sequence.

3. The method according to claim 2, characterized in that The construction layer features include abstract syntax tree features and code semantic features, wherein the expression of the abstract syntax tree features is: , The expression of the code semantic feature is: , in, Represents source code layer features, express Midpoint Type , Represents control flow structure , Indicates the expression type , Represents the semantic features of the code, express Medium parameter variables , express Medium Function , express Medium data type .

4. The method according to claim 3, characterized in that The expression of the bytecode layer feature is: , in, Represents bytecode-level features, express Medium opcode , express Control flow structure , express Access modifiers .

5. The method according to claim 4, characterized in that Determining fusion layer features based on the source code layer features, the construction layer features, and the bytecode layer features includes: Based on the source code layer features, the abstract syntax tree features, the code semantic features, the bytecode layer features and corresponding weight factors, a fusion layer feature is determined.

6. The method according to claim 5, characterized in that The expression of the fusion layer feature is: , in, represents the fusion layer features, express The corresponding weight factor is, express The corresponding weight factor is, express The corresponding weight factor is, express The corresponding weight factor is, express The corresponding weight factor is, represents the first fusion factor, represents the second fusion factor, Indicates feature point addition operation, Represents the feature point multiplication operation.

7. The method according to claim 6, characterized in that Before determining the feature difference based on the key feature, the fusion layer feature and the vulnerability detection algorithm, the method includes: A vulnerability detection algorithm is determined based on the key feature, the fusion layer feature, the feature size of the key feature, the feature size of the fusion layer feature, a first feature difference adjustment factor, a second feature difference adjustment factor, and a third feature difference adjustment factor.

8. The method according to claim 7, characterized in that The expression of the vulnerability detection algorithm is: , in, Indicates feature differences, Represents the key features, represents the first characteristic difference adjustment factor, represents the characteristic period adjustment factor, express The characteristic size of represents the second characteristic difference adjustment factor, express The characteristic size of represents the third characteristic difference adjustment factor, represents the Spearman rank correlation coefficient.

9. A smart contract vulnerability detection device based on multi-source data, characterized in that: The device comprises: A first acquisition module, used to acquire vulnerability information data, wherein the vulnerability information data includes vulnerability source code and vulnerability bytecode; A first determination module is used to extract and determine key features based on the vulnerability information data, wherein the key features include source code layer features, construction layer features, and bytecode layer features; A second determination module determines a fusion layer feature based on the source code layer feature, the construction layer feature and the bytecode layer feature; A third determination module, configured to determine feature differences based on the key features, the fusion layer features, and the vulnerability detection algorithm; The fourth determination module is used to determine the smart contract vulnerability based on the feature difference.

10. An electronic device, characterized in that The electronic device comprises: one or more processors; A storage device for storing one or more programs. When the one or more programs are executed by the one or more processors, the one or more processors implement the smart contract vulnerability detection method based on multi-source data as described in any one of claims 1-8.

Citation Information

Patent Citations

  • Ethereum smart contract security vulnerability detection method and system based on deep learning

    CN114048464A

  • Intelligent contract vulnerability detection system and method based on static feature full-stack hierarchical fusion

    CN115270130A

  • Multi-feature fusion block chain intelligent contract vulnerability detection method and device based on graph neural network, computer and storage medium

    CN115499164A

  • Intelligent contract vulnerability detection method and device based on syntax and semantic feature fusion

    CN116089957A

  • Block chain intelligent contract vulnerability feature extraction method and system based on deep learning

    CN117763558A