Smart contract and chain environment interaction vulnerability detection method, system, equipment and medium
Through smart contract transaction generation and chain environment simulation, an interactive transaction model is formed and formal verification is carried out, which solves the problem of the inability to detect interactive vulnerabilities between smart contracts and chain environments in the existing technology, and improves the security and detection efficiency of smart contracts.
Patent Information
- Application Number
- CN202210620850.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-06-02
- Publication Date
- 2024-12-03
- Estimated Expiration
- 2042-06-02
AI Technical Summary
The existing technology cannot effectively detect interactive vulnerabilities between smart contracts and chain environments, resulting in the inability to effectively prevent hackers' second type of attack methods, and lack transaction generation and processing solutions, resulting in inefficiency in the detection system.
Through smart contract transaction generation, processing and chain environment simulation, the smart contract intermediate code is converted into a behavior model to form an interactive transaction model, and the formal verification and inspiration strategy library are used to cut irrelevant transactions to generate non-repetitive behavioral complete transactions related to target attributes set, perform formal verification.
It can effectively detect interactive vulnerabilities between smart contracts and chain environments, improve security, prevent attacks, improve detection efficiency and performance, analyze malicious transactions and their probability, and analyze the impact of transaction execution time on the results.
Smart Images

Figure CN114896604B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of blockchain smart contract security technology, and in particular to a method, system, device and medium for detecting vulnerabilities in the interaction between a smart contract and a chain environment. Background Art
[0002] Blockchain is a new application model of computer technologies such as distributed data storage, peer-to-peer transmission, consensus mechanism, and encryption algorithm. The technology of using decentralized consensus mechanism to maintain a complete, distributed, and tamper-proof ledger database enables participants in the blockchain to achieve a unified ledger system without establishing a trust relationship. A smart contract is a set of commitments defined in digital form, including the agreement on which the contract participants can execute these commitments. In the context of blockchain technology, smart contracts refer to program codes that run on the blockchain and can perform certain functions. Smart contracts are written into the blockchain in a digital form, and the characteristics of blockchain technology ensure that the entire process of storage, reading, and execution is transparent, traceable, and tamper-proof. At the same time, a state machine system is constructed by the consensus algorithm of the blockchain itself, so that smart contracts can run efficiently.
[0003] Due to the tamper-proof nature of blockchain, once a smart contract is attacked due to its own design defects, it may cause irreversible and significant losses. Existing technologies usually use some code defect inspection methods, such as formal verification, static code analysis, fuzz testing and other technologies, to discover program defect codes in advance and modify the problem codes in time, which can play a preventive role.
[0004] Hackers' attack methods on smart contracts can be divided into two categories: 1) Analyze the code of a single smart contract on the chain, find program vulnerabilities and launch attacks; 2) Analyze the combined interactive behaviors of multiple smart contracts on the chain, find interactive vulnerabilities and launch attacks. Existing smart contract code vulnerability detection and verification systems and tools all use static code analysis, fuzz testing, and formal verification methods to detect and verify single smart contract programs to prevent hackers' first attack methods. The prior art also mentions the situation of combined transactions of smart contracts, but does not propose a method for cutting and generating non-repetitive behavior complete transactions related to target attributes, and the verification engine used cannot infer the impact of transaction execution time on the attack effect. In short, the system or tool designed by the existing technical solution lacks chain environment simulation functions such as transaction execution time and transaction random execution, resulting in the inability to infer or detect the interactive vulnerabilities between smart contracts and chain environments caused by transaction execution time in the transaction pool, transaction reordering, and miners inserting malicious transaction sequences, thereby failing to effectively prevent hackers' second attack methods (i.e., attacks on interactive vulnerabilities).
[0005] In addition, the existing technology lacks effective transaction generation and processing solutions. In terms of transaction generation, the existing technology lacks filtering and screening of transactions, resulting in the detection engine having to process a large number of transactions that are irrelevant to target attributes during transaction processing, which greatly reduces the vulnerability detection capability of the detection system. In particular, when the detection engine uses formal methods to process a large number of transactions, the detection system will fail due to the path state space explosion problem. Summary of the invention
[0006] In order to solve the problem that the existing technology cannot effectively detect the interaction loopholes between smart contracts and chain environments, the present invention provides a method, system, device and medium for detecting the interaction loopholes between smart contracts and chain environments. The present invention can detect the interaction loopholes between smart contracts and chain environments through smart contract transaction generation, processing and chain environment simulation.
[0007] The present invention is achieved through the following technical solutions:
[0008] A method for detecting vulnerabilities in interaction between a smart contract and a chain environment, comprising:
[0009] Compile the target smart contract and the on-chain smart contract source code into smart contract intermediate code;
[0010] Convert smart contract intermediate code into smart contract behavior model;
[0011] Convert smart contract behavior model into interactive transaction model;
[0012] Formal verification is performed on the interaction transaction model and the target attribute model.
[0013] As a preferred implementation, the present invention converts the smart contract intermediate code into a smart contract behavior model, specifically:
[0014] The smart contract intermediate code is converted into a token sequence through a lexical analyzer;
[0015] Determine the type of each line of smart contract intermediate code based on the tag sequence and generate an intermediate code type sequence;
[0016] Generate abstract intermediate codes with smart contract functions as basic units according to the intermediate code type sequence;
[0017] The abstract intermediate code is converted into a behavior model based on a timed automaton according to the preset language grammar rules.
[0018] As a preferred embodiment, a smart contract behavior of the present invention corresponds to a time automaton of a smart contract function, including contract state, time or non-time variables, events and state transfer relations.
[0019] As a preferred implementation, the present invention converts the smart contract behavior model into an interactive transaction model, specifically:
[0020] Select several behaviors from the smart contract behavior model to form a complete transaction set of non-repetitive behaviors related to the target attributes to form an interactive transaction model.
[0021] As a preferred embodiment, the process of generating an interactive transaction of the present invention further includes:
[0022] Use the heuristic strategy library to cut out the interactive transactions that are irrelevant to the target attributes;
[0023] The heuristic strategy library stores necessary transaction features that can satisfy the target attributes. If the generated interactive transactions satisfy these necessary transaction features, they can satisfy the target attributes; otherwise, they should be cut off.
[0024] As a preferred embodiment, the target attribute model of the present invention is automatically generated by inputting the target attribute document into the attribute model generator;
[0025] The target attribute document is a security requirement description document of the smart contract.
[0026] In the second aspect, the present invention proposes a smart contract and chain environment interaction vulnerability detection system, including: a smart contract front-end compiler, an automated modeling tool, a property model generator, a statistical model detection engine, and a report generator;
[0027] The smart contract front-end compiler is used to receive the target smart contract and the on-chain smart contract source code and compile them into smart contract intermediate code;
[0028] The automated modeling tool is used to receive the intermediate code output by the smart contract front-end compiler, and rely on the behavior model generator and the transaction model generator to automatically model the intermediate code to obtain the smart contract interaction transaction model;
[0029] The attribute model generator is used to receive the target attribute document and translate it into a target attribute model containing time attributes;
[0030] The statistical model checking engine is used to receive the interactive transaction model generated by the automated modeling tool and the target attribute model generated by the attribute model generator, and perform formal verification on them;
[0031] The report generator is used to receive the verification results output by the statistical model detection engine and generate a smart contract vulnerability detection document.
[0032] As a preferred embodiment, the detection system of the present invention further includes a heuristic strategy library;
[0033] The heuristic strategy library is used to store necessary transaction features that can meet the target attributes and filter out transactions generated by the behavior model generator that are irrelevant to the target attributes.
[0034] As a preferred embodiment, the statistical model detection engine of the present invention has time characteristics and random characteristics;
[0035] The statistical model detection engine uses time characteristics and random characteristics to obtain two types of verification results:
[0036] The probability that the interactive transaction model satisfies the target attributes;
[0037] And whether the probability that the target attribute model satisfies the target attribute is greater than or equal to a preset threshold.
[0038] In a third aspect, the present invention proposes a computer device, comprising a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps of the method of the present invention when executing the computer program.
[0039] The present invention has the following advantages and beneficial effects:
[0040] 1. The present invention can detect the interaction loopholes between smart contracts and chain environments, thereby effectively preventing attacks on smart contracts and improving the security of smart contracts.
[0041] 2. The present invention provides a complete transaction set of non-repetitive behaviors related to the target attributes, while taking into account the path space explosion problem of the formal detection engine, and covers any possible attack transactions on the chain such as transaction reordering and miners inserting malicious transaction sequences to the greatest extent, thereby improving detection efficiency and detection performance.
[0042] 3. The present invention can not only analyze malicious transactions and the probability of their occurrence, but also analyze the impact of transaction execution time on execution results, thereby obtaining more accurate verification results. BRIEF DESCRIPTION OF THE DRAWINGS
[0043] The drawings described herein are used to provide a further understanding of the embodiments of the present invention, constitute a part of this application, and do not constitute a limitation of the embodiments of the present invention. In the drawings:
[0044] Figure 1 The figure is a flow chart of the detection method according to an embodiment of the present invention.
[0045] Figure 2 The figure is a functional block diagram of a computer device according to an embodiment of the present invention.
[0046] Figure 3 4 is a principle block diagram of a detection system according to an embodiment of the present invention.
[0047] Figure 4 Schematic diagram of a time state machine according to an embodiment of the present invention. DETAILED DESCRIPTION
[0048] In order to make the objectives, technical solutions and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with embodiments and drawings. The exemplary embodiments of the present invention and their description are only used to explain the present invention and are not intended to limit the present invention.
[0049] Example 1
[0050] In view of the problem that the prior art lacks effective smart contract transaction generation and processing and chain environment simulation functions, and is unable to detect vulnerabilities in the interaction between smart contracts and chain environments, thereby failing to effectively prevent attacks on smart contracts, this embodiment proposes a method for detecting vulnerabilities in the interaction between smart contracts and chain environments.
[0051] like Figure 1 As shown, the detection method of this embodiment includes the following steps:
[0052] Step 1: Compile the target smart contract and the on-chain smart contract source code into smart contract intermediate code.
[0053] In this step, the target smart contract is the contract to be verified before being put on the chain; the on-chain smart contract is the on-chain smart contract that has interactive value with the target smart contract, such as the unsecured loan contracts, exchange contracts and mortgage loan contracts in the financial field.
[0054] Smart contract intermediate code is usually represented in bytecode form.
[0055] Step 2: Convert the smart contract intermediate code into a smart contract behavior model.
[0056] This step also includes the following sub-steps:
[0057] Step 21, convert the smart contract intermediate code into a token sequence through a lexical analyzer;
[0058] Step 22, determine the type of each line of smart contract intermediate code according to the tag sequence and generate an intermediate code type sequence (for example, function body type, common instruction type, etc.);
[0059] Step 23, generating an abstract intermediate code with the smart contract function as the basic unit according to the intermediate code type sequence;
[0060] Step 24: convert the abstract intermediate code into a behavior model based on a timed automaton according to preset language grammar rules.
[0061] Among them, a smart contract behavior corresponds to a time automaton of a smart contract function, which includes contract status, time or non-time variables, events and state transfer relations.
[0062] Step 3: Convert the smart contract behavior model into an interactive transaction model.
[0063] The specific step is: select several behaviors from the smart contract behavior model to form a non-repetitive behavior complete transaction set related to the target attribute to form an interactive transaction model. A feasible random transaction generation method is as follows:
[0064] If the set A represents the smart contract behavior model, then a transaction t∈T is a sequence of n non-repeating behaviors extracted from the set A. Let P(A) represent the power set of A. Given an element K∈P(A), let σ(K) represent the full permutation set of K. Formula (1) gives the definition of the transaction set T consisting of transactions of different lengths and permutations:
[0065]
[0066]
[0067]
[0068] The above random transaction generation method gives any possible transaction that can be generated from the behavior model without repeating the selected behavior. Under the framework of the above method, the transaction set can be further expanded by selectively repeating the behaviors in K according to the actual target attribute requirements. Therefore, the random transaction set constructed by the timed automaton behavior model can simulate any possible attack transactions in the on-chain transaction pool, such as transaction execution time, transaction reordering, and miners inserting malicious transaction sequences.
[0069] In addition, since each transaction in the interactive transaction model requires formal reasoning, the transaction generation process should minimize the generation of transactions that are irrelevant to the target attributes. Therefore, in step three, the heuristic strategy library is used to trim transactions that are irrelevant to the target attributes during the generation of interactive transactions.
[0070] The heuristic strategy library stores the necessary transaction features that can satisfy the target attributes. The so-called necessary transaction features refer to the necessary features of transactions that satisfy the target attributes. The generated transactions can only satisfy the target attributes if they meet these necessary transaction features. Transactions that do not meet these necessary transaction features should be pruned, that is, transactions that are irrelevant to the target attributes are filtered out to solve the combinatorial path explosion problem in formal verification. For example, possible heuristic strategies that meet the target attributes include: 1) The transaction contains no less than two behaviors; 2) The transaction must start with a special behavior; 3) The transaction must end with a special behavior; 4) A behavior in the transaction must depend on at least one previously executed behavior, etc.
[0071] Step 4: Perform formal verification on the interactive transaction model and the target attribute model, and output the verification results.
[0072] The target attribute model is automatically generated by inputting the target attribute document into the attribute model generator. The so-called target attribute document is a security requirement description document of the smart contract, which is usually based on a natural language description form of a limited template and domain vocabulary.
[0073] This embodiment also provides a computer device for executing the above method of this embodiment.
[0074] Specific as Figure 2 As shown, the computer device includes a processor, an internal memory and a system bus; various device components including the internal memory and the processor are connected to the system bus. The processor is a piece of hardware used to execute computer program instructions through basic arithmetic and logical operations in the computer system. The internal memory is a physical device used to temporarily or permanently store computer programs or data (for example, program status information). The system bus can be any of the following types of bus structures, including a memory bus or a storage controller, a peripheral bus, and a local bus. The processor and the internal memory can communicate data through the system bus. The internal memory includes a read-only memory (ROM) or a flash memory (not shown in the figure), and a random access memory (RAM), and RAM usually refers to the main memory loaded with the operating system and computer programs.
[0075] Computer devices generally include an external storage device. The external storage device can be selected from a variety of computer-readable media, which refers to any available media that can be accessed by the computer device, including both removable and fixed media. For example, computer-readable media include, but are not limited to, flash memory (micro SD card), CD-ROM, digital versatile disk (DVD) or other optical disk storage, magnetic tape cassettes, magnetic tapes, magnetic disk storage or other magnetic storage devices, or any other medium that can be used to store the desired information and can be accessed by the computer device.
[0076] Computer devices can be logically connected to one or more network terminals in a network environment. Network terminals can be personal computers, servers, routers, smart phones, tablets, or other public network nodes. Computer devices are connected to network terminals through network interfaces (local area network LAN interfaces). Local area network (LAN) refers to a network of computers interconnected within a limited area, such as a home, school, computer laboratory, or office building using network media. WiFi and twisted pair cabling Ethernet are the two most commonly used technologies for building LANs.
[0077] It should be noted that other computer systems including more or fewer subsystems than a computer device may also be suitable for the invention.
[0078] As described in detail above, the computer device applicable to this embodiment can perform the specified operations of the method for detecting vulnerabilities in the interaction between smart contracts and chain environments. The computer device performs these operations in the form of software instructions running in a computer-readable medium by a processor. These software instructions can be read into the memory from a storage device or from another device through a local area network interface. The software instructions stored in the memory enable the processor to execute the above-mentioned method for processing group member information. In addition, the present invention can also be implemented by hardware circuits or hardware circuits combined with software instructions. Therefore, the implementation of this embodiment is not limited to any specific combination of hardware circuits and software.
[0079] Example 2
[0080] This embodiment proposes a smart contract and chain environment interaction vulnerability detection system. Figure 3 As shown, the detection system of this embodiment includes:
[0081] The smart contract front-end compiler is used to receive the blockchain smart contract source code implemented in the same or different programming languages, and compile the smart contract source code into an intermediate code in a unified representation.
[0082] The automated modeling tool is used to receive the intermediate code output by the smart contract front-end compiler, and relies on the behavior model generator and the transaction model generator to automatically model the intermediate code to obtain the smart contract interaction transaction model.
[0083] The behavior model generator is used to convert the smart contract intermediate code into the smart contract behavior model. The specific process is as described in the above embodiment 1 and will not be repeated here.
[0084] The transaction model generator is used to convert the smart contract behavior model into an interactive transaction model. The interactive transaction generation method is as described in the above embodiment 1 and will not be repeated here.
[0085] The heuristic strategy library is used to store the necessary transaction features that can meet the target attributes, filter out transactions generated by the behavior model generator that are irrelevant to the target attributes, and solve the combinatorial path explosion problem in formal verification.
[0086] The attribute model generator is used to receive the target attribute document, translate the target attribute document into a target attribute model containing time attributes (for example, performing time extension on linear temporal logic LTL), and input the target attribute model into the statistical model detection engine.
[0087] The statistical model detection engine is used to receive the interactive transaction model generated by the transaction model generator and the target attribute model generated by the attribute model generator, and perform formal verification on them, and output the verification results to the smart contract and chain environment interaction vulnerability detection generator. In addition to being able to handle conventional finite state automata, the statistical model detection engine needs to further expand the following two features: 1) Time characteristics, such as time variables and real-time semantic support based on time automata; 2) Random characteristics, such as probability variables and discrete time random semantic support based on Markov chains. Using time characteristics and random characteristics, the statistical model detection engine can obtain two types of reasoning results: 1) The probability that the interaction model satisfies the target attributes;
[0088] 2) Whether the probability that the attribute model satisfies the target attribute is greater than or equal to a certain threshold. Using the above characteristics, the chain environment simulation and verifier can not only analyze malicious transactions and their probability of occurrence, but also analyze the impact of transaction execution time on execution results, thereby obtaining more accurate verification results.
[0089] The smart contract and chain environment interaction vulnerability detection report generator is used to receive the verification results output by the statistical model detection engine and generate smart contract vulnerability detection documents.
[0090] Example 3
[0091] In this embodiment, the game smart contract application of the Ethereum blockchain platform is used as an example. Assume that there are two game contracts A and B, each of which has the right to issue game coins AToken and BToken, and AToken and BToken can be exchanged in any game coin trading market AMarket or BMarket provided by A or B. The hacker first exchanges AToken for BToken in BMarket, then exchanges BToken back to AToken in AMarket, and finally obtains the game coins. Figure 1 or Figure 3 , the tool proposed in the embodiment of the present invention is used to describe the above-mentioned vulnerability detection process of siphoning game coins in detail, and the main steps are as follows:
[0092] 1) Import the contract source code of the smart contract A to be verified and the smart contract B on the chain into the smart contract front-end compiler. In this example, the game contract source code is written in the high-level programming language supported by the Ethereum blockchain: Solidity language;
[0093] 2) The smart contract front-end compiler converts the game contract written in Ethereum solidity language into smart contract intermediate code one by one. The intermediate code contains the program logic and data information of game contracts A and B, such as source code variables, constants, and functions. Constants in game contracts A and B include constant factors A_RATIO, A_FEE, B_RATIO, and B_FEE used for exchange rate calculation. Variables in game contracts A and B include the current total amount of AToken in AMarket [AToken], the total amount of BToken in AMarket [BToken], the current total amount of BToken in BMarket [BToken], the total amount of AToken in BMarket [AToken], and the current total amount of AToken in attacker Attacker [AToken], and the total amount of BToken Attacker [BToken]. For example, the function in game contracts A and B is the exchange function AExchange(InToken, OutToken, InAmount), which means selling InAmount of InToken and obtaining OutAmount of OutToken. The OutAmount that can be obtained here needs to be obtained through constant factors A_RATIO, A_FEE and a specific exchange rate algorithm. Similarly, the exchange function in B is BExchange(InToken, OutToken, InAmount).
[0094] 3) The automated modeling tool first converts the smart contract intermediate code into a smart contract behavior model with the help of the behavior model generator, and then generates an interactive transaction model through the transaction model generator and the heuristic strategy library. For example: the time automaton model of the exchange function AExchange is as follows: Figure 4As shown in the figure, x is the automaton time variable, S0 state is the initial state, including symbolic state variables S0_Attacker[AToken], S0_Attacker[BToken], S0_AMarket[AToken], S0_AMarket[BToken], S0_BMarket[AToken], S0_BMarket[BToken], after the event BExchange, the state is transferred from S0 to S1, and the modified state is: S1_Attacker[AToken]=S0_Attacker[AToken]–InAmount, S1_Attacker[BToken]=S0_Attacker[BToken]+OutAmount, S1_BMarket[AToken]=S0_BMarket[AToken]+InAmount, S1_BMarket[BToken]=S0_BMarket[BToken]–OutAmount, S 1_AMarket[AToken]=S0_AMarket[AToken]、S1_AMarket[BToken]=S0_AMarket[BToken],after event AExchange, the state is transferred from S1 to S2. The modified states are: S2_Attacker[BToken]=S1_Attacker[BToken]–InAmount、S2_Attacker[AToken]=S1_Attacker[AToken]+OutAmount、S2_AMarket[BToken]=S1_AMarket[BToken]+InAmount、S2_AMarket[AToken]=S1_AMarket[AToken]–OutAmount、S2_BMarket[AToken]=S1_BMarket[AToken]、S2_BMarket[BToken]=S1_BMarket[BToken]. This example state machine contains two behavior models, {S0->S1} and {S1->S2}. The four transactions that can be generated are {{S0->S1}, {S1->S2}, {S0->S1->S2}, {S0->S2->S1}}. Assuming that the heuristic strategy library stipulates that a) a transaction must contain at least two actions and b) there must be an AExchange action before BExchange, then after the above four transactions are pruned by the heuristic strategy library, there are only Figure 2 The {S0->S1->S2} transaction in meets the conditions, which greatly reduces the path state space of formal reasoning.
[0095] 4) The attribute described in the target attribute document in this example is "whether the attacker can increase N ATokens in the attacker's account through the exchange function of the contract market on different platforms". This attribute document is converted into the following time-based LTL target attribute model by the target attribute generator:
[0096] φ(t)=F [0,t] S2_Attacker[AToken]≥S0_Attacker[AToken]+N∧S2 Attacker[AToken]=S0 Attacker[AToken]
[0097] 5) First, the necessary statistical parameters and thresholds are set according to the characteristics of the statistical model detection engine, and then the satisfiability of the interactive transaction model and the target attribute model is inferred. If the statistical probability is 0, it means that there is no risk of vulnerability described in the target attribute for the attacker to siphon off game coins. Otherwise, the detection engine will report the change in the probability of the attacker's successful attack as the transaction execution time changes, indicating that there is an interactive security problem between the game contract A and the existing contract B on the chain.
[0098] The specific implementation methods described above further illustrate the objectives, technical solutions and beneficial effects of the present invention in detail. It should be understood that the above description is only a specific implementation method of the present invention and is not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the scope of protection of the present invention.
Claims
1. A method for detecting vulnerabilities in interaction between smart contracts and chain environments, characterized in that: include: Compile the target smart contract and the on-chain smart contract source code into smart contract intermediate code; Convert smart contract intermediate code into smart contract behavior model; Convert smart contract behavior model into interactive transaction model; Formal verification of the interactive transaction model and the target attribute model; converting the smart contract intermediate code into a smart contract behavior model, specifically: The smart contract intermediate code is converted into a token sequence through a lexical analyzer; Determine the type of each line of smart contract intermediate code based on the tag sequence and generate an intermediate code type sequence; Generate abstract intermediate codes with smart contract functions as basic units according to the intermediate code type sequence; Convert the abstract intermediate code into a behavior model based on a timed automaton according to the preset language grammar rules; A smart contract behavior corresponds to a time automaton of a smart contract function, including contract state, time or non-time variables, events and state transition relations; the smart contract behavior model is converted into an interactive transaction model, specifically: Select several behaviors from the smart contract behavior model to form a complete transaction set of non-repetitive behaviors related to the target attributes to form an interactive transaction model; The process of generating interactive transactions also includes: Use the heuristic strategy library to cut out the interactive transactions that are irrelevant to the target attributes; The heuristic strategy library stores necessary transaction features that can satisfy the target attributes. If the generated interactive transactions meet these necessary transaction features, they can meet the target attributes, otherwise they should be cut off; the target attribute model is automatically generated by inputting the target attribute document into the attribute model generator; The target attribute document is a security requirement description document of the smart contract.
2. A smart contract and chain environment interaction vulnerability detection system, characterized in that: include: Smart contract front-end compiler, automated modeling tool, property model generator, statistical model checking engine and report generator; The smart contract front-end compiler is used to receive the target smart contract and the on-chain smart contract source code and compile them into smart contract intermediate code; The automated modeling tool is used to receive the intermediate code output by the smart contract front-end compiler, and rely on the behavior model generator and the transaction model generator to automatically model the intermediate code to obtain the smart contract interaction transaction model; wherein the behavior model generator converts the smart contract intermediate code into a smart contract behavior model, specifically including: The smart contract intermediate code is converted into a token sequence through a lexical analyzer; Determine the type of each line of smart contract intermediate code based on the tag sequence and generate an intermediate code type sequence; Generate abstract intermediate codes with smart contract functions as basic units according to the intermediate code type sequence; Convert the abstract intermediate code into a behavior model based on a timed automaton according to the preset language grammar rules; A smart contract behavior corresponds to a time automaton of a smart contract function, including contract state, time or non-time variables, events, and state transition relations; The transaction model generator converts the smart contract behavior model into an interactive transaction model, specifically including: Select several behaviors from the smart contract behavior model to form a complete transaction set of non-repetitive behaviors related to the target attributes to form an interactive transaction model; The attribute model generator is used to receive a target attribute document and translate it into a target attribute model containing a time attribute; the target attribute document is a security requirement description document of a smart contract; The statistical model checking engine is used to receive the interactive transaction model generated by the automated modeling tool and the target attribute model generated by the attribute model generator, and perform formal verification on them; The report generator is used to receive the verification results output by the statistical model detection engine and generate a smart contract vulnerability detection document; it also includes a heuristic strategy library; The heuristic strategy library is used to store necessary transaction features that can meet the target attributes and filter out transactions generated by the behavior model generator that are irrelevant to the target attributes.
3. A smart contract and chain environment interaction vulnerability detection system according to claim 2, characterized in that: The statistical model detection engine has time characteristics and random characteristics; The statistical model detection engine uses time characteristics and random characteristics to obtain two types of verification results: The probability that the interactive transaction model satisfies the target attributes; And whether the probability that the target attribute model satisfies the target attribute is greater than or equal to a preset threshold.
4. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that: When the processor executes the computer program, the steps of the method according to claim 1 are implemented.
