Security analysis method, device, equipment and storage medium for blockchain consensus protocol
By generating consensus messages in the blockchain system and calculating data differences, identifying whether the target node violates the consensus protocol, the problem of inaccurate and rapid analysis of the security of the blockchain consensus protocol in the existing technology is solved, and the effect of quickly discovering consensus failure vulnerabilities is achieved.
Patent Information
- Application Number
- CN202311623508.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-11-28
- Publication Date
- 2025-08-26
- Estimated Expiration
- 2043-11-28
AI Technical Summary
The existing technology cannot accurately and quickly identify and analyze the security of blockchain consensus protocols, making it difficult to detect consensus failure vulnerabilities.
By generating consensus messages and broadcasting to the blockchain system, the consensus data differences are calculated, and the preset data is compared and determined whether the target node violates the consensus protocol requirements, and the node monitoring and behavioral divergence engine are used for security analysis.
Rapidly discover security issues of consensus protocols, improve the accuracy and efficiency of analysis, and can identify consensus failure vulnerabilities.
Smart Images

Figure CN117439996B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of blockchain technology, and in particular to a security analysis method, device, equipment, and storage medium for a blockchain consensus protocol. Background Art
[0002] Unlike centralized distributed systems, transactions in blockchain networks must be executed by all replicas. Consensus protocols are developed to ensure validity and consistency across all replicas. Once a user sends a transaction to a blockchain network, it is broadcast to all nodes and stored in their transaction pools. When a node becomes a leader / miner based on the network's specific consensus protocol, it executes and sorts transactions from the transaction pool. The leader / miner then closes the block with its signature and broadcasts it to other nodes. When other nodes receive a block from the network, they become validators. They check the validity of the block and the transactions contained within it. If the block is deemed legitimate, it is linked to their local blockchain. Finally, all replicas update their global state based on the transaction results. This consensus process ensures that the ledgers of all honest nodes remain identical.
[0003] Security analysis of consensus protocols is essential because they are the key mechanism in blockchain systems that ensures consensus among all nodes in a distributed network. The goal of security analysis is to assess the security of the consensus protocol—that is, to determine whether it can withstand various attacks and threats, ensuring the reliability and security of the system. Consensus protocol flaws, such as code vulnerabilities, algorithmic implementation errors, or imperfect network communication, can lead to consensus failure vulnerabilities.
[0004] Currently, security analysis methods for blockchain consensus protocols cannot accurately identify vulnerabilities and the identification process is relatively complicated. Summary of the Invention
[0005] The main purpose of the present invention is to provide a security analysis method, device, equipment and storage medium for a blockchain consensus protocol, aiming to solve the technical problem that the existing technology cannot accurately and quickly analyze the security of the consensus protocol.
[0006] To achieve the above objectives, the present invention provides a security analysis method for a blockchain consensus protocol, the method comprising the following steps:
[0007] Broadcasting the generated consensus message and transaction to the blockchain system, so that the transaction is executed under the consensus protocol of the blockchain system according to the consensus message, and generating consensus data of the target node;
[0008] Calculating the difference between the consensus data to obtain a consensus difference;
[0009] Comparing the consensus data corresponding to the consensus difference with the preset data to obtain a comparison result;
[0010] Determine whether the target node violates the consensus protocol requirements based on the comparison result, so as to perform a security analysis on the consensus protocol.
[0011] Optionally, broadcasting the generated consensus message and transaction to the blockchain system so that the transaction is executed under the consensus protocol of the blockchain system according to the consensus message, and generating consensus data of the target node, includes:
[0012] Establish connections with each node in the blockchain system and monitor the consensus behavior of said nodes;
[0013] selecting a target node from the nodes based on the consensus behavior;
[0014] Mutate the generated consensus message to obtain a mutated message;
[0015] The generated transaction and the mutation message are broadcast to a target node in the blockchain system, so that the transaction is executed under the consensus protocol of the blockchain system according to the mutation message, and consensus data of the target node is generated.
[0016] Optionally, mutating the generated consensus message to obtain a mutated message includes:
[0017] Parse the grammatical structure of the generated consensus message to obtain the parsed content;
[0018] mutating a preset field in the parsed content to obtain a mutated field;
[0019] The mutation message is obtained through the mutation field.
[0020] Optionally, calculating the difference between the consensus data to obtain the consensus difference includes:
[0021] Obtaining the consensus algorithm and data type of the consensus data;
[0022] Comparing the consensus data based on the consensus algorithm and the data type to obtain a consensus comparison result of the consensus data;
[0023] The difference between the consensus data is calculated according to the consensus comparison result to obtain a consensus difference.
[0024] Optionally, calculating the difference between the consensus data according to the consensus comparison result to obtain the consensus difference includes:
[0025] Obtain missing data, inconsistent data, and data that do not conform to the rules based on the consensus comparison results;
[0026] Calculate the difference using the missing data, the inconsistent data, and the data that does not conform to the rules;
[0027] The consensus difference is obtained through the difference situation.
[0028] Optionally, determining whether the target node violates a consensus protocol requirement according to the comparison result to perform a security analysis on the consensus protocol includes:
[0029] Performing a liveness, security, integrity, and fairness analysis of the consensus protocol on the target node according to the comparison result to obtain an analysis result;
[0030] Determining whether the target node violates consensus protocol requirements based on the analysis results to perform a security analysis on the consensus protocol;
[0031] When the analysis result indicates that the target node does not comply with at least one of liveness, security, integrity, and fairness of the consensus protocol, determining that the target node violates a requirement of the consensus protocol;
[0032] Determine that the consensus protocol has a consensus failure vulnerability and complete the security analysis of the consensus protocol.
[0033] Optionally, after determining whether the target node violates the consensus protocol requirements according to the comparison result to perform a security analysis on the consensus protocol, the method further includes:
[0034] Generate a new consensus message and transaction, and return to execute the step of broadcasting the generated consensus message and transaction to the blockchain system, so that the transaction is executed under the consensus protocol of the blockchain system according to the consensus message, and generating consensus data of the target node.
[0035] In addition, to achieve the above-mentioned purpose, the present invention also proposes a security analysis device for a blockchain consensus protocol, the security analysis device for a blockchain consensus protocol comprising:
[0036] A broadcast module, configured to broadcast the generated consensus message and transaction to the blockchain system, so as to execute the transaction under the consensus protocol of the blockchain system according to the consensus message and generate consensus data of the target node;
[0037] A calculation module, configured to calculate the difference between the consensus data to obtain a consensus difference;
[0038] An acquisition module, configured to obtain a comparison result between the consensus data and preset data;
[0039] A determination module is used to determine whether the target node violates the consensus protocol requirements based on the comparison result and the consensus difference, so as to perform a security analysis on the consensus protocol.
[0040] In addition, to achieve the above-mentioned purpose, the present invention also proposes a security analysis device for a blockchain consensus protocol, wherein the security analysis device for the blockchain consensus protocol includes: a memory, a processor, and a security analysis program for the blockchain consensus protocol stored on the memory and executable on the processor, wherein the security analysis program for the blockchain consensus protocol is configured to implement the steps of the security analysis method for the blockchain consensus protocol as described above.
[0041] In addition, to achieve the above-mentioned purpose, the present invention also proposes a storage medium, on which a security analysis program of a blockchain consensus protocol is stored. When the security analysis program of the blockchain consensus protocol is executed by a processor, the steps of the security analysis method of the blockchain consensus protocol as described above are implemented.
[0042] The present invention broadcasts the generated consensus message and transaction to the blockchain system, so that the transaction is executed under the consensus protocol of the blockchain system according to the consensus message, thereby generating consensus data of the target node; calculating the difference between the consensus data to obtain a consensus difference; comparing the consensus data corresponding to the consensus difference with preset data to obtain a comparison result; and determining whether the target node violates the consensus protocol requirements based on the comparison result to perform a security analysis on the consensus protocol, which can quickly discover security issues of the consensus protocol and improve accuracy and testing efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0043] Figure 1 Schematic diagram of the structure of a security analysis device for a blockchain consensus protocol in a hardware operating environment according to an embodiment of the present invention;
[0044] Figure 2 This is a flow chart of the first embodiment of the security analysis method for the blockchain consensus protocol of the present invention;
[0045] Figure 3 This is a flow chart of the second embodiment of the security analysis method for the blockchain consensus protocol of the present invention;
[0046] Figure 4 This is a flowchart of the third embodiment of the security analysis method for the blockchain consensus protocol of the present invention;
[0047] Figure 5 This is a flowchart of the fourth embodiment of the security analysis method for the blockchain consensus protocol of the present invention;
[0048] Figure 6 This is a structural block diagram of the first embodiment of the security analysis device for the blockchain consensus protocol of the present invention.
[0049] The purpose, features and advantages of the present invention will be further described with reference to the accompanying drawings and in conjunction with the embodiments. DETAILED DESCRIPTION
[0050] It should be understood that the specific embodiments described herein are only used to explain the present invention and are not intended to limit the present invention.
[0051] Reference Figure 1 , Figure 1 This is a schematic diagram of the structure of a security analysis device for a blockchain consensus protocol in a hardware operating environment according to an embodiment of the present invention.
[0052] like Figure 1 As shown, the blockchain consensus protocol security analysis device may include: a processor 1001, such as a central processing unit (CPU), a communication bus 1002, a user interface 1003, a network interface 1004, and a memory 1005. The communication bus 1002 is used to enable communication between these components. The user interface 1003 may include a display screen and an input unit such as a keyboard. Optionally, the user interface 1003 may also include a standard wired interface or a wireless interface. The network interface 1004 may optionally include a standard wired interface or a wireless interface (such as a wireless fidelity (Wi-Fi) interface). The memory 1005 may be a high-speed random access memory (RAM) or a stable non-volatile memory (NVM), such as a disk storage device. The memory 1005 may also be a storage device independent of the aforementioned processor 1001.
[0053] Those skilled in the art will understand that Figure 1 The structure shown in does not constitute a limitation on the security analysis device of the blockchain consensus protocol, and may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently.
[0054] like Figure 1 As shown, the memory 1005 as a storage medium may include an operating system, a network communication module, a user interface module, and a security analysis program for the blockchain consensus protocol.
[0055] exist Figure 1In the security analysis device of the blockchain consensus protocol shown, the network interface 1004 is mainly used for data communication with the network server; the user interface 1003 is mainly used for data interaction with the user; the processor 1001 and the memory 1005 in the security analysis device of the blockchain consensus protocol of the present invention can be set in the security analysis device of the blockchain consensus protocol, and the security analysis device of the blockchain consensus protocol calls the security analysis program of the blockchain consensus protocol stored in the memory 1005 through the processor 1001, and executes the security analysis method of the blockchain consensus protocol provided by the embodiment of the present invention.
[0056] The embodiment of the present invention provides a security analysis method for a blockchain consensus protocol, referring to Figure 2 , Figure 2 This is a flow chart of the first embodiment of the security analysis method for the blockchain consensus protocol of the present invention.
[0057] In this embodiment, the security analysis method of the blockchain consensus protocol includes the following steps:
[0058] Step S10: Broadcast the generated consensus message and transaction to the blockchain system, so that the transaction is executed under the consensus protocol of the blockchain system according to the consensus message, and generate consensus data of the target node.
[0059] It should be noted that the execution entity of this embodiment can be a security analysis device of the blockchain consensus protocol, or other devices that can achieve the same or similar functions. This embodiment does not limit this. This embodiment uses the security analysis device of the blockchain consensus protocol as an example for explanation.
[0060] Currently, there are several existing technical solutions for the security analysis model method of blockchain consensus protocol:
[0061] Formal Verification: Formal methods are used to model and verify the consensus protocol to verify its security and correctness. This approach is primarily based on mathematical principles and formal logic, and can be verified through techniques such as formal specification, symbolic execution, and model checking. For example, the model checking tool Spin is used to verify the properties of the consensus protocol.
[0062] Fuzz testing: Fuzz testing techniques are used to analyze the security of consensus protocols. This method generates a large amount of random input data to test the behavior and response of the consensus protocol under different circumstances. By observing the consensus protocol's ability to handle unexpected input, potential vulnerabilities and security issues can be discovered. For example, tools such as Atheris and Echidna are used to perform fuzz testing on blockchain protocols.
[0063] Security Audit: A professional security team or organization conducts a comprehensive security audit of the consensus protocol. This approach involves comprehensive evaluation and analysis of the protocol's design, code, documentation, and actual operation to identify potential vulnerabilities and security risks. Security audits typically combine multiple technical means and methods to provide comprehensive security analysis results.
[0064] Effectively detecting Consensus Failure Bugs (CFBs) in blockchain systems presents two key challenges. The first is developing an oracle that can accurately determine whether a blockchain system is behaving correctly. Blockchain consensus behavior is complex and dynamic, making it difficult to detect vulnerabilities even if they exist without an accurate detector. The second challenge is that CFBs are often hidden in deep logical paths, making it difficult to effectively trigger these erroneous oracles. The blockchain consensus process typically consists of multiple phases, with multiple nodes interacting and collaborating at different stages. Detecting deep logical path vulnerabilities requires multiple nodes to execute a series of different behaviors. Therefore, this embodiment tests the blockchain network by masquerading as real nodes, sensing the consensus network state in real time and continuously generating consensus messages and transactions as test input to ensure that node behavior within the network is as diverse as possible. Simultaneously, the consensus data of target nodes is monitored and analyzed in real time. If any node violates the "four properties" of the consensus protocol (liveness, security, integrity, and fairness), a consensus failure vulnerability is detected.
[0065] The blockchain consensus protocol security analysis device includes two key components: a node monitoring engine and a behavioral deviation engine. These components are used to analyze the security of the blockchain consensus protocol. The behavioral deviation engine continuously calculates differences in node behavior and constructs a large number of messages and transactions based on these differences. The node monitoring engine analyzes node consensus data in real time and identifies consensus failure vulnerabilities.
[0066] It should be noted that the behavioral deviation engine in the blockchain consensus protocol security analysis device is also used to construct a set of messages using a message fuzzer to generate consensus messages. Consensus messages can be randomly generated during the initial test iteration or generated based on node differences during iterations. The behavioral deviation engine also generates a set of transactions and preset data for validity checks.
[0067] After the consensus message and transaction are generated, the generated consensus message can be broadcast to the blockchain system, so that the transaction is executed under the consensus protocol of the blockchain system and the consensus data of the target node is generated.
[0068] In a specific implementation, the generated expected data can be stored in its own storage space in advance to facilitate subsequent validity checks.
[0069] The node monitoring engine can monitor and collect consensus data from distributed nodes in real time. This data can include block height, transaction history, status information, etc. This data can be obtained by establishing a connection with each node and using the corresponding API or protocol.
[0070] Step S20: Calculate the difference between the consensus data to obtain a consensus difference.
[0071] It should be understood that after collecting the consensus data, the node monitoring engine can calculate the differences between the consensus data, which may specifically include steps such as data comparison and difference calculation, so as to obtain the consensus differences between the consensus data.
[0072] It should be understood that the behavior deviation engine is also used to collect execution runtime information of nodes and record the differences between them.
[0073] Step S30: Compare the consensus data corresponding to the consensus difference with preset data to obtain a comparison result.
[0074] In a specific implementation, the node monitoring engine compares the consensus data with preset data, which is the consensus data generated under a normal consensus protocol. The comparison result may be a difference between the consensus data and the preset data, or it may be no difference between the consensus data and the preset data.
[0075] Step S40: Determine whether the target node violates the consensus protocol requirements based on the comparison result, so as to perform a security analysis on the consensus protocol.
[0076] It should be understood that whether the target node violates the consensus protocol requirements can be determined based on the comparison results. For example, the target node can be analyzed based on the comparison results to determine whether the target node violates the "four properties" requirements of the consensus protocol, thereby obtaining the analysis results. If the target node violates the consensus protocol requirements, it is determined that the consensus protocol corresponding to the target node has a consensus failure vulnerability. If the consensus protocol requirements are not violated, the analysis can continue to achieve security analysis of the consensus protocol.
[0077] Optionally, after step S40, it also includes: generating a new consensus message and transaction, and returning to execute the step of broadcasting the generated consensus message and transaction to the blockchain system, so as to execute the transaction under the consensus protocol of the blockchain system according to the consensus message, and generating consensus data of the target node.
[0078] It should be noted that if the current consensus protocol situation is identified, the next iteration of the test process can be continued, thereby generating new consensus messages and transactions, and continuing to return to execute the generated consensus messages and transactions to be broadcast to the blockchain system, so that the transaction executes the steps of generating consensus data of the target node under the consensus protocol of the blockchain system, performs new consensus protocol analysis, and continuously generates messages as test inputs for the target node in the blockchain system, so that the test node can generate resistance to the entire network, and can quickly discover consensus protocol security issues.
[0079] This embodiment broadcasts the generated consensus message and transaction to the blockchain system, so that the transaction is executed under the consensus protocol of the blockchain system according to the consensus message, thereby generating consensus data of the target node; calculating the difference between the consensus data to obtain a consensus difference; comparing the consensus data corresponding to the consensus difference with preset data to obtain a comparison result; and determining whether the target node violates the consensus protocol requirements based on the comparison result to perform a security analysis on the consensus protocol, thereby quickly discovering security issues of the consensus protocol and improving accuracy and testing efficiency.
[0080] refer to Figure 3 , Figure 3 This is a flow chart of the second embodiment of the security analysis method for the blockchain consensus protocol of the present invention.
[0081] Based on the first embodiment described above, step S10 of the security analysis method for the blockchain consensus protocol in this embodiment includes:
[0082] Step S101: Establish a connection with each node in the blockchain system and monitor the consensus behavior of the node.
[0083] It's important to note that the consensus process of most blockchain systems aims to ensure eventual consistency. During this process, transient inconsistencies in node behavior are normal and tolerated. However, the ultimate consensus failure is the cumulative result of many transient inconsistencies during the consensus process. Therefore, to help achieve deeper consensus logic and effectively trigger consensus failure vulnerabilities, this embodiment uses a behavior deviation engine to guide message generation and maximize the differentiation of node behavior within the system.
[0084] The behavior of all nodes is driven by messages in the blockchain system. In order to differentiate the behavior of nodes as much as possible, a behavior-guided message fuzzer is used to continuously generate messages as test inputs for the target node in the blockchain system.
[0085] Before fuzzing, connections can be established with each node in the blockchain system and their consensus behavior can be monitored in real time.
[0086] Step S102: Select a target node from the nodes based on the consensus behavior.
[0087] In a specific implementation, messages from the network are collected as initial seeds and placed into a message pool. In each fuzzy iteration, some target nodes can be selected from the network. For example, some nodes can be selected as target nodes based on consensus behavior.
[0088] Step S103: mutate the generated consensus message to obtain a mutated message.
[0089] It should be understood that after the target node is selected, the generated consensus message can be mutated to obtain a mutated message.
[0090] Furthermore, the generated consensus message is mutated to obtain the mutated message, including the steps of: parsing the grammatical structure of the generated consensus message to obtain parsed content; mutating the preset fields in the parsed content to obtain mutated fields; and obtaining the mutated message through the mutated fields.
[0091] Blockchain message packets are highly structured. As a mutation-based fuzzer, it's crucial to maintain the message structure while mutating its content. Since each blockchain implementation has its own message parser, the parser first analyzes the grammatical structure of each message to derive the parsed content. For example, Fabric uses the protobuf format for message serialization and deserialization, so it directly uses the Marshal and Unmarshal packages to parse messages.
[0092] Then, after obtaining the parsed content, the preset fields in the parsed content may be mutated to obtain mutated fields, where the preset fields are old fields, and the mutated fields are combined to obtain a mutated message.
[0093] Generates a new value for each field by mutating the old one. Use different mutators for different field types. A numeric mutator converts a random number to another. A string mutator mutates a string to a new string. For struct types, each field is mutated recursively.
[0094] Step S104: broadcasting the generated transaction and the mutation message to the target node in the blockchain system, so that the transaction is executed under the consensus protocol of the blockchain system according to the mutation message, and generating consensus data of the target node.
[0095] In a specific implementation, a well-mutated message is generated and sent to a target node in the blockchain network, and the generated transaction is also sent to the target node in the blockchain system, so that the transaction is executed under the consensus protocol of the blockchain system and the consensus data of the target node is generated.
[0096] This embodiment establishes a connection with each node in the blockchain system and monitors the consensus behavior of the nodes; selects a target node from the nodes based on the consensus behavior; mutates the generated consensus message to obtain a mutated message; broadcasts the generated transaction and the mutated message to the target node in the blockchain system, so that the transaction is executed under the consensus protocol of the blockchain system according to the mutated message, and generates consensus data for the target node. By continuously generating a large number of abnormal divergent consensus messages, the behavior of distributed nodes is caused to diverge as much as possible, and is used for effective testing of consensus protocol detection, so that consensus protocol security issues can be quickly discovered.
[0097] refer to Figure 4 , Figure 4 This is a flow chart of the third embodiment of the security analysis method for the blockchain consensus protocol of the present invention.
[0098] Based on the first embodiment described above, step S20 of the security analysis method for the blockchain consensus protocol in this embodiment includes:
[0099] Step S201: Acquire the consensus algorithm and data type of the consensus data.
[0100] It should be noted that after the consensus data is collected, the consensus data can be compared. The specific comparison method depends on the consensus algorithm and data type. Therefore, the consensus algorithm and data type of the consensus data can be obtained.
[0101] For example, for a blockchain system using the Byzantine Fault Tolerance consensus algorithm, you can compare the block heights and transaction hash values of different nodes to see if they are consistent. For a system using the Proof of Stake consensus algorithm, you can compare the stake distribution and signature verification results of different nodes.
[0102] Step S202: comparing the consensus data based on the consensus algorithm and the data type to obtain a consensus comparison result of the consensus data.
[0103] In a specific implementation, the consensus data may be compared based on the consensus algorithm and data type, thereby obtaining a consensus comparison result of the consensus data.
[0104] Step S203: Calculate the difference between the consensus data according to the consensus comparison result to obtain a consensus difference.
[0105] It should be understood that based on the data comparison results, the node monitoring engine can calculate the differences between the consensus data. These differences may include missing data, inconsistent data, or data that does not comply with the rules. For example, if the block heights of different nodes are inconsistent, the number of missing blocks or the existence of blockchain forks can be calculated.
[0106] Optionally, the difference between the consensus data is calculated based on the consensus comparison result, and the step of obtaining the consensus difference specifically includes: obtaining missing data, inconsistent data and non-compliant data based on the consensus comparison result; calculating the difference situation through the missing data, the inconsistent data and the non-compliant data; and obtaining the consensus difference through the difference situation.
[0107] In a specific implementation, missing data, inconsistent data, and data that does not comply with rules can be determined based on the specific consensus comparison results, so that the differences between the consensus data can be calculated to obtain the consensus difference, which may specifically include the difference value.
[0108] This embodiment obtains the consensus algorithm and data type of the consensus data; compares the consensus data based on the consensus algorithm and the data type to obtain a consensus comparison result of the consensus data; calculates the difference between the consensus data according to the consensus comparison result to obtain a consensus difference, thereby quickly calculating the consensus difference between the consensus data and facilitating the generation of subsequent mutation messages.
[0109] refer to Figure 5 , Figure 5 Schematic diagram of the fourth embodiment of the security analysis method for the blockchain consensus protocol of the present invention.
[0110] Based on the first embodiment described above, step S40 of the security analysis method for the blockchain consensus protocol in this embodiment includes:
[0111] Step S401: performing a liveness, security, integrity, and fairness analysis of the consensus protocol on the target node according to the comparison result to obtain an analysis result.
[0112] It should be noted that the blockchain consensus protocol includes four key attributes, namely liveness, security, integrity, and fairness. For example, a model can be established based on the four key attributes, so that the model can analyze the "four properties" of the consensus protocol of the target node and obtain the analysis results.
[0113] Liveness requirements ensure that the system can continue to operate and reach consensus. Determining whether a node is violating liveness requirements can be done through the following methods: Block height comparison: Comparing the blockchain heights of nodes. If a node's block height lags significantly behind other nodes, there may be a liveness issue. Transaction confirmation time: Monitoring transaction confirmation times. If a node's transaction confirmation time is significantly longer or fails to confirm transactions in a timely manner, there may be a liveness issue. Node block generation frequency: Comparing the block generation frequency of nodes. If a node has not generated blocks for an extended period of time or its frequency is significantly lower than other nodes, there may be a liveness issue.
[0114] Security requirements ensure that the system is resilient to various attacks and malicious behavior. Determining whether a node has violated security requirements can be done through the following methods: Double-spending detection: Detecting whether a node sends the same transaction to different nodes at the same time, thereby enabling a double-spending attack. Byzantine behavior detection: Identifying whether a node sends incorrect consensus information, such as incorrect block data or transaction data. Signature verification: Verifying the validity of the signature of a transaction or block sent by a node to prevent data forgery or tampering.
[0115] Integrity requirements ensure the consistency and correctness of blockchain data. Determining whether a node violates integrity requirements can be done through the following methods: Block hash verification: This verifies the consistency of block hash values across different nodes to verify the integrity of blockchain data. Transaction data consistency verification: This verifies the consistency of transaction records across different nodes to verify any inconsistent transaction data.
[0116] Fairness requirements ensure that nodes have a fair opportunity to participate and receive rewards during the consensus process. Determining whether a node violates fairness requirements can be done through the following methods: Randomness Analysis: Analyzing the random selection mechanism of nodes during the consensus process to check for bias toward certain nodes. Reward Distribution Verification: Verifying the fairness of the method and proportion of rewards received by nodes to prevent nodes from receiving inappropriate rewards or manipulating reward distribution. The node monitoring engine compares consensus data with expected data and, based on the differences in their consensus, determines whether the node has violated the "four properties" of the consensus protocol. If so, it is considered a consensus failure vulnerability.
[0117] Step S402: Determine whether the target node violates the consensus protocol requirements based on the analysis result, so as to perform a security analysis on the consensus protocol.
[0118] By performing a "four-property" analysis on the target node, it is possible to determine whether the target node violates the consensus protocol requirements based on the analysis results, thereby performing a security analysis of the consensus protocol.
[0119] The node monitoring engine monitors and analyzes the consensus data of nodes in real time to identify nodes that violate properties.
[0120] Step S403: When the analysis result indicates that the target node does not comply with at least one of liveness, security, integrity, and fairness of the consensus protocol, it is determined that the target node violates the consensus protocol requirement.
[0121] In a specific implementation, if the analysis result shows that the target node does not meet one or more of the liveness, security, integrity or fairness of the consensus protocol, the target node violates the consensus protocol requirements.
[0122] Step S404: Determine whether the consensus protocol has a consensus failure vulnerability and complete the security analysis of the consensus protocol.
[0123] It is understandable that when the target node violates the consensus protocol requirements, it is determined that the consensus protocol has a consensus failure vulnerability, which can quickly discover the security issues of the consensus protocol, and thus the consensus failure vulnerability can be analyzed and processed.
[0124] In the specific implementation, if the target node meets the liveness, security, integrity and fairness of the consensus protocol, then the current consensus protocol does not have a consensus failure vulnerability, and the security analysis of the next consensus protocol can be continued.
[0125] This embodiment performs a liveness, security, integrity, and fairness analysis of the consensus protocol on the target node based on the comparison result to obtain an analysis result; determines whether the target node violates the consensus protocol requirements based on the analysis result to perform a security analysis on the consensus protocol; when the analysis result shows that the target node does not comply with at least one of the liveness, security, integrity, and fairness of the consensus protocol, determines that the target node violates the consensus protocol requirements; determines that the consensus protocol has a consensus failure vulnerability, completes the security analysis of the consensus protocol, and can quickly and comprehensively identify nodes that violate the attributes, thereby quickly discovering security issues of the consensus protocol.
[0126] Reference Figure 6 , Figure 6 This is a structural block diagram of the first embodiment of the security analysis device for the blockchain consensus protocol of the present invention.
[0127] like Figure 6 As shown, the security analysis device of the blockchain consensus protocol proposed in the embodiment of the present invention includes:
[0128] The broadcast module 10 is used to broadcast the generated consensus message and transaction to the blockchain system, so that the transaction is executed under the consensus protocol of the blockchain system according to the consensus message, and the consensus data of the target node is generated.
[0129] The calculation module 20 is configured to calculate the difference between the consensus data to obtain a consensus difference.
[0130] The acquisition module 30 is configured to obtain a comparison result between the consensus data and preset data.
[0131] The determination module 40 is configured to determine whether the target node violates the consensus protocol requirements based on the comparison result and the consensus difference, so as to perform a security analysis on the consensus protocol.
[0132] This embodiment broadcasts the generated consensus message and transaction to the blockchain system, so that the transaction is executed under the consensus protocol of the blockchain system according to the consensus message, thereby generating consensus data of the target node; calculating the difference between the consensus data to obtain a consensus difference; comparing the consensus data corresponding to the consensus difference with preset data to obtain a comparison result; and determining whether the target node violates the consensus protocol requirements based on the comparison result to perform a security analysis on the consensus protocol, thereby quickly discovering security issues of the consensus protocol and improving accuracy and testing efficiency.
[0133] In one embodiment, the broadcast module 10 is further used to establish a connection with each node in the blockchain system and monitor the consensus behavior of the nodes; select a target node from the nodes based on the consensus behavior; mutate the generated consensus message to obtain a mutated message; broadcast the generated transaction and the mutated message to the target node in the blockchain system, so that the transaction is executed under the consensus protocol of the blockchain system according to the mutated message, and generate consensus data of the target node.
[0134] In one embodiment, the broadcast module 10 is further configured to parse the grammatical structure of the generated consensus message to obtain parsed content; mutate a preset field in the parsed content to obtain a mutated field; and obtain a mutated message through the mutated field.
[0135] In one embodiment, the calculation module 20 is further used to obtain the consensus algorithm and data type of the consensus data; compare the consensus data based on the consensus algorithm and the data type to obtain a consensus comparison result of the consensus data; and calculate the difference between the consensus data based on the consensus comparison result to obtain a consensus difference.
[0136] In one embodiment, the calculation module 20 is further used to obtain missing data, inconsistent data and non-compliant data based on the consensus comparison result; calculate the difference situation through the missing data, the inconsistent data and the non-compliant data; and obtain the consensus difference through the difference situation.
[0137] In one embodiment, the determination module 40 is further used to perform a liveness, security, integrity, and fairness analysis of the consensus protocol on the target node based on the comparison result to obtain an analysis result; determine whether the target node violates the consensus protocol requirements based on the analysis result to perform a security analysis of the consensus protocol; when the analysis result shows that the target node does not comply with at least one of the liveness, security, integrity, and fairness of the consensus protocol, determine that the target node violates the consensus protocol requirements; determine that the consensus protocol has a consensus failure vulnerability, and complete the security analysis of the consensus protocol.
[0138] In one embodiment, the determination module 40 is also used to generate new consensus messages and transactions, and return to execute the step of broadcasting the generated consensus messages and transactions to the blockchain system, so as to execute the transactions under the consensus protocol of the blockchain system according to the consensus messages, and generate consensus data of the target node.
[0139] In addition, an embodiment of the present invention also proposes a storage medium, on which a security analysis program for a blockchain consensus protocol is stored. When the security analysis program for the blockchain consensus protocol is executed by a processor, the steps of the security analysis method for the blockchain consensus protocol as described above are implemented.
[0140] Since the storage medium adopts all the technical solutions of all the above embodiments, it has at least all the beneficial effects brought by the technical solutions of the above embodiments, which will not be described one by one here.
[0141] It should be understood that the above is only an example and does not constitute any limitation to the technical solution of the present invention. In specific applications, those skilled in the art can make settings as needed, and the present invention does not impose any limitation on this.
[0142] It should be noted that the workflow described above is merely illustrative and does not limit the scope of protection of the present invention. In practical applications, technicians in this field can select part or all of it according to actual needs to achieve the purpose of the embodiment scheme, and no limitation is made here.
[0143] In addition, for technical details not fully described in this embodiment, please refer to the security analysis method of the blockchain consensus protocol provided in any embodiment of the present invention, and will not be repeated here.
[0144] In addition, it should be noted that, in this document, the terms "comprises," "includes," or any other variations thereof are intended to encompass non-exclusive inclusion, such that a process, method, article, or system comprising a series of elements includes not only those elements but also other elements not explicitly listed, or elements inherent to such process, method, article, or system. In the absence of further limitations, an element defined by the phrase "comprising a ..." does not exclude the presence of other identical elements in the process, method, article, or system comprising the element.
[0145] The serial numbers of the above embodiments of the present invention are for description only and do not represent the advantages or disadvantages of the embodiments.
[0146] Through the description of the above embodiments, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus the necessary general hardware platform, or of course by hardware, but in many cases the former is a better embodiment. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, can be embodied in the form of a software product. The computer software product is stored in a storage medium (such as a read-only memory (ROM) / RAM, a magnetic disk, or an optical disk), and includes a number of instructions for enabling a terminal device (which can be a mobile phone, a computer, a server, or a network device, etc.) to execute the methods described in each embodiment of the present invention.
[0147] The above are only preferred embodiments of the present invention and are not intended to limit the patent scope of the present invention. Any equivalent structure or equivalent process transformation made using the contents of the present invention description and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present invention.
Claims
1. A security analysis method for a blockchain consensus protocol, characterized in that: The security analysis method of the blockchain consensus protocol includes: Establish connections with each node in the blockchain system and monitor the consensus behavior of said nodes; selecting a target node from the nodes based on the consensus behavior; Parse the grammatical structure of the generated consensus message to obtain the parsed content; mutating a preset field in the parsed content to obtain a mutated field, wherein the preset field is an old field; Obtaining a mutation message through the mutation field; Broadcasting the generated transaction and the mutation message to a target node in the blockchain system, so that the transaction is executed under the consensus protocol of the blockchain system according to the mutation message, and generating consensus data of the target node; Obtaining the consensus algorithm and data type of the consensus data; Comparing the consensus data based on the consensus algorithm and the data type to obtain a consensus comparison result of the consensus data; Obtain missing data, inconsistent data, and data that do not conform to the rules based on the consensus comparison results; Calculate the difference using the missing data, the inconsistent data, and the data that does not conform to the rules; The consensus difference is obtained through the said difference situation; Comparing the consensus data corresponding to the consensus difference with the preset data to obtain a comparison result; Determine whether the target node violates the consensus protocol requirements based on the comparison result, so as to perform a security analysis on the consensus protocol.
2. The security analysis method of the blockchain consensus protocol according to claim 1, characterized in that: Determining whether the target node violates the consensus protocol requirements according to the comparison result to perform a security analysis on the consensus protocol includes: Performing a liveness, security, integrity, and fairness analysis of the consensus protocol on the target node according to the comparison result to obtain an analysis result; Determining whether the target node violates consensus protocol requirements based on the analysis results to perform a security analysis on the consensus protocol; When the analysis result indicates that the target node does not comply with at least one of liveness, security, integrity, and fairness of the consensus protocol, determining that the target node violates a requirement of the consensus protocol; Determine that the consensus protocol has a consensus failure vulnerability and complete the security analysis of the consensus protocol.
3. The security analysis method of the blockchain consensus protocol according to claim 1 or 2, characterized in that: After determining whether the target node violates the consensus protocol requirements based on the comparison result to perform a security analysis on the consensus protocol, the method further includes: Generate a new consensus message and transaction, and return to execute the step of broadcasting the generated consensus message and transaction to the blockchain system, so that the transaction is executed under the consensus protocol of the blockchain system according to the consensus message, and generating consensus data of the target node.
4. A security analysis device for a blockchain consensus protocol, characterized in that: The security analysis device of the blockchain consensus protocol includes: A broadcast module, used to establish connections with each node in the blockchain system and monitor the consensus behavior of said nodes; selecting a target node from the nodes based on the consensus behavior; Parse the grammatical structure of the generated consensus message to obtain the parsed content; mutating a preset field in the parsed content to obtain a mutated field, wherein the preset field is an old field; Obtaining a mutation message through the mutation field; Broadcasting the generated transaction and the mutation message to a target node in the blockchain system, so that the transaction is executed under the consensus protocol of the blockchain system according to the mutation message, and generating consensus data of the target node; a calculation module, configured to obtain a consensus algorithm and a data type of the consensus data; compare the consensus data based on the consensus algorithm and the data type to obtain a consensus comparison result of the consensus data; obtain missing data, inconsistent data, and non-compliant data based on the consensus comparison result; calculate differences based on the missing data, the inconsistent data, and the non-compliant data; and obtain a consensus difference based on the differences; An acquisition module, configured to compare the consensus data corresponding to the consensus difference with preset data to obtain a comparison result; A determination module is used to determine whether the target node violates the consensus protocol requirements based on the comparison result and the consensus difference, so as to perform a security analysis on the consensus protocol.
5. A security analysis device for a blockchain consensus protocol, characterized in that: The security analysis device of the blockchain consensus protocol includes: a memory, a processor, and a security analysis program of the blockchain consensus protocol stored in the memory and executable on the processor, wherein the security analysis program of the blockchain consensus protocol is configured to implement the security analysis method of the blockchain consensus protocol according to any one of claims 1 to 3.
6. A storage medium, characterized in that The storage medium stores a security analysis program for the blockchain consensus protocol, which, when executed by the processor, implements the security analysis method for the blockchain consensus protocol according to any one of claims 1 to 3.
Citation Information
Patent Citations
Fault-tolerant consensus mechanism test method and device, storage medium and computer equipment
CN110868337A
Industrial control protocol test method and system, electronic equipment and storage medium
CN111123888A