Cross-contract address verification method and system based on intelligent contract simulation execution

By combining static analysis and dynamic simulation execution technology, a security analysis method for cross-chain smart contract code is proposed, which solves the problem that the existing technology is difficult to discover cross-chain security vulnerabilities, and improves the security and reliability of cross-chain contract code.

CN119691748APending Publication Date: 2025-03-25NANJING ZHANGYU INFORMATION TECH CO LTD +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411750712.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-02
Publication Date
2025-03-25

AI Technical Summary

Technical Problem

The existing smart contract code security analysis technology is difficult to discover security vulnerabilities unique to cross-chain smart contracts, making it difficult to guarantee the security and reliability of cross-chain contract codes.

Method used

By combining static analysis and dynamic simulation execution technology, a cross-contract address verification method based on smart contract simulation execution is proposed, including cross-chain contract code preprocessing, access control constraint node identification, cross-chain control flow and data flow graph alignment, cross-chain stain tracking and vulnerability confirmation based on simulation execution.

Benefits of technology

It realizes enhanced security analysis capabilities for cross-chain smart contract code, can identify security vulnerabilities unique to cross-chain smart contracts, and expands the scope and accuracy of smart contract security vulnerabilities detection.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure HDA0005164926090000011
    Figure HDA0005164926090000011
  • Figure HDA0005164926090000012
    Figure HDA0005164926090000012
  • Figure HDA0005164926090000013
    Figure HDA0005164926090000013
Patent Text Reader

Abstract

The invention provides a cross-contract address verification method and system based on intelligent contract simulation execution, and aims to solve the problem of specific security vulnerability detection in a cross-chain intelligent contract. According to the method provided by the invention, through code preprocessing, access control constraint identification, cross-chain control flow and data flow diagram alignment analysis, in combination with dynamic taint tracking and simulation execution, potential security vulnerabilities in the cross-chain smart contract are detected, and the security of the contract is ensured. Based on the provided method, a system composed of a cross-chain contract code preprocessing unit, an access control constraint class node identification unit, a cross-chain control flow and data flow diagram analysis unit, a cross-chain taint tracking unit and a simulation execution vulnerability verification unit is realized. According to the method, the vulnerability detection range and accuracy of the cross-chain smart contract are improved, and the method is suitable for security audit of the smart contract in a multi-block-chain environment.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the fields of computer program analysis, artificial intelligence and blockchain, and in particular to security analysis technology for smart contract codes, focusing on the security issues of cross-chain smart contracts involving multiple different blockchains. By combining artificial intelligence with traditional program analysis technology, special security vulnerabilities in cross-chain smart contract codes are discovered. The method and system are widely used in joint application scenarios involving multiple blockchains. Background Art

[0002] With the rapid development of blockchain technology, smart contracts, as the core components of blockchain applications, are widely used in finance, the Internet of Things, supply chain and other fields. However, the security issues of smart contract codes are becoming increasingly prominent. Once deployed on the blockchain, smart contracts cannot be tampered with, so it is crucial to discover and fix potential vulnerabilities before deployment. Since smart contracts usually directly control blockchain assets, potential security vulnerabilities in the code (such as reentrancy attacks, integer overflows, etc.) may cause significant economic losses.

[0003] Cross-chain smart contracts refer to smart contracts that run collaboratively between multiple blockchain platforms, and realize data exchange, state synchronization, and asset transfer between contracts on different chains through cross-chain protocols. With the ecological development of blockchain applications, cross-chain smart contracts are widely used in scenarios such as cross-border payments and asset swaps to achieve interoperability of assets and information between chains. However, the complexity of cross-chain smart contracts also brings a series of security issues, such as cross-chain data consistency, double spending risks, and cross-chain communication trust. In addition, the access control mechanisms of different blockchains vary greatly, and there may be problems with lax authority management, which increases security risks.

[0004] Existing smart contract code security analysis technologies mainly target single-chain contracts and are difficult to discover specific cross-chain security vulnerabilities. Therefore, there is an urgent need to develop new analysis technologies to support the security audit of cross-chain smart contracts in order to enhance the security and reliability of cross-chain contract codes. Summary of the invention

[0005] The present invention proposes a cross-contract address verification method and system based on smart contract simulation execution, aiming to provide assistance for the analysis of specific security vulnerabilities of cross-chain smart contract codes through static analysis and dynamic simulation execution technology of cross-chain smart contracts, and to achieve the ability to accurately detect code security that supports cross-chain smart contracts.

[0006] Specifically, the method of the present invention comprises the following steps:

[0007] S1. Cross-chain smart contract code preprocessing: Perform independent static code analysis on cross-chain smart contracts involving multiple blockchains. First, obtain the control flow graphs (CFGs) of cross-chain contracts A and B respectively. aand CFG b ) and data flow graph (DFG a and DFG b ).

[0008] S2. Access control constraint class node identification: the control flow graph CFG generated in step S1 a and CFG b We conduct an analysis to identify nodes that contain conditional statements, and further use natural semantic analysis technology to analyze the function of conditional judgments, extract nodes involving key semantics such as "transfer", "amount", "signature" and "identity check", and mark them as "access control constraint nodes".

[0009] S3. Alignment of cross-chain control flow and data flow graph: Based on the control flow graph (CFG generated in step S1) a and CFG b ) and Data Flow Graph (DFG a and DFG b ), by constructing an extended connection path, a cross-chain control flow graph xCFG and a cross-chain data flow graph xDFG are generated. First, the "deposit" event and the "withdraw" event are identified in the control flow graph, and an edge (extend edge) of the "deposit" node is extended to point to the "withdraw" node in another control flow graph to form xCFG; then, the DFG is mapped according to the variables in xCFG. a and DFG b Merge them to get the cross-chain data flow graph xDFG.

[0010] S4. Cross-chain taint tracking: Based on the xCFG and xDFG generated in step S3, the external input of the cross-chain contract (including user input and public interface parameters) is used as the taint source to perform data flow taint analysis. Along the data flow path, the flow of data in external function calls or contract state variables (such as BALANCE) is tracked. If it is found that the data flow does not pass the access control constraint class node, it is considered a potential security vulnerability.

[0011] S5. Vulnerability confirmation based on simulated execution: For the potential vulnerabilities identified in step S4, an offline simulated execution environment is constructed by synchronizing the data of the blockchain where the cross-chain smart contract is located. The external input interface of the cross-chain contract is called in the simulated environment, and the contract is executed using the execution engine of the corresponding blockchain to confirm whether the external input data has an actual impact on the contract status, thereby verifying whether the vulnerability exists.

[0012] Based on the above steps, the present invention proposes a cross-contract address verification method and system based on smart contract simulation execution, and its system architecture includes a cross-chain contract code preprocessing unit, an access control constraint node identification unit, a cross-chain control flow and data flow graph analysis unit, a cross-chain taint tracking unit, and a simulation execution vulnerability verification unit. The architecture of the cross-chain contract code preprocessing unit is shown in the attached figure. Figure 2 As shown in the figure, it includes the blockchain contract code capture submodule, the contract code control flow analysis submodule and the contract code data flow analysis submodule; the architecture of the access control constraint node identification unit is shown in the figure. Figure 3 As shown in the figure, it includes the contract code abstract syntax tree generation submodule and the contract code natural semantic analysis submodule; the architecture of the cross-chain control flow and data flow graph analysis unit is shown in the attached Figure 4 As shown in the figure, it includes the control flow graph alignment and merging submodule, the data flow graph alignment and merging submodule and the path extension submodule; the architecture of the cross-chain taint tracking unit is shown in the figure. Figure 5 As shown in the figure, it includes the taint source identification submodule, the taint tracking engine submodule and the vulnerability detection submodule; the architecture of the simulation execution vulnerability verification unit is shown in the figure. Figure 6 As shown, it includes the blockchain historical data synchronization submodule, the blockchain simulation execution submodule and the vulnerability status verification submodule. Technical Effects

[0013] Through the above-mentioned invention steps and invention system, the present invention realizes the enhanced security analysis capability of cross-chain smart contract code, combines traditional static and dynamic program analysis techniques, and expands them according to the characteristics of cross-chain smart contracts. It can identify security vulnerabilities unique to cross-chain smart contracts and expand the scope and accuracy of smart contract security vulnerability detection. BRIEF DESCRIPTION OF THE DRAWINGS

[0014] Figure 1 Shown is a flow chart of a cross-contract address verification method based on smart contract simulation execution disclosed in an embodiment of the present invention.

[0015] Figure 2 Shown is a schematic diagram of the cross-chain contract code preprocessing unit architecture disclosed in an embodiment of the present invention.

[0016] Figure 3 Shown is a schematic diagram of the access control constraint node identification unit architecture disclosed in an embodiment of the present invention.

[0017] Figure 4 Shown is a schematic diagram of the architecture of the cross-chain control flow and data flow graph analysis unit disclosed in an embodiment of the present invention.

[0018] Figure 5 Shown is a schematic diagram of the architecture of the cross-chain taint tracking unit disclosed in an embodiment of the present invention.

[0019] Figure 6 Shown is a schematic diagram of the architecture of the simulated execution vulnerability verification unit disclosed in an embodiment of the present invention. DETAILED DESCRIPTION

[0020] The following is a specific embodiment of the present invention, which describes in detail the specific implementation of each step to show the operation details of the method:

[0021] For step S1. Cross-chain smart contract code preprocessing, the code of the cross-chain smart contract is preprocessed by the cross-chain contract code preprocessing unit to generate the control flow graph (CFG) and data flow graph (DFG) of the code. In specific implementation, the contract code is first obtained from each blockchain platform through the contract code capture submodule, and then the control flow graph and data flow graph are generated for each contract using static analysis tools (such as Slither, etc.). These graphs are used to represent the function call relationship and variable transfer relationship of the contract code, and prepare for subsequent access control analysis and cross-chain graph alignment.

[0022] For step S2. Identification of access control constraint nodes, further analyze the nodes in the control flow graph through the access control constraint node identification unit to identify key nodes with access control functions. The specific technical method includes using the contract code abstract syntax tree (AST) generation submodule to generate the AST tree structure of the contract code, and using the contract code natural semantic analysis submodule combined with natural language processing technology to perform semantic identification on the conditional judgment nodes in the control flow graph, extracting nodes involving key semantics such as "transfer", "amount", "signature", and "identity check", and marking them as access control constraint nodes. NLP libraries (such as spaCy or NLTK) can be used to perform semantic analysis on conditional judgment statements, thereby enhancing the accuracy of static analysis results.

[0023] For step S3. Alignment of cross-chain control flow and data flow graph, the generation of cross-chain graph is realized by cross-chain control flow and data flow graph analysis unit, control flow graph alignment merging submodule and data flow graph alignment merging submodule. First, identify the "deposit" and "withdraw" events in each contract control flow graph, and build extended edges to connect these event nodes in the control flow graphs of different chains to generate a cross-chain control flow graph (xCFG). Subsequently, according to the cross-chain control relationship in xCFG, the corresponding merge is performed in the data flow graph to obtain a cross-chain data flow graph (xDFG).

[0024] For step S4. Cross-chain taint tracking, in the cross-chain taint tracking unit, the external input (such as user input and parameters of the public call interface) is identified as the taint source through the taint source identification submodule. The propagation path of the external input is tracked along the data flow in xCFG and xDFG using the taint tracking engine submodule. For data flows that do not pass through access control constraint nodes and flow directly to external function calls or contract state variables (such as BALANCE), they are considered potential vulnerabilities. Dynamic analysis tools (such as Ethainter, etc.) can be used to implement taint tracking analysis to ensure that all potential vulnerability paths are accurately identified.

[0025] For step S5. Vulnerability confirmation based on simulated execution, the potential vulnerabilities identified in the taint tracking are verified through the simulated execution vulnerability verification unit. The data of the relevant cross-chain contract is synchronized to the local through the blockchain historical data synchronization submodule, an offline simulated execution environment is constructed, and the external input interface of the cross-chain contract is called by the blockchain simulated execution submodule in the simulated environment. The contract is executed using the blockchain execution engine (such as EVM simulator or Tendermint simulator), the impact of external input data on the contract status is checked, and the vulnerability status verification submodule is used to confirm whether there is an actual impact, thereby judging the authenticity of the vulnerability.

[0026] The above-mentioned specific implementation can be partially adjusted in different ways by those skilled in the art without departing from the principle and purpose of the present invention. The protection scope of the present invention shall be based on the claims and shall not be limited by the above-mentioned specific implementation. Each implementation scheme within its scope shall be subject to the constraints of the present invention.

Claims

1. A cross-contract address verification method and system based on smart contract simulation execution, characterized in that: The system includes a cross-chain contract code preprocessing unit, an access control constraint node identification unit, a cross-chain control flow and data flow graph analysis unit, a cross-chain taint tracking unit, and a simulated execution vulnerability verification unit. Through the collaborative work of various units, cross-contract address verification and vulnerability detection of cross-chain smart contracts can be achieved.

2. According to claim 1, a cross-contract address verification method and system based on smart contract simulation execution is characterized in that: The cross-chain contract code preprocessing unit includes a blockchain contract code capture submodule, a contract code control flow analysis submodule and a contract code data flow analysis submodule, which are used to obtain the code of the cross-chain contract and generate respective control flow graphs and data flow graphs.

3. A cross-contract address verification method and system based on smart contract simulation execution according to claim 1 or 2, characterized in that: The access control constraint node identification unit includes a contract code abstract syntax tree generation submodule and a contract code natural semantic analysis submodule, which are used to perform natural semantic analysis on the conditional judgment nodes in the control flow graph, identify key semantic nodes such as transfer, amount, signature and identity check, and mark them as access control constraint nodes.

4. A cross-contract address verification method and system based on smart contract simulation execution according to any one of claims 1 to 3, characterized in that: The cross-chain control flow and data flow graph analysis unit includes a control flow graph alignment and merging submodule, a data flow graph alignment and merging submodule and a path extension submodule, which are used to identify and merge the "amount deposit" and "amount withdrawal" nodes in the control flow graph, and generate a cross-chain control flow graph and a cross-chain data flow graph.

5. A cross-contract address verification method and system based on smart contract simulation execution according to any one of claims 1 to 4, characterized in that: The cross-chain taint tracking unit includes a taint source identification submodule, a taint tracking engine submodule and a vulnerability detection submodule, which are used to track the data flow direction based on the cross-chain control flow graph and the cross-chain data flow graph, with external input as the taint source, and detect whether there is a situation in the data flow that bypasses the access control constraint class node.

6. A cross-contract address verification method and system based on smart contract simulation execution according to any one of claims 1 to 5, characterized in that: The simulated execution vulnerability verification unit includes a blockchain historical data synchronization submodule, a blockchain simulated execution submodule and a vulnerability status verification submodule. It synchronizes the blockchain data involved in the cross-chain contract offline and verifies the impact of external input data on the contract status in the blockchain simulated execution environment to confirm the existence of the vulnerability.