Cross-chain bridge smart contract vulnerability detection method and related equipment
By analyzing the target control flow and access control constraints of cross-chain bridge smart contracts, identifying incomplete and semantic inconsistent access control constraints, the problem of difficult to identify cross-chain bridge smart contract vulnerabilities in the existing technology is solved, and a more accurate and comprehensive vulnerability detection effect is achieved.
Patent Information
- Application Number
- CN202410554484.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-07
- Publication Date
- 2025-03-25
- Estimated Expiration
- 2044-05-07
AI Technical Summary
It is difficult for the existing technology to effectively identify vulnerabilities in cross-chain bridge smart contracts, especially the lack of ability to identify context information during cross-chain data transmission, resulting in the inability to accurately identify vulnerabilities in cross-chain bridge smart contracts.
By determining the target control flow set of smart contracts on both sides of the cross-chain bridge to be analyzed, all access control constraints in the target control flow set are identified, whether these access control constraints are complete, and further analyzing incomplete and semantic inconsistent access control constraints are determined to determine whether there is a cross-chain bridge vulnerability.
It realizes more comprehensive and accurate vulnerability detection of cross-chain bridge smart contracts, can identify vulnerabilities with wider access control inconsistency and semantic inconsistency, and improves the accuracy and recall of vulnerability detection.
Smart Images

Figure CN118468282B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of vulnerability detection technology, and in particular to a cross-chain bridge smart contract vulnerability detection method and related equipment. Background Art
[0002] With the increasing popularity of blockchain technology, different blockchain platforms can coexist in the ecosystem. For example, Ethereum, BNB, EOSIO and other blockchain platforms can coexist in the ecosystem. The current situation of multi-chain ecology has put forward high requirements for cross-chain communication, which has given rise to cross-chain bridges that focus on providing blockchain cross-chain services. A cross-chain bridge is a special decentralized application that consists of smart contracts deployed on multiple chains and can be used to exchange assets and data between different blockchain platforms. Due to vulnerabilities in the cross-chain bridge smart contract, many security incidents with major economic losses have occurred, and a method for detecting cross-chain bridge smart contract vulnerabilities is urgently needed.
[0003] Existing smart contract vulnerability detection technology can only extract typical security control statements in smart contracts, but lacks the extraction of cross-chain semantics, resulting in incomplete security control information. In addition, cross-chain bridges involve the exchange of asset data of multiple blockchains, and the link relationship between resources and security checks is relatively complex. Existing technologies lack the ability to identify contextual information during cross-chain data transmission, and therefore cannot effectively identify vulnerabilities in cross-chain bridge smart contracts. Summary of the invention
[0004] The present application aims to solve at least one of the above-mentioned technical defects. In view of this, the present application provides a cross-chain bridge smart contract vulnerability detection method and related equipment to solve the technical defect that the prior art cannot well identify the vulnerabilities of the cross-chain bridge smart contract.
[0005] A cross-chain bridge smart contract vulnerability detection method, comprising:
[0006] Determine the target control flow set of smart contracts on both sides of the cross-chain bridge to be analyzed;
[0007] Identifying all access control constraints in the target control flow set;
[0008] Determining whether all access control constraints in the target control flow set are complete;
[0009] If there are incomplete access control constraints in the target control flow set, determining whether there are semantically inconsistent access control constraints in the incomplete access control constraints in the target control flow set;
[0010] If there are semantically inconsistent access control constraints in the incomplete access control constraints in the target control flow set, it is determined that the control flow corresponding to the incomplete and semantically inconsistent access control constraints in the target control flow set has a cross-chain bridge vulnerability.
[0011] Preferably, the method further comprises:
[0012] Analyze the reachable path from the contract entry point to the vulnerable function in the incomplete and semantically inconsistent access control constraints in the target control flow set to determine the reachability of the control flow corresponding to the incomplete and semantically inconsistent access control constraints in the target control flow set;
[0013] Analyze the state variables affected by the vulnerability function of the incomplete and semantically inconsistent access control constraints in the target control flow set to determine the destructiveness of the control flow corresponding to the incomplete and semantically inconsistent access control constraints in the target control flow set.
[0014] Preferably, the determining whether all access control constraints in the target control flow set are complete includes:
[0015] Modeling all access control constraints of the target control flow set to obtain a model corresponding to all access control constraints of the target control flow set;
[0016] According to the model corresponding to all the access control constraints of the target control flow set, all the security check requirements corresponding to all the access control constraints of the target control flow set are standardized to obtain a standardized security check set, wherein the standardized security check set includes all the security check requirements of all the access control constraints of the target control flow set;
[0017] Access resources corresponding to all access control constraints of the target control flow set;
[0018] Associating the resources corresponding to all the access control constraints of the target control flow set with the various security check requirements of the standard security check set to obtain the corresponding relationship between the resources corresponding to all the access constraints of the target control flow set and the various security check requirements;
[0019] Based on the correspondence between resources corresponding to all access constraints of the target control flow set and various security check requirements, identifying whether there is an access control constraint in the target control flow set that does not meet the security check requirements corresponding to each access control constraint;
[0020] If there are access control constraints in the target control flow set that do not meet the security check requirements corresponding to each access control constraint, then the access control constraints in the target control flow set that do not meet the security check requirements corresponding to each access control constraint are determined to be incomplete access control constraints.
[0021] Preferably, the determining whether there are semantically inconsistent access control constraints in the incomplete access control constraints in the target control flow set includes:
[0022] Constructing a cross-chain control flow graph corresponding to the incomplete access control constraints in the target control flow set;
[0023] Based on the cross-chain control flow graph corresponding to the incomplete access control constraints in the target control flow set, data analysis is performed on the cross-chain control flow graph corresponding to the incomplete access control constraints in the target control flow set, and a cross-chain data flow graph corresponding to the cross-chain control flow graph corresponding to the incomplete access control constraints in the target control flow set is formed;
[0024] Performing semantic analysis on the cross-chain control flow graph and its corresponding cross-chain data flow graph corresponding to the incomplete access control constraints in the target control flow set to obtain semantic analysis results of the incomplete access control constraints in the target control flow set;
[0025] According to the semantic analysis result of the incomplete access control constraints in the target control flow set, it is determined whether there are semantically inconsistent access control constraints in the incomplete access control constraints in the target control flow set.
[0026] Preferably, the step of associating resources corresponding to all access control constraints of the target control flow set with each security check requirement of the standard security check set includes:
[0027] Calculate all reachable paths for each resource corresponding to all access control constraints of the target control flow set;
[0028] Find out the security checks of all access control constraints on each reachable path of each resource corresponding to all access control constraints of the target control flow set;
[0029] All reachable paths of each resource corresponding to all access control constraints of the target control flow set are associated with security check requirements of all access control constraints on each reachable path of each resource corresponding to all access control constraints of the target control flow set.
[0030] Preferably, the rule for determining whether all access control constraints in the target control flow set are complete includes:
[0031] If it is determined that there is an access control constraint with a missing security check requirement among all the access control constraints in the target control flow set, then the access control constraint with a missing security check requirement among all the access control constraints in the target control flow set is determined to be an incomplete access control constraint;
[0032] and / or,
[0033] If it is determined that there is an access control constraint with an access control violation path among all the access control paths in all the access control constraints in the target control flow set, then the access control constraint corresponding to the access control violation path in the target control flow is determined to be an incomplete access control constraint;
[0034] The rule for determining whether there are semantically inconsistent access control constraints in the incomplete access control constraints in the target control flow set includes:
[0035] If it is determined that among the incomplete access control constraints in the target control flow set, there are access control constraints whose semantic granularity does not satisfy the reachable path requirements corresponding to each access control constraint, then it is determined that among the incomplete access control constraints in the target control flow set, there are access control constraints whose semantic granularity does not satisfy the reachable path requirements corresponding to the access control constraints are incomplete and semantically inconsistent access control constraints;
[0036] and / or,
[0037] If it is determined that the incomplete access control constraints in the target control flow set include access control constraints whose semantic integrity does not satisfy the data dependencies of the state variables corresponding to the access control constraints, then it is determined that the incomplete access control constraints in the target control flow set include access control constraints whose semantic integrity does not satisfy the data dependencies of the state variables corresponding to the access control constraints are incomplete and semantically inconsistent access control constraints.
[0038] Preferably, constructing a cross-chain control flow graph corresponding to the incomplete access control constraints in the target control flow set includes:
[0039] Determine the basic block nodes, the relay nodes for cross-chain data transmission, and the client nodes of the cross-chain bridge client corresponding to the incomplete access control constraints in the target control flow set;
[0040] Determine the control edge, monitoring edge and notification edge corresponding to the incomplete access control constraint in the target control flow set, wherein the monitoring edge corresponding to the incomplete access control constraint in the target control flow set corresponds to the information flow of the repeater and the client monitoring event message corresponding to the incomplete access control constraint in the target control flow set, and the notification edge corresponding to the incomplete access control constraint in the target control flow set corresponds to the information flow of the repeater corresponding to the incomplete access control constraint in the target control flow set notifying the contract execution event on the target chain;
[0041] The basic block nodes corresponding to the incomplete access control constraints in the target control flow set, the repeater nodes for cross-chain data transmission, and the client nodes of the cross-chain bridge client are respectively established with the control edges, listening edges, and notification edges corresponding to the incomplete access control constraints in the target control flow set, and a cross-chain control flow graph corresponding to the incomplete access control constraints in the target control flow set is obtained.
[0042] A cross-chain bridge smart contract vulnerability detection device, comprising:
[0043] A control flow determination unit, used to determine the target control flow set of the smart contracts on both sides of the cross-chain bridge to be analyzed;
[0044] An identification unit, used to identify all access control constraints in the target control flow set;
[0045] A first judging unit, configured to judge whether all access control constraints in the target control flow set are complete;
[0046] a second judgment unit, configured to judge whether there are semantically inconsistent access control constraints in the incomplete access control constraints in the target control flow set when the execution result of the first judgment unit is to determine that there are incomplete access control constraints in the target control flow set;
[0047] A vulnerability determination unit is used to determine that a cross-chain bridge vulnerability exists in the control flow corresponding to the incomplete and semantically inconsistent access control constraints in the target control flow set when the execution result of the second judgment unit is to determine that there are semantically inconsistent access control constraints in the incomplete access control constraints in the target control flow set.
[0048] A cross-chain bridge smart contract vulnerability detection device, comprising: one or more processors, and a memory;
[0049] The memory stores computer-readable instructions, and when the computer-readable instructions are executed by the one or more processors, the steps of the cross-chain bridge smart contract vulnerability detection method as described in any of the above introductions are implemented.
[0050] A readable storage medium: the readable storage medium stores computer-readable instructions, and when the computer-readable instructions are executed by one or more processors, the one or more processors implement the steps of the cross-chain bridge smart contract vulnerability detection method as described in any of the above introductions.
[0051] It can be seen from the technical solutions introduced above that in the actual application process, different cross-chain bridges have different cross-chain semantics. Identifying the cross-chain semantics of different cross-chain bridges is helpful to analyze the vulnerabilities of the smart contracts on both sides of the cross-chain bridge. Therefore, when it is necessary to determine whether the smart contracts on both sides of the cross-chain bridge to be analyzed have cross-chain bridge vulnerabilities, the method provided in the embodiment of the present application can determine the target control flow set of the smart contracts on both sides of the cross-chain bridge to be analyzed; so that it can be determined whether the smart contracts on both sides of the cross-chain bridge to be analyzed have cross-chain bridge vulnerabilities by analyzing the target control flows of the smart contracts on both sides of the cross-chain bridge to be analyzed, wherein the target control flows of the smart contracts on both sides of the cross-chain bridge have at least one access control constraint. Therefore, after determining the target control flow set of the smart contracts on both sides of the cross-chain bridge to be analyzed, all access control constraints in the target control flow set can be further identified; in the actual application process, it is generally believed that if there are incomplete and semantically inconsistent access control constraints in the control flow of the smart contract, it is considered that the smart contract has a cross-chain bridge vulnerability. Therefore, after identifying all the access control constraints of the target control flow set of the smart contracts on both sides of the cross-chain bridge to be analyzed, it is possible to further determine whether all the access control constraints in the target control flow set are complete; if there are incomplete access control constraints in the target control flow set, it is possible to further determine whether there are semantically inconsistent access control constraints in the incomplete access control constraints in the target control flow set; if there are semantically inconsistent access control constraints in the incomplete access control constraints in the target control flow set, it is possible to determine that the control flow corresponding to the incomplete and semantically inconsistent access control constraints in the target control flow set has a cross-chain bridge vulnerability. From the above introduction, it can be seen that when it is necessary to detect vulnerabilities in the smart contract corresponding to the cross-chain bridge, the method provided in the embodiment of the present application can summarize the cross-chain semantics of different cross-chain bridges, realize the extraction of the security control flow information of the cross-chain bridge, and can identify the contextual information in the cross-chain data transmission process, and use this to determine whether there is a cross-chain bridge vulnerability in the smart contract of the cross-chain bridge. The method provided in the embodiment of the present application can detect a wider range of inconsistent access control vulnerabilities and inconsistent semantic vulnerabilities, which can effectively improve the accuracy and recall rate of vulnerability detection for cross-chain bridge smart contracts. BRIEF DESCRIPTION OF THE DRAWINGS
[0052] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.
[0053] Figure 1 A flowchart of a method for implementing smart contract vulnerability detection provided in an embodiment of the present application;
[0054] Figure 2 A schematic diagram of a working framework of a cross-chain bridge provided in an embodiment of the present application;
[0055] Figure 3 A schematic diagram of the structure of a cross-chain bridge smart contract vulnerability detection device as an example of an embodiment of the present application;
[0056] Figure 4 This is a hardware structure block diagram of a cross-chain bridge smart contract vulnerability detection device disclosed in an embodiment of the present application. DETAILED DESCRIPTION
[0057] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0058] In view of the fact that most of the current cross-chain bridge smart contract vulnerability detection solutions are difficult to adapt to complex and changeable business needs, for this reason, this application studies a cross-chain bridge smart contract vulnerability detection solution. When it is necessary to detect vulnerabilities in the smart contract corresponding to the cross-chain bridge, the method provided in the embodiment of this application can summarize the cross-chain semantics of different cross-chain bridges, realize the extraction of the security control flow information of the cross-chain bridge, and can identify the context information in the cross-chain data transmission process, and use it to determine whether the smart contract of the cross-chain bridge has a cross-chain bridge vulnerability. The method provided by the embodiment of this application can detect a wider range of inconsistent access control vulnerabilities and inconsistent semantics vulnerabilities, which can effectively improve the accuracy and recall rate of vulnerability detection for cross-chain bridge smart contracts.
[0059] The method provided in the embodiments of the present application can be used in many general or special computing device environments or configurations, such as personal computers, server computers, handheld devices or portable devices, tablet devices, multi-processor devices, and distributed computing environments including any of the above devices or equipment.
[0060] The embodiment of the present application provides a cross-chain bridge smart contract vulnerability detection method, which can be applied to various blockchain systems and can also be applied to various computer terminals or smart terminals. The execution subject can be a processor or server of the computer terminal or smart terminal.
[0061] Combine the following Figure 1 , introduces the process of the cross-chain bridge smart contract vulnerability detection method given in the embodiment of the present application, such as Figure 1 As shown, the process can include the following steps:
[0062] Step S101, determine the target control flow set of the smart contracts on both sides of the cross-chain bridge to be analyzed.
[0063] Specifically, in actual application, smart contracts are a special program running on the blockchain. Smart contracts can automatically execute contract terms without human intervention. Smart contracts are written and executed using programming languages, such as Solidity, which is the smart contract programming language on the Ethereum blockchain. Smart contracts can be used in various application scenarios, such as financial transactions, supply chain management, digital asset management, etc.
[0064] Smart contracts can support various functions to realize new business models. For example, smart contracts can realize decentralized finance, decentralized games, and cross-chain bridge transactions.
[0065] A cross-chain bridge is a technology that allows for secure and efficient asset transfers and information exchange between different blockchains. It can transfer assets from one blockchain to another, thereby enabling cross-chain circulation of assets. There are many ways to implement a cross-chain bridge, such as hash locking, notary mechanism, side chain, etc.
[0066] For example, Figure 2 The following is a schematic diagram of the working framework of a cross-chain bridge. Figure 2 As shown, a typical cross-chain bridge can be divided into three parts: source chain, cross-chain relay, and target chain.
[0067] Among them, the cross-chain bridge deploys smart contracts on the source chain and the target chain. The repeater is designed to support information exchange between the source chain and the target chain. Through the cross-chain bridge, users can deposit assets on the source chain and withdraw assets on the target chain.
[0068] For example, Figure 2 As shown, the user needs to exchange asset A on the source chain for asset B on the target chain. Specifically, the process of exchanging asset A on the source chain for asset B on the target chain includes the following three steps:
[0069] (1) Deposit assets on the source chain:
[0070] When receiving a user's cross-chain asset request, the source chain's router contract R s Will call contract T s Lock asset A, then the router contract R of the source chain s Will send deposit event I d The message is used as a confirmation message of asset locking, where the deposit event can contain detailed deposit information;
[0071] For example, the deposit information included in the deposit event may include asset type and amount.
[0072] Finally, the user's assets will be transferred to the router contract R s .
[0073] (2) Cross-chain communication through off-chain cross-chain relays:
[0074] Once the source chain sends a deposit event I d The cross-chain relay verifies whether the deposit on the source chain is valid. If the cross-chain relay verifies successfully, the cross-chain relay sends a message to the router contract R of the target chain. d Send informed event I p information.
[0075] (3) Asset extraction on the target chain:
[0076] Once the cross-chain relay sends the informed event I p Send to the target chain, router contract R d It will verify I p The authenticity of the router contract R d After verification is completed, the router contract R d Then a withdrawal event I will be sent w message and call the token contract T d Send asset B to the address on the target chain specified by the user.
[0077] In reality, based on the above cross-chain bridge working framework, the tool Xscope, which is used to mine cross-chain smart contract vulnerabilities, is generally used to detect vulnerabilities. Xscope is a dynamic analysis framework that needs to analyze the code to detect vulnerabilities during the code execution process. Xscope analyzes the current cross-chain bridge security events and classifies the cross-chain bridge contract vulnerabilities into three categories, namely, the unrestricted triggering of deposit events on the source chain, the inconsistency of cross-chain data between the source chain and the target chain, and the unauthorized withdrawal on the target chain. Therefore, Xscope constructs corresponding security models for these three vulnerabilities, taking the hash value of the cross-chain transaction as input, and the output result is one of the above three types of vulnerabilities or no vulnerability.
[0078] Existing vulnerability detection technology solutions rely on cross-chain transaction data, and these cross-chain transactions have already been completed. That is, when a vulnerability is discovered through completed transaction data, the vulnerability has already been exploited by the attacker and the attack has been completed. In other words, existing technical solutions cannot detect vulnerabilities and recover losses before an attack occurs, and existing technical solutions can only detect a few specific cross-chain vulnerabilities, and the vulnerability identification range is small. Most existing technical solutions support vulnerability detection at the smart contract source code level, lack support for bytecode level vulnerability detection, and are not comprehensive enough for cross-chain vulnerability detection, which leads to low detection accuracy and recall rates.
[0079] In actual application, different cross-chain bridges have different cross-chain semantics. Identifying the cross-chain semantics of different cross-chain bridges helps to analyze the vulnerabilities of the smart contracts on both sides of the cross-chain bridge. Therefore, when it is necessary to determine whether the smart contracts on both sides of the cross-chain bridge to be analyzed have cross-chain bridge vulnerabilities, based on the above situation, the method provided in the embodiment of the present application can determine the target control flow set of the smart contracts on both sides of the cross-chain bridge to be analyzed, so that it can be determined whether the smart contracts on both sides of the cross-chain bridge to be analyzed have cross-chain bridge vulnerabilities by analyzing the target control flows of the smart contracts on both sides of the cross-chain bridge to be analyzed.
[0080] Among them, there is at least one control flow in the target control flow set of the smart contracts on both sides of the cross-chain bridge; each control flow has at least one access control constraint.
[0081] For example, the method provided in the embodiment of the present application can restore the control flow of the smart contracts on both sides of the cross-chain bridge to be analyzed through a static analysis framework SmartAxe for fine-grained detection of cross-chain bridge smart contract vulnerabilities, so that the bytecode of the smart contracts on both sides of the cross-chain bridge can be used as input for analysis to determine whether there are cross-chain vulnerabilities in the smart contracts on both sides of the cross-chain bridge to be analyzed.
[0082] Step S102: identifying all access control constraints in the target control flow set.
[0083] Specifically, from the above introduction, it can be seen that the method provided in the embodiment of the present application can determine the control flow of the smart contracts on both sides of the cross-chain bridge to be analyzed.
[0084] In actual applications, due to the inherent openness of blockchain, it is impossible to guarantee the complete privacy of contracts. It is impossible to prevent others from reading the state of smart contracts because everyone can see all the contents. However, by defining private states, it is possible to prevent the contract state from being read by other contracts.
[0085] Generally, some access rules need to be put in place to restrict access to a contract. Typically, method access is granted to specific entities, such as contract administrators. Other restrictions are at a certain point in time or if the accessor is willing to pay for access. All of these restrictions, and more, can be used to protect the security of the contract using the access restriction pattern.
[0086] Therefore, in general, depending on the usage scenario, the control flow corresponding to the smart contract generally includes at least one access control constraint.
[0087] For example, each control flow of the target control flow set to be analyzed may include several access control constraints.
[0088] Step S103, determining whether all access control constraints in the target control flow set are complete.
[0089] Specifically, it can be seen from the above introduction that the method provided in the embodiment of the present application can determine all access control constraints of the target control flow set to be analyzed.
[0090] In actual application, if there are incomplete access control constraints in the access control constraints corresponding to the control flow, it means that there may be loopholes in the control flow.
[0091] Therefore, in order to determine whether there is a vulnerability in the target control flow set, after determining all the access control constraints in the target control flow set, it can be further determined whether there is an incomplete access control constraint in all the access control constraints in the target control flow set.
[0092] The rules for determining whether all access control constraints in the target control flow set are complete may include the following:
[0093] It can be determined whether there are any access control constraints with legacy security check requirements among all the access control constraints in the target control force set. If it is determined that there are any access control constraints with missing security check requirements among all the access control constraints in the target control flow set, then it can be determined that the access control constraints with missing security check requirements among all the access control constraints in the target control flow set are incomplete access control constraints.
[0094] and / or,
[0095] It can be determined whether there is an access control constraint with an access control violation path among all the access control constraints in the target control flow set. If it is determined that there is an access control constraint with an access control violation path among all the access control paths in the target control flow set, it can be determined that the access control constraint corresponding to the access control violation path in the target control flow is an incomplete access control constraint.
[0096] Among them, in the actual application process, by comparing the extracted security check model corresponding to the target control flow set, all access control constraints of the target control flow set can be checked to see if there are access control missing vulnerabilities. If it is determined that a certain category of security check is missing, it can be determined that the access control corresponding to this type is incomplete.
[0097] Among them, the commonly extracted security check models can be shown in Table 1 below
[0098] Table 1 Security check model of cross-chain bridge contract
[0099]
[0100] In Table 1, the first type of security check model is asset deposit and lock:
[0101] The first type of security check model can include deposit success check and check verification of user passed parameters (i.e. the first two items in the second column). The specific analysis is as follows:
[0102] The deposit success check is used to confirm whether the user's deposit has been transferred to the cross-chain bridge to prevent "fake deposit" events. The verification check of the parameters passed by the user is to prevent the user from passing malicious parameters and maliciously modifying the contract status to create a "fake deposit" event. As shown in the first three items of the third column, the security check of whether the deposit is successful can take many forms, such as comparing the balance of the cross-chain bridge before and after the deposit, comparing the user's balance with the deposit amount, and comparing the liquidity of the cross-chain bridge with the deposit threshold. Although these three security checks are different in syntactic form, they are semantically equivalent in confirming whether the deposit is successful, so there is a disjunctive relationship between them. In addition, in the fourth and fifth items of the third column, checking the parameters of the public function and checking the parameters of the message call can both implement verification checks on the parameters passed by the user. Similarly, these two types of security checks are semantically equivalent, and a disjunctive relationship is adopted between them.
[0103] The second type of security check model in Table 1 is a cross-chain relay:
[0104] The second type of security check model mainly checks the correctness of the cross-chain relay, as shown in the third entry in the second column.
[0105] The correctness check of the cross-chain repeater is used to prevent unexpected errors in cross-chain data transmission. As shown in the sixth and seventh items in the third column of the table, the check of the second type of check model can be achieved in the following ways:
[0106] 1) Check the asset ID and blockchain ID supported by the cross-chain bridge;
[0107] 2) Check the address of the external call (e.g., an address of 0 will cause the external call to fail). Obviously, these two types of checks are not semantically equivalent, so in the actual analysis process, a conjunction relationship is adopted between them.
[0108] The third category of security check models in Table 1 is asset authorization and withdrawal:
[0109] The Category 3 security check model includes verification checks on asset authorization, withdrawal duplication checks, and withdrawal correctness checks (as shown in the fourth, fifth, and sixth items in the second column).
[0110] Specifically, the asset authorization verification check is used to ensure that the cross-chain transaction has been verified by the relayer signature. Therefore, this verification check is achieved by checking the correctness and timeliness of the signature or signer (items 8 and 9 in the third column of the table). Since there is an inequality between the two, the conjunction relationship is generally used to measure them in practical applications.
[0111] Withdrawal duplication checks are used to prevent users from repeatedly withdrawing funds from the cross-chain bridge. To this end, such checks are implemented by checking a specific list used to record withdrawal events (the tenth item in the third column of the table). In addition, withdrawal correctness checks are used to ensure that the transfer destination is valid and correct. Such security checks can be implemented by checking the asset receiving address (the eleventh item in the third column of the table).
[0112] By comparing the control flow information of the smart contract with the various security check models in Table 1 above, all security check requirements for cross-chain contract access control can be extracted.
[0113] In actual application, a violation path refers to an access control path that allows users without sufficient permissions to access sensitive resources. For the entry points of cross-chain contracts, their sub-control flow graphs can be compared in pairs to identify potential paths that can access the same sensitive resources but perform different security checks.
[0114] For example, it can be determined whether there is a potential path in which one of the sub-control flow graphs has a security check and the other sub-control flow graph does not have a security check.
[0115] In actual application, the method provided in the embodiment of the present application can output all functions on the illegal path, because all functions on these illegal paths are vulnerable to attacks.
[0116] If there are incomplete access control constraints in the target control flow set, it means that there may be a vulnerability in the target control flow set. In order to determine whether the vulnerability in the target control flow set is a cross-chain bridge vulnerability, step S104 can be executed.
[0117] Step S104: determine whether there are semantically inconsistent access control constraints in the incomplete access control constraints in the target control flow set.
[0118] Specifically, in actual application, cross-chain bridge vulnerabilities generally occur in incomplete access control constraints and semantically inconsistent access control constraints. From the above introduction, it can be seen that the method provided by the embodiment of the present application can determine whether there are incomplete access control constraints in the target control flow set.
[0119] If there are incomplete access control constraints in the target control flow set, it means that there may be vulnerabilities in the target control flow set. In order to determine whether the vulnerability in the target control flow set is a cross-chain bridge vulnerability, it is possible to further determine whether there are semantically inconsistent access control constraints in the incomplete access control constraints in the target control flow set.
[0120] The rules for determining whether there are semantically inconsistent access control constraints in the incomplete access control constraints in the target control flow set may include the following:
[0121] It can be determined whether there are access control constraints in the target control flow set whose semantic granularity does not satisfy the requirements of the reachable paths corresponding to the various access control constraints in the incomplete access control constraints. If it is determined that there are access control constraints in the target control flow set whose semantic granularity does not satisfy the requirements of the reachable paths corresponding to the various access control constraints, then it can be determined that the access control constraints in the target control flow set whose semantic granularity does not satisfy the requirements of the reachable paths corresponding to the access control constraints are incomplete and semantically inconsistent access control constraints.
[0122] Among them, in the actual application process, when the semantic granularity of the deposit event is not enough, it may cause the smart contract of the target chain to be unable to distinguish different types of deposits, resulting in different types of deposits but may enter the same withdrawal logic. Therefore, in the actual application process, by comparing cross-chain paths, potential paths with the same withdrawal logic on the target chain but different deposit logic on the source chain can be identified to identify possible cross-chain bridge vulnerabilities.
[0123] and / or,
[0124] It can be done by judging whether there are access control constraints in the target control flow set whose semantic integrity does not satisfy the data dependencies of the state variables corresponding to each access control constraint. If it is determined that there are access control constraints in the target control flow set whose semantic integrity does not satisfy the data dependencies of the state variables corresponding to each access control constraint, then it is determined that among the incomplete access control constraints in the target control flow set, the access control constraints whose semantic integrity does not satisfy the data dependencies of the state variables corresponding to the access control constraints are incomplete and semantically inconsistent access control constraints.
[0125] For example, in actual applications, the amount or type of withdrawal depends on the withdrawal function itself, not the deposit on the source chain. Control flow vulnerabilities can be detected by identifying whether the withdrawal state variable has a data dependency relationship with the deposit state variable. If it is determined that there is a lack of data dependency between the withdrawal state variable and the deposit state variable, the semantics of the withdrawal event is considered incomplete.
[0126] If any of the above identification rules is met, it can be considered that the contract code has a semantic inconsistency vulnerability.
[0127] Therefore, if there are semantically inconsistent access control constraints in the incomplete access control constraints in the target control flow set, it means that there is a cross-chain bridge vulnerability in the target control flow set, and step S105 can be executed.
[0128] Step S105, determining that the control flow corresponding to the incomplete and semantically inconsistent access control constraints in the target control flow set has a cross-chain bridge vulnerability.
[0129] Specifically, in actual application, if there is a control flow corresponding to an access control constraint that is both complete and semantically inconsistent in the control flow of a smart contract, it means that the control flow may have a cross-chain bridge vulnerability.
[0130] From the above introduction, it can be seen that the method provided in the embodiment of the present application can determine whether there are incomplete and semantically inconsistent access control constraints in the target control flow set.
[0131] Therefore, if it is determined that there are control flows corresponding to incomplete and semantically inconsistent access control constraints in the target control flow set, it means that there are cross-chain bridge vulnerabilities in the control flows corresponding to incomplete and semantically inconsistent access control constraints in the target control flow set, then it can be determined that there are cross-chain bridge vulnerabilities in the control flows corresponding to incomplete and semantically inconsistent access control constraints in the target control flow set.
[0132] Step S106, analyzing the reachable path from the contract entry point to the vulnerable function in the incomplete and semantically inconsistent access control constraints in the target control flow set to determine the reachability of the control flow corresponding to the incomplete and semantically inconsistent access control constraints in the target control flow set.
[0133] Specifically, from the above introduction, it can be seen that the method provided in the embodiment of the present application can determine whether there is a control flow with a cross-chain bridge vulnerability in the target control flow set.
[0134] In actual application, after determining that a smart contract has a cross-chain bridge vulnerability, it is also necessary to analyze the smart contract with the cross-chain bridge vulnerability so that the specific information of the cross-chain bridge vulnerability can be analyzed.
[0135] For example, in actual application, determining the cross-chain bridge vulnerability of the control flow requires the following two conditions to be met:
[0136] Condition 1: You can try to find out whether the control flow with the cross-chain bridge vulnerability has an entry point for external calls, that is, you need to confirm whether the tainted data can be propagated from the entry point of the cross-chain bridge contract. For example, you can confirm whether the tainted data can be propagated from the public function of the cross-chain bridge contract, and further detect whether the tainted data can reach the cross-chain bridge vulnerability function.
[0137] Condition 2: You can try to find the state variables affected by the cross-chain bridge vulnerability. In actual application, after finding the entry trajectory that the external attacker can enter, you can further follow the attack trajectory of the external attacker to identify the state variables affected by the cross-chain bridge vulnerability. If the state variables affected by the cross-chain bridge vulnerability can be identified, it can be said that the cross-chain bridge vulnerability does exist.
[0138] Therefore, after determining that there is a cross-chain bridge vulnerability in the control flow in the target control flow set, the reachable path from the contract entry point to the vulnerable function of the incomplete and semantically inconsistent access control constraints in the target control flow set can be further analyzed to determine the reachability of the control flow corresponding to the incomplete and semantically inconsistent access control constraints in the target control flow set.
[0139] Step S107, analyzing the state variables affected by the vulnerable function of the incomplete and semantically inconsistent access control constraints in the target control flow set to determine the destructiveness of the control flow corresponding to the incomplete and semantically inconsistent access control constraints in the target control flow set.
[0140] Specifically, from the above introduction, it can be seen that the method provided in the embodiment of the present application can analyze the reachable path from the contract entry point to the vulnerable function of the incomplete and semantically inconsistent access control constraints in the target control flow set, so as to determine the reachability of the control flow corresponding to the incomplete and semantically inconsistent access control constraints in the target control flow set.
[0141] Since determining a cross-chain bridge vulnerability requires not only determining the entry of the external call of the vulnerability existing in the target control flow set, but also finding the state variables affected by the vulnerability, it is possible to determine that the vulnerability is a cross-chain bridge vulnerability. Therefore, in addition to analyzing the reachable path from the contract entry point to the vulnerable function of the incomplete and semantically inconsistent access control constraints in the target control flow set, the method provided in the embodiment of the present application can also analyze the state variables affected by the vulnerable function of the incomplete and semantically inconsistent access control constraints in the target control flow set, so as to determine the destructiveness of the control flow corresponding to the incomplete and semantically inconsistent access control constraints in the target control flow set.
[0142] For example, if in actual application, the entry of the external call of the vulnerability in the target control flow set can be determined and the state variables affected by the vulnerability can also be found, then the vulnerability can be located as a cross-chain bridge vulnerability and the attack path of the cross-chain bridge vulnerability can be determined, so as to reveal how the attacker exploits the cross-chain bridge vulnerability to attack.
[0143] It is worth noting that in actual application, the tainted data source can be divided into two types: parameters passed by the contract caller and parameters of public functions.
[0144] Generally speaking, the confluence of taint sources is usually composed of external calls or state variables of smart contracts, where the state variables of smart contracts may include cross-chain bridge vulnerabilities and client nodes.
[0145] In particular, Table 2 below lists some detailed information about the sources of tainted data and the sinks of tainted data.
[0146] Table 2. EVM instructions defined as taint sources and sinks
[0147]
[0148] It can be seen from the technical solutions introduced above that when it is necessary to detect vulnerabilities in the smart contract corresponding to the cross-chain bridge, the method provided in the embodiment of the present application can summarize the cross-chain semantics of different cross-chain bridges, realize the extraction of the security control flow information of the cross-chain bridge, and can identify the context information in the cross-chain data transmission process, and use this to determine whether the smart contract of the cross-chain bridge has a cross-chain bridge vulnerability. Further, the method provided in the embodiment of the present application can combine the detection results of the inconsistency of access control constraints and the inconsistency of semantics to accurately locate the vulnerability functions of the smart contracts on both sides of the cross-chain bridge, and the method provided in the embodiment of the present application can analyze the smart contract with only bytecode, and can perform cross-chain vulnerability detection at the bytecode level. Compared with other methods, it has better applicability. The method provided in the embodiment of the present application can detect a wider range of inconsistent access control vulnerabilities and inconsistent semantics vulnerabilities, which can effectively improve the accuracy and recall rate of vulnerability detection for cross-chain bridge smart contracts.
[0149] As can be seen from the above introduction, the method provided in the embodiment of the present application can determine whether all access control constraints in the target control flow set are complete. The following describes the process, which may include the following steps:
[0150] Step S201, modeling all access control constraints of the target control flow set to obtain a model corresponding to all access control constraints of the target control flow set.
[0151] Specifically, from the above introduction, we can see that in actual application, the workflow of the cross-chain bridge includes three steps:
[0152] 1) Asset deposit and lock;
[0153] 2) Cross-chain communication;
[0154] 3) Asset authorization and withdrawal.
[0155] In actual application, the security check of cross-chain contracts mainly checks user permissions based on these three steps.
[0156] However, in cross-chain bridge contracts, the implementation of security check requirements is actually more diverse. This is because different cross-chain bridges generally use different security functions related to cross-chain workflows to implement access control security checks. Therefore, in actual application, all different forms of access control check requirements must be identified, modeled, and standardized for comparison.
[0157] Although most security check requirements differ in syntactic form, the protection they provide is semantically equivalent.
[0158] Therefore, in actual application, security checks with different grammatical forms but providing the same protection type can be equated to the same category.
[0159] For example, some security check models shown in Table 1 above can divide the security check requirements of access control into three categories:
[0160] 1) Categories for asset deposit and lock-up;
[0161] 2) Categories for cross-chain relays;
[0162] 3) Categories for asset authorization and withdrawal (i.e. the first column of Table 1).
[0163] In the actual application process, in order to ensure the security and credibility of the blockchain system, all access control constraints of the target control flow set can be modeled to obtain a model corresponding to all access control constraints of the target control flow set.
[0164] By modeling the access control constraints corresponding to the control flow, we can better understand and manage the data flow and transaction process in the blockchain system, thereby preventing illegal access and tampering.
[0165] Specifically, access control constraint modeling in blockchain technology can achieve the following security guarantees:
[0166] 1. Identity authentication: By authenticating the user’s identity, it can be ensured that only authorized users can access data and perform transactions in the blockchain system.
[0167] 2. Permission management: By managing user permissions, users’ access and operations on data in the blockchain system can be restricted, thereby preventing illegal access and tampering.
[0168] 3. Transaction process management: By managing the transaction process, the legality and credibility of the transaction can be ensured, thereby preventing fraud and money laundering.
[0169] 4. Data privacy protection: By protecting data privacy, it can ensure that the user's personal privacy is not leaked, thereby improving the user's trust and sense of security.
[0170] In summary, it is very important to model the access control constraints corresponding to the control flow, which can effectively ensure the security and credibility of the blockchain system, and also help analyze whether the access control constraints corresponding to the target control flow set are complete.
[0171] Step S202, based on the model corresponding to all the access control constraints of the target control flow set, all the security check requirements corresponding to all the access control constraints of the target control flow set are standardized to obtain a standardized security check set.
[0172] Specifically, from the above introduction, it can be known that the method provided by the embodiment of the present application can determine the model corresponding to all access control constraints of the target control flow set. By analyzing the model corresponding to all access control constraints of the target control flow set, it can be understood whether all access control constraints of the target control flow set are complete. Therefore, after determining the model corresponding to all access control constraints of the target control flow set, it is possible to further standardize all security check requirements corresponding to all access control constraints of the target control flow set according to the model corresponding to all access control constraints of the target control flow set, and obtain a standardized security check set, so that the standardized format of all security check requirements corresponding to all access control constraints of the target control flow set can be determined.
[0173] The standard security check set may include all security check requirements of all access control constraints of the target control flow set.
[0174] Step S203: access resources corresponding to all access control constraints of the target control flow set.
[0175] Specifically, from the above introduction, it can be seen that the method provided in the embodiment of the present application can determine all access control constraints corresponding to the target control flow set. In actual application, after extracting the security inspection requirements of all access control constraints of the target control flow set, the method provided in the embodiment of the present application can identify the resources of all access control constraints in the target control flow set.
[0176] Therefore, after determining the security check requirements corresponding to all access control constraints of the target control flow set, we can further access the resources corresponding to all access control constraints of the target control flow set, so that we can associate the resources corresponding to all access control constraints of the target control flow set with the corresponding security check requirements through the probabilistic pattern reasoning method.
[0177] Step S204, associate the resources corresponding to all the access control constraints of the target control flow set with the various security check requirements of the standard security check set to obtain the corresponding relationship between the resources corresponding to all the access constraints of the target control flow set and the various security check requirements.
[0178] Specifically, from the above introduction, it can be seen that the method provided in the embodiment of the present application can determine the resources corresponding to all access constraints of the target control flow set and the security check requirements corresponding to all access constraints of the target control flow set.
[0179] In the actual application process, there is a corresponding relationship between the resources corresponding to all the access constraints of the target control flow set and the security check requirements corresponding to all the access constraints of the target control flow set. Therefore, after determining the resources and security check requirements corresponding to all the access constraints of the target control flow set, the resources corresponding to all the access control constraints of the target control flow set can be associated with each security check requirement of the standard security check set to obtain the corresponding relationship between the resources corresponding to all the access constraints of the target control flow set and each security check requirement.
[0180] In actual application, the following four types of resources can be considered based on access control constraints:
[0181] 1) f can be used to represent access fields; for example, f represents a statement for reading and writing state variables; for example, f can represent a statement for reading and writing global variables of a smart contract.
[0182] 2) Use m to represent internal methods. For example, m represents a statement that calls an internal method in a cross-chain bridge contract. For example, m can represent a statement that calls a private function in a cross-chain bridge contract.
[0183] 3) a is used to represent the application binary interface (ABI). For example, a refers to the interface for external calls in a contract; for example, a can represent the interface of an external public function in a smart contract;
[0184] 4) Use e to represent an event trigger statement. For example, e refers to an event trigger statement that records cross-chain data transmission. For example, e can represent the deposit record I mentioned above. d Event triggering statement.
[0185] Further,
[0186] Before associating the resources corresponding to all the access control constraints of the target control flow set with the security check requirements corresponding to all the access control constraints of the target control flow set, basic information may be collected first.
[0187] For example, given a cross-chain contract with resources R = {r1, r2, ..., r n}, for each resource r i , we can use the path-sensitive analysis method to calculate all the reachable paths P = {p1, p2, ..., p n}.
[0188] For every reachable path p i , we can find the reachable path p i The security check of all access control constraints on C = {c1,c2,...,c n}. Therefore, the reachable path p i Resources oni With safety check k The association between them can be expressed as Association = (c k ,p i ,c i ).
[0189] In practical applications, in order to improve accuracy and credibility, we can introduce prior probability to express Association = (c k ,p i ,c i ) confidence. In practical applications, the prior probability is a value between 0 and 1, representing the confidence of Association = (c k ,p i ,c i )’s level of trust.
[0190] The prior probability is determined by analyzing the properties of the access control constraints, such as by analyzing the control flow, data flow, and semantics between the resources corresponding to the access control constraints and the security check.
[0191] In the actual application process, the association patterns between the resources of access control constraints and security checks in some cross-chain contracts and their corresponding prior probabilities are summarized, as shown in Table 3.
[0192] Table 3 Prior probability statistics of the association between resources constrained by access control and security checks
[0193]
[0194] Step S205, based on the correspondence between resources corresponding to all access constraints of the target control flow set and various security check requirements, identify whether there is an access control constraint in the target control flow set that does not meet the security check requirements corresponding to each access control constraint.
[0195] Specifically, from the above introduction, it can be seen that the method provided in the embodiment of the present application can determine the correspondence between the resources corresponding to all the access constraints of the target control flow set and each security check requirement. The correspondence between the resources corresponding to all the access constraints of the target control flow set and each security check requirement can provide feedback on whether there are access control constraints in the target control flow set that do not meet the security check requirements corresponding to each access control constraint. Therefore, after determining the correspondence between the resources corresponding to all the access constraints of the target control flow set and each security check requirement, it can be further based on the correspondence between the resources corresponding to all the access constraints of the target control flow set and each security check requirement so as to identify whether there are access control constraints in the target control flow set that do not meet the security check requirements corresponding to each access control constraint.
[0196] If there are access control constraints in the target control flow set that do not meet the security check requirements corresponding to each access control constraint, step S206 may be executed.
[0197] Step S206: Determine that the access control constraints in the target control flow set that do not meet the security check requirements corresponding to each access control constraint are incomplete access control constraints.
[0198] Specifically, it can be seen from the above introduction that the method provided in the embodiment of the present application can identify whether there are access control constraints in the target control flow set that do not meet the security check requirements corresponding to each access control constraint based on the corresponding relationship between the resources corresponding to all access constraints of the target control flow set and each security check requirement. If there are access control constraints in the target control flow set that do not meet the security check requirements corresponding to each access control constraint, it means that there are incomplete access control constraints in the target control flow set. Therefore, if there are access control constraints in the target control flow set that do not meet the security check requirements corresponding to each access control constraint, it can be determined that the access control constraints in the target control flow set that do not meet the security check requirements corresponding to each access control constraint are incomplete access control constraints.
[0199] It can be seen from the technical solution introduced above that the method provided in the embodiment of the present application can determine that the access control constraints in the target control flow set that do not meet the security check requirements corresponding to each access control constraint are incomplete access control constraints by analyzing the resources and security check requirements corresponding to the access control constraints in the target control flow set, so as to identify whether there are vulnerabilities in the target control flow set.
[0200] From the above introduction, it can be known that the method provided in the embodiment of the present application can determine whether there are semantically inconsistent access control constraints in the incomplete access control constraints in the target control flow set. The process is described below, and the process may include the following steps:
[0201] Step S301, construct a cross-chain control flow graph corresponding to the incomplete access control constraints in the target control flow set.
[0202] Specifically, it can be seen from the above introduction that the method provided in the embodiment of the present application can target incomplete access control constraints in a control flow set.
[0203] Furthermore, in order to confirm whether the incomplete access control constraints in the target control flow set have semantically inconsistent access control constraints, a cross-chain control flow graph corresponding to the incomplete access control constraints in the target control flow set can be constructed based on the incomplete access control constraints in the target control flow set.
[0204] For example, the cross-chain control flow graph corresponding to the incomplete access control constraints in the target control flow set can be set to G C =(N c ,E c ,X e ).
[0205] In actual application, the nodes of the cross-chain control flow graph corresponding to the incomplete access control constraints in the target control flow set can be composed of three parts, namely, the basic block node representing the program operation, the repeater node representing the cross-chain data transmission, and the client node representing the cross-chain bridge client.
[0206] You can use N b represents a basic block node, N r Represents the repeater node, N l represents the client node. Therefore, there are N C = {N b ∪N r ∪N l ). The edges of the cross-chain control flow graph corresponding to the incomplete access control constraints in the target control flow set are represented by the control flow edges E f , monitor edge E e and notification side E i Among them, E e Represents the information flow of relayers and clients listening to event messages, i.e. relayers listening to messages of deposit events sent on the source chain or clients listening to messages of withdrawal events on the target chain. i Represents the information flow of the relay notifying the contract on the target chain to execute authorization and withdrawal.
[0207] Similarly, there is E C ={E f ∪E e ∪E i );X e is a label function that maps edges to one of three types.
[0208] Therefore, the specific steps of constructing a cross-chain control flow graph corresponding to the incomplete access control constraints in the target control flow set may include the following:
[0209] Step S11, determine the basic block nodes, the repeater nodes for cross-chain data transmission, and the client nodes of the cross-chain bridge client corresponding to the incomplete access control constraints in the target control flow set.
[0210] Step S12, determine the control edges, listening edges and notification edges corresponding to the incomplete access control constraints in the target control flow set, wherein the listening edges corresponding to the incomplete access control constraints in the target control flow set correspond to the information flow of the repeater and the client listening to event messages corresponding to the incomplete access control constraints in the target control flow set, and the notification edges corresponding to the incomplete access control constraints in the target control flow set correspond to the information flow of the repeater corresponding to the incomplete access control constraints in the target control flow set notifying the contract execution events on the target chain.
[0211] Step S13, establish corresponding relationships between the basic block nodes corresponding to the incomplete access control constraints in the target control flow set, the repeater nodes for cross-chain data transmission, and the client nodes of the cross-chain bridge client and the control edges, listening edges, and notification edges corresponding to the incomplete access control constraints in the target control flow set, and obtain the cross-chain control flow graph corresponding to the incomplete access control constraints in the target control flow set.
[0212] Step S302, based on the cross-chain control flow graph corresponding to the incomplete access control constraints in the target control flow set, perform data analysis on the cross-chain control flow graph corresponding to the incomplete access control constraints in the target control flow set, and form a cross-chain data flow graph corresponding to the cross-chain control flow graph corresponding to the incomplete access control constraints in the target control flow set.
[0213] Specifically, in actual application, the cross-chain control flow graph corresponding to the incomplete access control constraints in the target control flow set corresponds to the cross-chain data flow graph corresponding to the incomplete access control constraints in the target control flow set. Therefore, after determining the cross-chain control flow graph corresponding to the incomplete access control constraints in the target control flow set, it is possible to further perform data analysis on the cross-chain control flow graph corresponding to the incomplete access control constraints in the target control flow set based on the cross-chain control flow graph corresponding to the incomplete access control constraints in the target control flow set, and form a cross-chain data flow graph corresponding to the cross-chain control flow graph corresponding to the incomplete access control constraints in the target control flow set.
[0214] For example, after determining the cross-chain control flow graph corresponding to the incomplete access control constraints in the target control flow set, the cross-chain data flow graph corresponding to the incomplete access control constraints in the target control flow set can be constructed by performing data flow analysis on the cross-chain control flow graph corresponding to the incomplete access control constraints in the target control flow set.
[0215] From the above introduction, we can see that the cross-chain control flow graph corresponding to the incomplete access control constraints in the target control flow set is represented as G C =(N c ,E c ,Xe ); then the cross-chain data flow graph corresponding to the incomplete access control constraints in the target control flow set can be expressed as G d =(N d ,E d ). Among them, N d Indicates different program operations of cross-chain contracts, E d Represents data dependencies between program operations.
[0216] In actual application, in order to construct a cross-chain control flow graph and a cross-chain data flow graph corresponding to the incomplete access control constraints in the target control flow set, the method provided in the embodiment of the present application constructs a cross-chain data flow graph corresponding to the incomplete access control constraints in the target control flow set by adding listening edges and notification edges in the single-chain control flow graph.
[0217] For example, listening edges and notification edges can be added to the control flow graph of the source chain or the control flow graph of the target chain corresponding to the incomplete access control constraints in the target control flow set to construct a data flow graph of the source chain or the data flow graph of the target chain corresponding to the incomplete access control constraints in the target control flow set.
[0218] The specific implementation method can be as follows:
[0219] 1. Construct a cross-chain control flow graph corresponding to the incomplete access control constraints in the target control flow set:
[0220] 1) When adding a listening edge, in order to indicate that the repeater listens to the message of sending a deposit event on the source chain, the message sending statements of the deposit and lock events can be searched on the source chain control flow graph as the starting point of the listening edge, and the repeater node can be used as the end point of the listening edge, and they are connected with a directed edge. Similarly, in order to indicate that the client listens to the message of sending a withdrawal event on the target chain, another listening edge is connected. For such an edge, the starting point is the message sending statement of the authorization and withdrawal events on the target chain control flow graph, and the end point is the client node.
[0221] 2) When adding a notification edge, in order to indicate that the repeater notifies the contract on the target chain to authorize and withdraw funds, the repeater node can be used as the starting point, the authorization and withdrawal statements as the end points, and they can be connected together with directed edges.
[0222] 2. The cross-chain data flow graph corresponding to the incomplete access control constraints in the target control flow set:
[0223] A cross-chain data flow graph corresponding to the incomplete access control constraints in the target control flow set is constructed through a dedicated data flow analysis method. Similar to traditional data flow analysis, this method also performs forward data flow analysis on the control flow edges. Unlike traditional data flow analysis, for the listening edge, only the parameters of the event can be propagated forward through the listening edge, because only these parameters are recorded in the cross-chain data transmitted to the relay. For the notification edge, only the parameters of the authorization and withdrawal method calls can be propagated forward through the notification edge.
[0224] Step S303, perform semantic analysis on the cross-chain control flow graph and its corresponding cross-chain data flow graph corresponding to the incomplete access control constraints in the target control flow set to obtain the semantic analysis results of the incomplete access control constraints in the target control flow set.
[0225] Specifically, from the above introduction, it can be seen that the method provided by the embodiment of the present application can determine the cross-chain control flow graph and its corresponding cross-chain data flow graph corresponding to the incomplete access control constraints in the target control flow set. Whether the semantics of the cross-chain control flow graph and its corresponding cross-chain data flow graph corresponding to the incomplete access control constraints in the target control flow set are consistent provides feedback on whether the semantics of the incomplete access control constraints in the target control flow set are consistent.
[0226] Therefore, after determining the cross-chain control flow graph and its corresponding cross-chain data flow graph corresponding to the incomplete access control constraints in the target control flow set, semantic analysis can be performed on the cross-chain control flow graph and its corresponding cross-chain data flow graph corresponding to the incomplete access control constraints in the target control flow set to obtain the semantic analysis results of the incomplete access control constraints in the target control flow set.
[0227] Step S304: judging whether there are semantically inconsistent access control constraints in the incomplete access control constraints in the target control flow set according to the semantic analysis results of the incomplete access control constraints in the target control flow set.
[0228] Specifically, from the above introduction, it can be seen that the method provided by the embodiment of the present application can determine the semantic analysis results of the incomplete access control constraints in the target control flow set. In the actual application process, the semantic analysis results of the incomplete access control constraints in the target control flow set provide feedback on whether the semantics of the incomplete access control constraints in the target control flow set are consistent. Therefore, after determining the semantic analysis results of the incomplete access control constraints in the target control flow set, it can be determined whether there are semantically inconsistent access control constraints in the incomplete access control constraints in the target control flow set based on the semantic analysis results of the incomplete access control constraints in the target control flow set.
[0229] It can be seen from the technical solution introduced above that the method provided in the embodiment of the present application can determine the semantic analysis results of the incomplete access control constraints in the target control flow set, and based on the semantic analysis results of the incomplete access control constraints in the target control flow set, judge whether there are semantically inconsistent access control constraints in the incomplete access control constraints in the target control flow set, so as to determine whether there is a cross-chain bridge vulnerability in the target control flow set.
[0230] As can be seen from the above introduction, the method provided in the embodiment of the present application can associate the resources corresponding to all the access control constraints of the target control flow set with the various security check requirements of the standard security check set. The process is introduced below, and the process may include the following steps:
[0231] Step S401, calculating all reachable paths of each resource corresponding to all access control constraints of the target control flow set.
[0232] Specifically, from the above introduction, it can be seen that there is a corresponding relationship between the resources corresponding to all the access control constraints of the target control flow set and the various security check requirements of the standard security check set. In order to associate the resources corresponding to all the access control constraints of the target control flow set with the various security check requirements of the standard security check set, all reachable paths of each resource corresponding to all the access control constraints of the target control flow set can be calculated, so that the security checks of all access control constraints on each reachable path of each resource corresponding to all the access control constraints of the target control flow set can be found according to all the reachable paths of each resource corresponding to all the access control constraints of the target control flow set.
[0233] Step S402, finding out the security checks of all access control constraints on each reachable path of each resource corresponding to all access control constraints of the target control flow set.
[0234] Specifically, from the above introduction, it can be known that the method provided by the embodiment of the present application can calculate all reachable paths for each resource corresponding to all access control constraints of the target control flow set, wherein all reachable paths for each resource corresponding to all access control constraints of the target control flow set can be used to understand the security check of all access control constraints on each reachable path for each resource corresponding to all access control constraints of the target control flow set. Therefore, after determining each reachable path for each resource corresponding to all access control constraints of the target control flow set, the security check of all access control constraints on each reachable path for each resource corresponding to all access control constraints of the target control flow set can be further performed.
[0235] Step S403, associating all reachable paths of each resource corresponding to all access control constraints of the target control flow set with the security check requirements of all access control constraints on each reachable path of each resource corresponding to all access control constraints of the target control flow set.
[0236] Specifically, from the above introduction, it can be seen that the method provided by the embodiment of the present application can determine all reachable paths of each resource corresponding to all access control constraints of the target control flow set and the security checks of all access control constraints on each reachable path. Furthermore, all reachable paths of each resource corresponding to all access control constraints of the target control flow set can be associated with the security check requirements of all access control constraints on each reachable path of each resource corresponding to all access control constraints of the target control flow set, so as to obtain the corresponding relationship between each resource corresponding to all access control constraints of the target control flow set and each security check requirement.
[0237] From the technical solution introduced above, it can be seen that the method provided in the embodiment of the present application can associate the resources corresponding to all the access control constraints of the target control flow set with the various security check requirements of the standard security check set, so as to obtain the correspondence between each resource corresponding to all the access control constraints of the target control flow set and each security check requirement, so as to identify the access control inconsistency vulnerabilities of a wider range of access control constraints.
[0238] The cross-chain bridge smart contract vulnerability detection device provided in an embodiment of the present application is described below. The cross-chain bridge smart contract vulnerability detection device described below and the cross-chain bridge smart contract vulnerability detection method described above can be referenced to each other.
[0239] See also Figure 3 , Figure 3 This is a schematic diagram of the structure of a cross-chain bridge smart contract vulnerability detection device disclosed in an embodiment of the present application.
[0240] like Figure 3 As shown, the cross-chain bridge smart contract vulnerability detection device may include:
[0241] A control flow determination unit 101, used to determine a target control flow set of smart contracts on both sides of the cross-chain bridge to be analyzed;
[0242] An identification unit 102, configured to identify all access control constraints in the target control flow set;
[0243] A first judging unit 103, configured to judge whether all access control constraints in the target control flow set are complete;
[0244] A second judgment unit 104 is used to judge whether there are semantically inconsistent access control constraints in the incomplete access control constraints in the target control flow set when the execution result of the first judgment unit is to determine that there are incomplete access control constraints in the target control flow set;
[0245] The vulnerability determination unit 105 is used to determine that there is a cross-chain bridge vulnerability in the control flow corresponding to the incomplete and semantically inconsistent access control constraints in the target control flow set when the execution result of the second judgment unit is to determine that there are semantically inconsistent access control constraints in the incomplete access control constraints in the target control flow set.
[0246] It can be seen from the technical solutions introduced above that, in actual application, different cross-chain bridges have different cross-chain semantics. Identifying the cross-chain semantics of different cross-chain bridges helps to analyze the vulnerabilities of the smart contracts on both sides of the cross-chain bridge. Therefore, when it is necessary to determine whether the smart contracts on both sides of the cross-chain bridge to be analyzed have cross-chain bridge vulnerabilities, the device provided in the embodiment of the present application can determine the target control flow set of the smart contracts on both sides of the cross-chain bridge to be analyzed; so that it can be determined whether the smart contracts on both sides of the cross-chain bridge to be analyzed have cross-chain bridge vulnerabilities by analyzing the target control flows of the smart contracts on both sides of the cross-chain bridge to be analyzed, wherein the target control flows of the smart contracts on both sides of the cross-chain bridge have at least one access control constraint.
[0247] Therefore, after determining the target control flow set of the smart contracts on both sides of the cross-chain bridge to be analyzed, all access control constraints in the target control flow set can be further identified; in actual application, it is generally believed that if there are incomplete and semantically inconsistent access control constraints in the control flow of the smart contract, it is considered that the smart contract has a cross-chain bridge vulnerability. Therefore, after identifying all access control constraints of the target control flow set of the smart contracts on both sides of the cross-chain bridge to be analyzed, it can be further determined whether all access control constraints in the target control flow set are complete; if there are incomplete access control constraints in the target control flow set, it can be further determined whether there are semantically inconsistent access control constraints in the incomplete access control constraints in the target control flow set; if there are semantically inconsistent access control constraints in the incomplete access control constraints in the target control flow set, it can be determined that the control flow corresponding to the incomplete and semantically inconsistent access control constraints in the target control flow set has a cross-chain bridge vulnerability.
[0248] From the above introduction, it can be seen that when it is necessary to detect vulnerabilities in the smart contract corresponding to the cross-chain bridge, the device provided by the embodiment of the present application can summarize the cross-chain semantics of different cross-chain bridges, realize the extraction of the security control flow information of the cross-chain bridge, and can identify the context information in the cross-chain data transmission process, and use it to determine whether the smart contract of the cross-chain bridge has a cross-chain bridge vulnerability. The device provided by the embodiment of the present application can detect a wider range of inconsistent access control vulnerabilities and inconsistent semantics vulnerabilities, which can effectively improve the accuracy and recall rate of vulnerability detection for cross-chain bridge smart contracts.
[0249] Among them, the specific processing flow of each unit included in the above-mentioned cross-chain bridge smart contract vulnerability detection device can refer to the relevant introduction of the cross-chain bridge smart contract vulnerability detection method in the previous text, and will not be repeated here.
[0250] The cross-chain bridge smart contract vulnerability detection device provided in the embodiment of the present application can be applied to cross-chain bridge smart contract vulnerability detection equipment, such as terminals: mobile phones, computers, etc. Optionally, Figure 4 The hardware structure diagram of the cross-chain bridge smart contract vulnerability detection device is shown. Figure 4 The hardware structure of the cross-chain bridge smart contract vulnerability detection device may include: at least one processor 1, at least one communication interface 2, at least one memory 3 and at least one communication bus 4.
[0251] In the embodiment of the present application, the number of the processor 1 , the communication interface 2 , the memory 3 , and the communication bus 4 is at least one, and the processor 1 , the communication interface 2 , and the memory 3 communicate with each other through the communication bus 4 .
[0252] The processor 1 may be a central processing unit CPU, or an application-specific integrated circuit ASIC (Application Specific Integrated Circuit), or one or more integrated circuits configured to implement the embodiments of the present application, etc.;
[0253] The memory 3 may include a high-speed RAM memory, and may also include a non-volatile memory, such as at least one disk memory;
[0254] Among them, the memory stores a program, and the processor can call the program stored in the memory, and the program is used to: implement each processing flow in the aforementioned terminal cross-chain bridge smart contract vulnerability detection solution.
[0255] An embodiment of the present application also provides a readable storage medium, which may store a program suitable for execution by a processor, and the program is used to: implement the various processing flows of the aforementioned terminal in the cross-chain bridge smart contract vulnerability detection solution.
[0256] Finally, it should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the presence of other identical elements in the process, method, article or device including the elements.
[0257] The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referenced to each other.
[0258] The above description of the disclosed embodiments enables professionals and technicians in the field to implement or use the present application. Various modifications to these embodiments will be apparent to professionals and technicians in the field, and the general principles defined herein can be implemented in other embodiments without departing from the spirit or scope of the present application. The various embodiments can be combined with each other. Therefore, the present application will not be limited to the embodiments shown herein, but will conform to the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A cross-chain bridge smart contract vulnerability detection method, characterized in that: include: Determine the target control flow set of smart contracts on both sides of the cross-chain bridge to be analyzed; Identifying all access control constraints in the target control flow set; Determining whether all access control constraints in the target control flow set are complete; If there are incomplete access control constraints in the target control flow set, determining whether there are semantically inconsistent access control constraints in the incomplete access control constraints in the target control flow set; If there are semantically inconsistent access control constraints in the incomplete access control constraints in the target control flow set, it is determined that the control flow corresponding to the incomplete and semantically inconsistent access control constraints in the target control flow set has a cross-chain bridge vulnerability.
2. The method according to claim 1, characterized in that The method further includes: Analyze the reachable path from the contract entry point to the vulnerable function in the incomplete and semantically inconsistent access control constraints in the target control flow set to determine the reachability of the control flow corresponding to the incomplete and semantically inconsistent access control constraints in the target control flow set; Analyze the state variables affected by the vulnerability function of the incomplete and semantically inconsistent access control constraints in the target control flow set to determine the destructiveness of the control flow corresponding to the incomplete and semantically inconsistent access control constraints in the target control flow set.
3. The method according to claim 1, characterized in that The determining whether all access control constraints in the target control flow set are complete includes: Modeling all access control constraints of the target control flow set to obtain a model corresponding to all access control constraints of the target control flow set; According to the model corresponding to all the access control constraints of the target control flow set, all the security check requirements corresponding to all the access control constraints of the target control flow set are standardized to obtain a standardized security check set, wherein the standardized security check set includes all the security check requirements of all the access control constraints of the target control flow set; Access resources corresponding to all access control constraints of the target control flow set; Associating the resources corresponding to all the access control constraints of the target control flow set with the various security check requirements of the standard security check set to obtain the corresponding relationship between the resources corresponding to all the access constraints of the target control flow set and the various security check requirements; Based on the correspondence between resources corresponding to all access constraints of the target control flow set and various security check requirements, identifying whether there is an access control constraint in the target control flow set that does not meet the security check requirements corresponding to each access control constraint; If there are access control constraints in the target control flow set that do not meet the security check requirements corresponding to each access control constraint, then the access control constraints in the target control flow set that do not meet the security check requirements corresponding to each access control constraint are determined to be incomplete access control constraints.
4. The method according to claim 1, characterized in that: The determining whether there are semantically inconsistent access control constraints in the incomplete access control constraints in the target control flow set includes: Constructing a cross-chain control flow graph corresponding to the incomplete access control constraints in the target control flow set; Based on the cross-chain control flow graph corresponding to the incomplete access control constraints in the target control flow set, data analysis is performed on the cross-chain control flow graph corresponding to the incomplete access control constraints in the target control flow set, and a cross-chain data flow graph corresponding to the cross-chain control flow graph corresponding to the incomplete access control constraints in the target control flow set is formed; Performing semantic analysis on the cross-chain control flow graph and its corresponding cross-chain data flow graph corresponding to the incomplete access control constraints in the target control flow set to obtain semantic analysis results of the incomplete access control constraints in the target control flow set; According to the semantic analysis result of the incomplete access control constraints in the target control flow set, it is determined whether there are semantically inconsistent access control constraints in the incomplete access control constraints in the target control flow set.
5. The method according to claim 3, characterized in that: The associating the resources corresponding to all the access control constraints of the target control flow set with the security check requirements of the standard security check set includes: Calculate all reachable paths for each resource corresponding to all access control constraints of the target control flow set; Find out the security checks of all access control constraints on each reachable path of each resource corresponding to all access control constraints of the target control flow set; All reachable paths of each resource corresponding to all access control constraints of the target control flow set are associated with security check requirements of all access control constraints on each reachable path of each resource corresponding to all access control constraints of the target control flow set.
6. The method according to claim 1, characterized in that The rule for determining whether all access control constraints in the target control flow set are complete includes: If it is determined that there is an access control constraint with a missing security check requirement among all the access control constraints in the target control flow set, then the access control constraint with a missing security check requirement among all the access control constraints in the target control flow set is determined to be an incomplete access control constraint; and / or, If it is determined that there is an access control constraint with an access control violation path among all the access control paths in all the access control constraints in the target control flow set, then the access control constraint corresponding to the access control violation path in the target control flow is determined to be an incomplete access control constraint; The rule for determining whether there are semantically inconsistent access control constraints in the incomplete access control constraints in the target control flow set includes: If it is determined that among the incomplete access control constraints in the target control flow set, there are access control constraints whose semantic granularity does not satisfy the reachable path requirements corresponding to each access control constraint, then it is determined that among the incomplete access control constraints in the target control flow set, there are access control constraints whose semantic granularity does not satisfy the reachable path requirements corresponding to the access control constraints are incomplete and semantically inconsistent access control constraints; and / or, If it is determined that the incomplete access control constraints in the target control flow set include access control constraints whose semantic integrity does not satisfy the data dependencies of the state variables corresponding to the access control constraints, then it is determined that the incomplete access control constraints in the target control flow set include access control constraints whose semantic integrity does not satisfy the data dependencies of the state variables corresponding to the access control constraints are incomplete and semantically inconsistent access control constraints.
7. The method according to claim 4, characterized in that The constructing a cross-chain control flow graph corresponding to the incomplete access control constraints in the target control flow set includes: Determine the basic block nodes, the relay nodes for cross-chain data transmission, and the client nodes of the cross-chain bridge client corresponding to the incomplete access control constraints in the target control flow set; Determine the control edge, monitoring edge and notification edge corresponding to the incomplete access control constraint in the target control flow set, wherein the monitoring edge corresponding to the incomplete access control constraint in the target control flow set corresponds to the information flow of the repeater and the client monitoring event message corresponding to the incomplete access control constraint in the target control flow set, and the notification edge corresponding to the incomplete access control constraint in the target control flow set corresponds to the information flow of the repeater corresponding to the incomplete access control constraint in the target control flow set notifying the contract execution event on the target chain; The basic block nodes corresponding to the incomplete access control constraints in the target control flow set, the repeater nodes for cross-chain data transmission, and the client nodes of the cross-chain bridge client are respectively established with the control edges, listening edges, and notification edges corresponding to the incomplete access control constraints in the target control flow set, and a cross-chain control flow graph corresponding to the incomplete access control constraints in the target control flow set is obtained.
8. A cross-chain bridge smart contract vulnerability detection device, characterized in that: include: A control flow determination unit, used to determine the target control flow set of the smart contracts on both sides of the cross-chain bridge to be analyzed; An identification unit, used to identify all access control constraints in the target control flow set; A first judging unit, configured to judge whether all access control constraints in the target control flow set are complete; a second judgment unit, configured to judge whether there are semantically inconsistent access control constraints in the incomplete access control constraints in the target control flow set when the execution result of the first judgment unit is to determine that there are incomplete access control constraints in the target control flow set; A vulnerability determination unit is used to determine that a cross-chain bridge vulnerability exists in the control flow corresponding to the incomplete and semantically inconsistent access control constraints in the target control flow set when the execution result of the second judgment unit is to determine that there are semantically inconsistent access control constraints in the incomplete access control constraints in the target control flow set.
9. A cross-chain bridge smart contract vulnerability detection device, characterized in that: include: one or more processors, and memory; The memory stores computer-readable instructions, which, when executed by the one or more processors, implement the steps of the cross-chain bridge smart contract vulnerability detection method as described in any one of claims 1 to 7.
10. A readable storage medium, characterized in that: The readable storage medium stores computer-readable instructions. When the computer-readable instructions are executed by one or more processors, the one or more processors implement the steps of the cross-chain bridge smart contract vulnerability detection method as described in any one of claims 1 to 7.
Citation Information
Patent Citations
Cross-contract vulnerability detection technology based on large language model
CN117389888A
Method and system for supporting smart contracts in a blockchain network
US20240020109A1