Digital currency transfer malicious behavior detection method and system based on intelligent contract analysis

Through symbolic execution and path exploration technology, combined with static and dynamic detection, the token transfer operation in the smart contract is analyzed, which solves the problem of false positives and false negatives in abnormal behavior detection of token transfer operations in the existing technology, and achieves efficient and accurate Multi-language and multi-standard support to adapt to malicious behavior detection in complex scenarios.

CN118735685APending Publication Date: 2024-10-01UNIV OF ELECTRONICS SCI & TECH OF CHINA
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202410922234.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-07-10
Publication Date
2024-10-01

AI Technical Summary

Technical Problem

Existing technology has high false positive and false negative rates when identifying and detecting abnormal behavior of token transfer operations in smart contracts, cannot adapt to complex and changeable attack methods, and lacks support for multi-language and multi-standards, making it impossible to identify Complex data structures, lack of automation and scalability.

Method used

Through symbolic execution and path exploration technology, it automatically extracts the access patterns of basic containers in smart contracts, analyzes the core data structure, builds interactive control flow graphs, and combines static and dynamic detection plug-ins to identify and monitor token transfer operations to achieve malicious behavior detection.

Benefits of technology

It significantly reduces the rate of false positives and false negatives, improves detection accuracy and efficiency, supports multi-language and multi-standards, can identify complex container type variables, provides flexibility and scalability, and adapts to different application scenarios.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118735685A_ABST
    Figure CN118735685A_ABST
Patent Text Reader

Abstract

The invention discloses a digital currency transfer malicious behavior detection method and system based on intelligent contract analysis, and the method comprises the steps: collecting byte codes and transaction records of an intelligent contract as the input of the system; the access mode of the basic container in the smart contract is automatically extracted through symbolic execution and path exploration technologies, and a basis is provided for subsequent token transfer operation identification and improper behavior detection; by analyzing the core data structure of the smart contract and capturing the token transfer operation, it is ensured that improper behaviors in the token transfer process can be accurately recognized and monitored; detecting an improper token behavior in the smart contract; by automatically learning an access mode of a basic container type and designing a cross-contract symbolic analysis method, a core data structure in a token contract is identified and monitored, so that token transfer operation is identified and abnormal behaviors are detected, the accuracy and efficiency of detection are improved, and the high false alarm rate and the missing report rate can be effectively reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of cloud computing technology, and in particular to a method and system for detecting malicious behavior of digital currency transfer based on smart contract analysis. Background Art

[0002] Blockchain technology has become an important part of modern finance and technology. Blockchain is a distributed ledger technology that records transactions in a decentralized manner to ensure the immutability and transparency of data. Cryptocurrency is one of the main applications of blockchain technology, which uses cryptography to ensure the security and privacy of transactions. Cryptocurrencies represented by Bitcoin and Ethereum have attracted widespread attention and become a new asset class. Bitcoin is the first decentralized cryptocurrency that uses the Proof of Work (PoW) mechanism to ensure the security and consensus of transactions. The Bitcoin network uses miners to verify transactions and generate blocks, ensuring the security and decentralization of the network.

[0003] Ethereum is an open-source blockchain platform that supports the development and execution of smart contracts. Smart contracts are self-executing programs on the Ethereum network that can automatically and securely manage contract terms. Ethereum is unique in that it not only supports cryptocurrency transactions, but also allows developers to build and deploy distributed applications (dApps). These applications are widely used in finance, supply chain management, games and other fields, greatly expanding the application scenarios of blockchain technology.

[0004] Smart contracts are automated protocols running on the blockchain that verify, execute, and record contract terms. Smart contracts automatically execute transactions through code without the intervention of intermediaries. Smart contracts are widely used on the Ethereum platform to create and manage tokens, which follow specific standards (such as ERC20, ERC721, and ERC1155) to ensure the interoperability and compatibility of tokens. Smart contracts are widely used on the Ethereum platform to create and manage various complex blockchain applications, greatly improving the level of automation of transactions and processes. However, the complexity of smart contracts also brings security challenges, especially in identifying and preventing malicious behavior. The security of smart contracts is an important issue, and common security issues include reentrancy attacks, integer overflows, and improper permission control. Solutions to these problems include using secure development frameworks and tools, code auditing, and testing. These measures help improve the security and reliability of smart contracts and prevent potential security vulnerabilities from being maliciously exploited.

[0005] Symbolic execution is a program analysis technique used to explore all possible execution paths of a program. It simulates the execution of a program by representing the program input as symbolic variables and collecting constraints on each path. Symbolic execution can discover potential execution paths and implicit errors, which is very important for the security analysis of smart contracts. Using symbolic execution, the behavior of a program can be checked without running the program, thereby effectively detecting vulnerabilities and abnormal operations in smart contracts.

[0006] One of the major challenges of symbolic execution is the path explosion problem, which means that the number of execution paths of a program grows exponentially as the complexity of the program increases. Each conditional branch generates a new path, and when the program contains a large number of branches and loops, the number of paths may increase dramatically, making symbolic execution very time-consuming and resource-intensive. This problem is particularly prominent in smart contract analysis, because smart contracts usually have complex logic and diverse interaction modes. Solving the path explosion problem is the key to improving the efficiency and accuracy of symbolic execution.

[0007] Token transfer is one of the core functions in smart contracts, which involves the process of transferring tokens from one address to another. Usually, token transfer operations need to follow specific standard interfaces and events. However, some token contracts may exhibit abnormal behaviors, which refer to operational behaviors that deviate from standard specifications and expectations, such as unauthorized token transfers, incorrect transfers of token quantities, false notifications, etc. These behaviors may lead to unexpected transfers of tokens or other problems, which may lead to financial losses and reduced user trust. Identifying the accuracy of token transfer operations is crucial to detecting and preventing these improper behaviors.

[0008] With the rapid development of blockchain technology, cryptocurrency has become an important part of the financial market. However, due to its significant economic value, cryptocurrency has become an important target for attackers. Attackers often take advantage of abnormal behaviors of token transfer operations that deviate from standard specifications and holders' expectations to make profits. Existing methods have high false positives or false negatives when identifying token transfer operations. Existing methods use specific rule sets and pattern matching techniques to detect abnormal behaviors of token transfer operations, but because these methods are often based on static and simplified assumptions and predefined rules and patterns, they fail to cover all possible abnormal behavior patterns and cannot adapt to complex and changing attack methods.

[0009] Among the existing methods for detecting malicious behavior of digital currencies, the technical means for detecting improper behavior of cryptocurrency tokens still have some significant limitations. These limitations not only affect the accuracy and efficiency of the detection system, but also limit its applicability in different environments and conditions. Specifically, the existing technologies show obvious deficiencies in the following aspects: 1) High false positive and false negative rates. The existing methods rely on invalid assumptions or simple, limited manually defined patterns, resulting in high false positive and false negative rates, thereby reducing the reliability of the detection system. 2) Lack of support for multiple languages ​​and multiple standards. The existing technologies usually only support specific programming languages ​​(such as Solidity) or token standards (such as ERC20), which limits the applicability of the detection system in different smart contracts and token ecosystems. 3) Inability to identify complex data structures. The existing technologies cannot effectively identify complex container type variables used to store token holder information in smart contracts, resulting in the inability to accurately identify and process complex token transfer operations, affecting the accuracy of detection. 4) Lack of automation and scalability. When identifying and processing token transfer operations, the existing technologies usually rely on manually defined patterns and rules, lack automation and scalability, and are difficult to adapt to the ever-changing attack methods and smart contract complexity.

[0010] The Chinese patent with publication number CN114491508A provides a digital legal currency processing method based on blockchain tokens and ledger dual authentication. Through user identity authentication, ledger account and token account mapping, transaction initiator identity authentication and other steps, it ensures the security and supervision of digital legal currency transactions, including system construction: building a digital legal currency processing system based on blockchain technology to ensure the distributed and decentralized characteristics of the system; account creation: when a user creates a digital legal currency account, it is necessary to confirm the identity and record it on the chain to generate the corresponding on-chain ledger account; account mapping: the user's account information is recorded in the token smart contract and mapped one-to-one with the ledger account; account storage: the user's ledger account and token account are mapped one-to-one; The currency account is stored on the chain; identity verification: when a transaction is initiated, the identity of the transaction initiator is first verified, and the identity of the transaction initiator is authenticated through secret keys or public-private key cryptography; balance verification: the balance of the ledger account and the token account are checked through user information to see if they are consistent. If not, the transaction is terminated; transaction processing: after confirming that the balances are consistent, the transaction will enter the token smart contract processing link, and the balances of the token account and the ledger account will be updated synchronously to complete the transaction; supervision mechanism: the system designer or regulatory unit can add a supervision mechanism to the ledger system to conduct transaction supervision, and ensure transaction security through dual authentication of ledgers and tokens. Through dual authentication of ledgers and tokens, the security and supervision capabilities of digital legal currency transactions are improved.

[0011] The Chinese patent with publication number CN113034148A provides a system and method for detecting and analyzing malicious transactions in smart contracts based on dynamic data storage, including a transaction data acquisition module: used to obtain detailed information of transactions, including transaction hashes and execution bytecodes; a simulation execution module: based on the acquired transaction details, simulate and replay the bytecode-level execution process of historical transactions, build a stack, generate intermediate data and logic, dynamically store the generated intermediate data, and map the generated logic setting data index; an attack identification module: based on the generated intermediate data and logic, analyze the transaction execution information, identify and report malicious transaction behaviors and smart contract vulnerabilities; by detecting abnormal behavior patterns of transactions, timely discover and prevent potential security threats. This method proposes a detection idea based on data reverse logic, which has good practicality and scalability. By simulating and replaying the execution of transactions at the bytecode level, the contract interaction logic relationship of the transaction is refined, malicious behaviors are detected, and the accuracy and efficiency of detection are improved.

[0012] The above two technical solutions provide effective solutions for digital currency processing and smart contract malicious transaction detection respectively. The first solution ensures transaction security through dual authentication of ledger and token, and the second solution detects malicious transaction behavior and smart contract vulnerabilities through dynamic data storage and logical indexing; however, neither of these two solutions involves the specific method of automatically identifying and monitoring token transfer operations and their improper behavior detection mechanism. Summary of the invention

[0013] The purpose of the present invention is to overcome the deficiencies of the prior art and to provide a method and system for detecting malicious behavior in digital currency transfer based on smart contract analysis.

[0014] The objective of the present invention is achieved through the following technical solutions: In a first aspect, the present invention provides a method for detecting malicious behavior of digital currency transfer based on smart contract analysis, comprising the following steps: Step 1: Data collection: collect the bytecode and transaction records of smart contracts as input to the system; Step 2: Pattern learning: automatically extract the access patterns of basic containers in smart contracts through symbolic execution and path exploration technology; Step 3: Identify token transfer operations. By analyzing the core data structure of smart contracts and capturing token transfer operations, we can ensure that improper behavior in the token transfer process can be accurately identified and monitored. Step 4: Malicious behavior detection: detect improper behavior of tokens in smart contracts.

[0015] Based on the first aspect, the bytecode collection in step one includes inserting the record code into the Ethereum client to extract the bytecode of the target smart contract from the blockchain network; the transaction record collection is to query the public data set to obtain all historical transaction records related to the target smart contract, and the transaction records include transaction hash, initiator address, recipient address, and transferred token quantity information.

[0016] Based on the first aspect, the data collection in step one also includes collecting data through event logs.

[0017] Based on the first aspect, the access mode of the basic container in step 2 includes an access learning mode, a mapping learning mode, an array learning mode and a structure learning mode of the basic container. The access learning mode of the basic container is that the system first collects the basic containers used in the smart contract, and automatically extracts the access modes of these containers through symbolic execution technology. The access mode of the container includes the read and write operations of the container. The basic containers include mappings, arrays and structures; the mapping learning mode uses symbolic execution technology to extract the key-value pair access behavior of the mapping container, analyze the read and write operations of the mapping container in the smart contract, and identify possible token transfer behaviors; the array learning mode uses symbolic execution technology to analyze the index access behavior of the array container; extracts the read and write operations of the array, and captures the changes in the array index during the token transfer process; the structure learning mode uses symbolic execution technology to extract the member variable access behavior of the structure container; analyzes the read and write operations of the structure in the smart contract, and identifies the member variable changes related to token transfer.

[0018] Based on the first aspect, the pattern learning in step two also includes the use of machine learning technology to achieve this by collecting a large amount of known smart contract codes and manually annotating the basic container access patterns therein. The machine learning model is trained using these manually annotated data so that it can automatically identify and extract the basic container access patterns in new smart contracts.

[0019] Based on the first aspect, the core data structure identification in step 3 includes the following sub-steps: Step 11: Analyze the storage write mode. By analyzing the storage write mode of the smart contract, identify the storage operations that may involve token transfers. Step 12: Construct an interactive control flow graph. Based on the storage write mode, construct an interactive control flow graph to describe the interactive relationship between different storage operations in the smart contract. Step 13: Extract core data structures. Extract core data structures and variables related to token transfer operations from the interactive control flow graph, including the balance field in the mapping and the index in the array.

[0020] Based on the first aspect, the capture token transfer operation in step 3 includes the following steps: Step 21: Static analysis: Use static analysis techniques to review the smart contract code and detect potential improper token transfer behavior; Step 22: Dynamic monitoring: By replaying transactions and exploring paths, dynamically monitor token transfer operations that occur during the operation of smart contracts to capture improper behaviors in actual operations.

[0021] Based on the first aspect, step four includes key data, and the key data includes execution traces and token transfer operations. The execution traces include execution traces of smart contracts that the plug-in can request from the system, and the execution traces include executed instructions, called functions, triggered events and function parameters; the data of the token transfer operation is requested by the plug-in, including all operation records involving token transfer in the smart contract.

[0022] Based on the first aspect, step four includes developing plug-ins, and the developed plug-ins include static detection plug-ins and dynamic detection plug-ins. The static detection plug-in is used to detect potential improper behavior by analyzing the smart contract code, and the dynamic detection plug-in is used to capture improper behavior of the smart contract in actual operation by replaying transactions and path exploration.

[0023] In a second aspect, the present invention provides a digital currency transfer malicious behavior detection system based on smart contract analysis, which is used to implement any one of the above-mentioned digital currency transfer malicious behavior detection methods based on smart contract analysis, and is characterized by comprising: Data collection module: responsible for collecting the bytecode and transaction records of smart contracts, which will serve as the basis for subsequent analysis; Pattern learning module: automatically extracts the access patterns of basic containers in smart contracts through symbolic execution technology; ICCG building module: By analyzing the storage write pattern, building an interactive control flow graph, and generating candidate patterns through pattern matching, the system will then filter and delete irrelevant patterns to ensure that only the core data structure storing digital currency information is retained; Plugin detection module: includes static detection plug-ins and dynamic detection plug-ins. Static detection plug-ins detect potential improper behaviors by analyzing smart contract codes, and dynamic detection plug-ins capture improper behaviors of smart contracts in actual operation by replaying transactions and path exploration.

[0024] The beneficial effects of the present invention are: 1) The present invention analyzes the bytecode of smart contracts and combines symbolic execution technology to automatically extract and learn access patterns of basic containers (such as mappings, arrays, and structures), significantly reducing false positive and false negative rates. It can work directly on the bytecode of smart contracts without the need for source code, ensuring the efficiency and accuracy of detection, making the detection system more reliable, and solving the high false positive and false negative problems caused by manually defined patterns in the prior art.

[0025] 2) This invention uses reverse engineering to identify and process the unique impact of different programming languages ​​(Solidity and Vyper) on bytecode, and is compatible with the three major token standards ERC20, ERC721 and ERC1155. This multi-language and multi-standard support can adapt to the evolving token ecosystem, making it highly applicable and compatible in a wide range of blockchain application scenarios, and can meet the needs of different types of smart contracts.

[0026] 3) Through symbolic execution and path exploration technology, the present invention can identify and process complex container type variables used to store token holder information in smart contracts, thereby accurately identifying token transfer operations and detecting related improper behaviors. By monitoring the operations of the core data structure Rs and using replay transactions and path exploration technology, token transfer operations can be captured, thereby detecting various improper behaviors in token contracts. The required information can be directly extracted from the bytecode of the smart contract without relying on the source code, thereby improving the accuracy and efficiency of detection.

[0027] 4) The present invention provides a highly extensible framework and a user interface, allowing users to develop plug-ins to detect more types of improper behaviors. Users can define expected token transfer operations, and the tools of the present invention will identify actual token transfer operations and compare them to detect improper behaviors, ensuring flexibility and scalability, and being able to adapt to different application scenarios and needs.

[0028] 5) This paper adopts the cross-contract symbolic analysis (ICSA) method to construct the cross-contract call graph (ICCG), which can effectively identify and process the complex interactions between multiple contracts and ensure the comprehensive analysis of token transfer operations. BRIEF DESCRIPTION OF THE DRAWINGS

[0029] Figure 1 It is a flow chart of a method for detecting malicious behavior of digital currency transfer based on smart contract analysis according to an embodiment of the present invention; Figure 2 This is a structural diagram of a digital currency transfer malicious behavior detection system based on smart contract analysis in an embodiment of the present invention. DETAILED DESCRIPTION

[0030] The technical solution of the present invention will be clearly and completely described below in conjunction with the embodiments. Obviously, the described embodiments are only part of the embodiments of the present invention, rather than all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present invention.

[0031] Exemplarily, the present invention provides a method for detecting malicious behavior of digital currency transfer based on smart contract analysis. By analyzing the bytecode and transaction records of smart contracts, symbolic execution and path exploration technology are used to automatically identify token transfer operations and detect improper behavior. The tool supports two programming languages, Solidity and Vyper, and is compatible with three major token standards, ERC20, ERC721 and ERC1155, wherein Solidity is a programming language for writing smart contracts, which is mainly used on the Ethereum platform, and Vyper is also a programming language for writing smart contracts, which is similar to Solidity, but is more concise and secure in design. ERC20, ERC721 and ERC1155 are Ethereum token standards, which are used to define a set of specifications for the interface of tokens issued on the Ethereum blockchain. ERC20 is used to implement interchangeable tokens, ERC721 is used to implement non-interchangeable unique tokens, and ERC1155 allows interchangeable and non-interchangeable tokens to exist in the same contract at the same time. The present invention accurately identifies token transfer operations through an automated method to solve the problems of high false positives and false negatives in the prior art. By innovatively and automatically identifying complex container type variables used to store token holder information in smart contracts and supporting multiple programming languages ​​and token standards, the present invention can not only effectively detect various improper behaviors involving token transfers, but also directly extract the required information from the bytecode of the smart contract without relying on the source code, thereby improving the accuracy and efficiency of detection.

[0032] For example, a flowchart of a method for detecting malicious behavior of digital currency transfer based on smart contract analysis is as follows: Figure 1 As shown, data collection collects the bytecode and transaction records of smart contracts as the input of the system; pattern learning automatically extracts the access patterns of basic containers in smart contracts through symbolic execution and path exploration technology, providing a basis for subsequent token transfer operation identification and improper behavior detection; token transfer operation identification ensures accurate identification and monitoring of improper behavior in the token transfer process by analyzing the core data structure of the smart contract and capturing token transfer operations; malicious behavior detection detects improper behavior of tokens in smart contracts.

[0033] Specifically, bytecode collection includes inserting the recording code into the Ethereum client to extract the bytecode of the target smart contract from the blockchain network; the transaction record collection is to query the public data set to obtain all historical transaction records related to the target smart contract, and the transaction record includes transaction hash, initiator address, recipient address, and the number of tokens transferred. Data collection can also be carried out in the form of event logs.

[0034] Specifically, the access mode of the basic container includes the access learning mode of the basic container, the mapping learning mode, the array learning mode and the structure learning mode. The access learning mode of the basic container is that the system first collects the basic containers used in the smart contract, and automatically extracts the access modes of these containers through symbolic execution technology, including the read and write operations of the containers. The basic containers include mapping, array and structure; the mapping learning mode uses symbolic execution technology to extract the key-value pair access behavior of the mapping container, analyze the read and write operations of the mapping container in the smart contract, and identify possible token transfer behaviors; the array learning mode uses symbolic execution technology to analyze the index access behavior of the array container; extract the read and write operations of the array, and capture the changes in the array index during the token transfer process; the structure learning mode uses symbolic execution technology to extract the member variable access behavior of the structure container; analyze the read and write operations of the structure in the smart contract, and identify the member variable changes related to the token transfer. Pattern learning can also be achieved using machine learning technology, by collecting a large amount of known smart contract codes, and manually annotating the basic container access modes therein, and using these manually annotated data to train the machine learning model so that it can automatically identify and extract the basic container access modes in new smart contracts.

[0035] Specifically, the core data structure identification includes the following steps: analyzing the storage write mode, identifying the storage operations that may involve token transfer by analyzing the storage write mode of the smart contract; constructing an interactive control flow graph, based on the storage write mode, constructing an interactive control flow graph to describe the interactive relationship between different storage operations in the smart contract; extracting the core data structure and variables related to the token transfer operation from the interactive control flow graph, including the balance field in the mapping, the index in the array, etc. The core data structure (Rs) refers to the complex container type variables used to store token holder information in the token contract, such as mapping, array, and structure, which are identified by automatically learning their access patterns.

[0036] Specifically, capturing token transfer operations includes the following steps: static analysis, through static analysis technology, reviewing the smart contract code to detect potential token transfer misconduct, for example, by analyzing whether there are unauthorized token transfer operations in the smart contract; dynamic monitoring, through replaying transactions and path exploration, dynamically monitoring token transfer operations that occur during the operation of the smart contract, and capturing improper behaviors of the smart contract in actual operation. The token transfer operation refers to the process of transferring tokens from one holder to another.

[0037] Specifically, malicious behavior detection includes two key data, including execution traces and token transfer operations. The execution traces are the execution traces (execution traces) that the plug-in can request from the system for the smart contract. The execution traces include information such as executed instructions, called functions, triggered events and function parameters; the token transfer operation is the data that the plug-in can request for the token transfer operation. The token transfer operation data includes all operation records involving token transfer in the smart contract.

[0038] Specifically, malicious behavior detection includes two developed plug-ins, including a static detection plug-in and a dynamic detection plug-in. The static detection plug-in is used to detect potential improper behavior by analyzing the smart contract code. The static plug-in uses symbolic execution and code auditing techniques to analyze the security of the code without executing the contract. The dynamic detection plug-in is used to capture improper behavior of smart contracts in actual operation by replaying transactions and path exploration. The dynamic plug-in monitors its behavior and identifies improper operations when the contract is actually executed. Static plug-ins are mainly used for pre-emptive prevention, and dynamic plug-ins are mainly used for in-process and post-event detection.

[0039] For example, a structure diagram of a digital currency transfer malicious behavior detection system based on smart contract analysis is as follows: Figure 2As shown in the figure, it includes: data collection module, which is responsible for collecting the bytecode and transaction records (trace) of smart contracts, which will serve as the basis for subsequent analysis; pattern learning module, which automatically extracts the access mode of basic containers in smart contracts through symbolic execution technology; ICCG construction module, which uses cross-contract symbolic analysis (ICSA) to build cross-contract call graph (ICCG), and generates candidate patterns through pattern matching. Subsequently, the system will filter and delete irrelevant patterns to ensure that only the core data structure storing digital currency information is retained; cross-contract symbolic analysis is an analysis method that identifies token transfer operations involving multiple contracts by tracing and analyzing the interactions between multiple smart contracts; plug-in detection module, which can be divided into static detection plug-ins and dynamic detection plug-ins according to functionality. Static detection plug-ins detect potential improper behaviors by analyzing smart contract codes, and dynamic detection plug-ins capture improper behaviors of smart contracts in actual operation by replaying transactions and path exploration. Static plug-ins use symbolic execution and code auditing and other technologies to analyze the security of codes without executing contracts. Dynamic plug-ins monitor their behaviors and identify improper operations when actually executing contracts. Static plug-ins are mainly used for pre-emptive prevention, and dynamic plug-ins are mainly used for in-process and post-event detection.

[0040] The above is only a preferred embodiment of the present invention. It should be understood that the present invention is not limited to the form disclosed herein, and should not be regarded as excluding other embodiments, but can be used in various other combinations, modifications and environments, and can be modified within the scope of the concept described herein through the above teachings or the technology or knowledge of the relevant field. The changes and modifications made by those skilled in the art shall not deviate from the spirit and scope of the present invention, and shall be within the scope of protection of the claims attached to the present invention.

Claims

1. A method for detecting malicious behavior of digital currency transfer based on smart contract analysis, characterized in that: The following steps are involved: Step 1: Data collection: collect the bytecode and transaction records of smart contracts as input to the system; Step 2: Pattern learning: automatically extract the access patterns of basic containers in smart contracts through symbolic execution and path exploration technology; Step 3: Identify token transfer operations. By analyzing the core data structure of smart contracts and capturing token transfer operations, we can ensure that improper behavior in the token transfer process can be accurately identified and monitored. Step 4: Malicious behavior detection: detect improper behavior of tokens in smart contracts.

2. According to claim 1, a method for detecting malicious behavior of digital currency transfer based on smart contract analysis is characterized by: The bytecode collection in step one includes inserting the record code into the Ethereum client to extract the bytecode of the target smart contract from the blockchain network; the transaction record collection is to query the public data set to obtain all historical transaction records related to the target smart contract, and the transaction record includes transaction hash, initiator address, recipient address, and the number of tokens transferred.

3. According to claim 1, a method for detecting malicious behavior of digital currency transfer based on smart contract analysis is characterized in that: Data collection in step one also includes event logging.

4. According to claim 1, a method for detecting malicious behavior of digital currency transfer based on smart contract analysis is characterized in that: The access mode of the basic container in step 2 includes the access learning mode, mapping learning mode, array learning mode and structure learning mode of the basic container. The access learning mode of the basic container is that the system first collects the basic containers used in the smart contract, and automatically extracts the access modes of these containers through symbolic execution technology. The access mode of the container includes the read and write operations of the container. The basic containers include mapping, array and structure; the mapping learning mode uses symbolic execution technology to extract the key-value pair access behavior of the mapping container, analyze the read and write operations of the mapping container in the smart contract, and identify possible token transfer behaviors; the array learning mode uses symbolic execution technology to analyze the index access behavior of the array container; extract the read and write operations of the array, and capture the changes in the array index during the token transfer process; the structure learning mode uses symbolic execution technology to extract the member variable access behavior of the structure container; analyze the read and write operations of the structure in the smart contract, and identify the member variable changes related to the token transfer.

5. According to claim 1, a method for detecting malicious behavior of digital currency transfer based on smart contract analysis is characterized in that: The pattern learning in step two also includes the use of machine learning technology to achieve this by collecting a large amount of known smart contract codes and manually annotating the basic container access patterns therein. The machine learning model is trained using these manually annotated data so that it can automatically identify and extract the basic container access patterns in new smart contracts.

6. According to claim 1, a method for detecting malicious behavior of digital currency transfer based on smart contract analysis is characterized in that: The identification of the core data structure in step 3 includes the following sub-steps: Step 11: Analyze the storage write mode. By analyzing the storage write mode of the smart contract, identify the storage operations that may involve token transfers. Step 12: Construct an interactive control flow graph. Based on the storage write mode, construct an interactive control flow graph to describe the interactive relationship between different storage operations in the smart contract. Step 13: Extract core data structures. Extract core data structures and variables related to token transfer operations from the interactive control flow graph, including the balance field in the mapping and the index in the array.

7. According to claim 1, a method for detecting malicious behavior of digital currency transfer based on smart contract analysis is characterized in that: The capture token transfer operation in step 3 includes the following steps: Step 21: Static analysis: Use static analysis techniques to review the smart contract code and detect potential improper token transfer behavior; Step 22: Dynamic monitoring: By replaying transactions and exploring paths, dynamically monitor token transfer operations that occur during the operation of smart contracts to capture improper behaviors in actual operations.

8. The method for detecting malicious behavior of digital currency transfer based on smart contract analysis according to claim 1 is characterized by: Step 4 includes key data, which includes execution traces and token transfer operations. The execution traces include the execution traces of the smart contract that the plug-in can request from the system. The execution traces include executed instructions, called functions, triggered events and function parameters; the data of the token transfer operation is requested by the plug-in, including all operation records involving token transfer in the smart contract.

9. The method for detecting malicious behavior of digital currency transfer based on smart contract analysis according to claim 1, characterized in that: Step 4 includes developing plug-ins, which include static detection plug-ins and dynamic detection plug-ins. The static detection plug-in is used to detect potential improper behavior by analyzing the smart contract code, and the dynamic detection plug-in is used to capture improper behavior of the smart contract in actual operation by replaying transactions and path exploration.

10. A digital currency transfer malicious behavior detection system based on smart contract analysis, used to implement a digital currency transfer malicious behavior detection method based on smart contract analysis as described in any one of claims 1-9, characterized in that: include: Data collection module: responsible for collecting the bytecode and transaction records of smart contracts, which will serve as the basis for subsequent analysis; Pattern learning module: automatically extracts the access patterns of basic containers in smart contracts through symbolic execution technology; ICCG building module: By analyzing the storage write pattern, building an interactive control flow graph, and generating candidate patterns through pattern matching, the system will then filter and delete irrelevant patterns to ensure that only the core data structure storing digital currency information is retained; Plugin detection module: includes static detection plug-ins and dynamic detection plug-ins. Static detection plug-ins detect potential improper behaviors by analyzing smart contract codes, and dynamic detection plug-ins capture improper behaviors of smart contracts in actual operation by replaying transactions and path exploration.

Citation Information

Patent Citations

  • Digital legal currency processing method based on block chain token and account book double authentication

    CN113034148A

  • Intelligent contract malicious transaction detection and analysis system and method based on data dynamic storage

    CN114491508A