A smart contract security audit method based on symbolic abstract analysis
Through symbolic abstract analysis combined with static analysis, the problems of low detection efficiency of smart contracts and high false positive false alarms are solved, and higher detection accuracy and coverage are achieved, adapting to rapid iteration of contract languages and new vulnerabilities.
Patent Information
- Application Number
- CN202111475260.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-06
- Publication Date
- 2024-11-12
- Estimated Expiration
- 2041-12-06
AI Technical Summary
The existing smart contract automation security tools rely on a single technology, have low detection efficiency, incomplete vulnerability verification, high false positive false alarms, low contract coverage, and are difficult to adapt to contract language updates and new vulnerabilities.
The security audit method based on symbol abstract analysis is adopted, and the control flowchart is generated through static detection files, single-assignment statement text analysis is performed in combination with contract information, vulnerability detection strategies are integrated, and the vulnerability path is verified using the symbol analysis engine to improve detection accuracy and coverage.
It improves the accuracy and scalability of vulnerability detection, reduces the false alarm rate, enhances the coverage rate of contracts, and achieves finer granular detection accuracy and higher detection efficiency.
Smart Images

Figure CN114201754B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of smart contracts, and specifically relates to a smart contract security audit method based on symbolic abstract analysis. Background Art
[0002] In the field of automated security tools for smart contracts, there are not many symbolic execution vulnerability detection solutions, among which Oyente, WANA, etc. are more typical. Current automated detection tools are often too dependent on a single technology, and the degree of automation is not high. There is still a lot of work to be done before they can be truly used in practice. Although it is very useful in some cases, there are still some shortcomings and deficiencies. With the update and iteration of the contract language and the increase in the number of vulnerability types, the defects in the detection mode or logic design will lead to the lack of verification of many critical vulnerabilities; due to the inaccurate modeling of vulnerabilities, a large number of false positives will be caused; the contract coverage rate is not high. For some specific contracts, it can meet the basic requirements, but the contract coverage rate in actual production is low. Summary of the invention
[0003] In view of the shortcomings of the existing technology, the present invention proposes a smart contract security audit method based on symbolic abstract analysis, which can improve the detection effect and accuracy of vulnerabilities, reduce the false alarm rate, and improve the scalability and coverage of contracts.
[0004] The present invention provides a smart contract security audit method based on symbolic abstract analysis, comprising the following steps:
[0005] S1: Input the contract source code to be tested and generate a static test file through the contract compiler;
[0006] S2: traverse the static detection file to generate a control flow graph file CFG and collect contraction information;
[0007] S3: The flowchart file CFG is converted into a single assignment statement text SSA using the contract information, modeling and analyzing the single assignment statement text SSA is performed, and contract attribute information is traversed and collected;
[0008] S4: Integrate the contract attribute information as input, perform vulnerability detection strategy search, and generate vulnerability type and vulnerability location;
[0009] S5: Use the vulnerability type and the vulnerability location as input to the symbolic analysis engine, query the basic block where the vulnerability is located, and the symbolic analysis engine analyzes the vulnerability type and the vulnerability location, traces the execution path of the vulnerability, and uses the vulnerability location as the end point of the problem path until the result of the problem path is found. The analysis of the problem path is terminated, and the verification and screening of the generated vulnerability type and the vulnerability location is completed.
[0010] Preferably, in S1, the static detection file includes an abstract syntax tree file AST in Json format.
[0011] Preferably, in S2, the contract information includes contract storage status, data dependency, whether it is inherited and authority definition.
[0012] Preferably, in S3, the contract attribute information includes the flowchart file CFG, function jump relationship, the contract storage status, the data dependency, whether to inherit and the authority definition.
[0013] Preferably, in S4, the vulnerability detection strategy includes that the developer needs to design the detection mode in combination with the current status of a specific vulnerability principle or contract language update, complete the writing and updating of the vulnerability detection, detect the contract attribute information according to the design of the detection mode and the implementation of the code, and generate the vulnerability type and the vulnerability location.
[0014] Preferably, in S5, the result is an input value obtained by constraint solving or exceeds a predetermined time.
[0015] The beneficial effects of the present invention are:
[0016] The present invention provides a smart contract security audit method based on symbolic abstract analysis, which performs the vulnerability detection work by combining static analysis with symbolic analysis. Compared with the traditional method of using single static analysis or symbolic analysis, it has the following beneficial effects:
[0017] 1. High scalability and coverage. In order to solve the problems of rapid iteration of contract language and the generation of new vulnerabilities leading to reduced vulnerability detection efficiency, modular design can be used to upgrade and iterate the original basic framework in a targeted manner without affecting the original functions, thereby enhancing the coverage of contract detection.
[0018] 2. In the multiple conversions of the static analysis contract source code, key information reflecting the vulnerability will be collected, and the contract will be modeled and analyzed in combination with the characteristics of the contract attribute information to maximize the approximation of the actual structure and attributes of the contract, achieve more fine-grained detection accuracy, and integrate the detection strategies of each vulnerability detection mode to achieve accurate vulnerability scanning.
[0019] 3. Static analysis has the advantages of fast speed and wide detection range in vulnerability detection, but traditional static analysis has a relatively high false positive rate of the vulnerability in contract detection. This invention combines static analysis with symbolic analysis, and further performs symbolic analysis based on the results of static analysis to complete the verification and screening of the vulnerability, greatly giving play to the characteristics and advantages of each technology and improving the detection effect and accuracy of the vulnerability. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only preferred embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0021] Figure 1 This is a flow chart of a smart contract security audit method based on symbolic abstract analysis of the present invention;
[0022] Figure 2 It is a flowchart of static analysis of a smart contract security audit method based on symbolic abstract analysis of the present invention;
[0023] Figure 3 The present invention is a flowchart of symbolic analysis of a smart contract security audit method based on symbolic abstract analysis. DETAILED DESCRIPTION
[0024] In order to better understand the technical content of the present invention, specific embodiments are provided below, and the present invention is further described in conjunction with the accompanying drawings.
[0025] See also Figures 1 to 3 The present invention provides a smart contract security audit method based on symbolic abstract analysis, comprising the following steps:
[0026] S1: Input the contract source code to be tested and generate a static test file through the contract compiler;
[0027] S2: traverse the static detection file to generate a control flow graph file CFG and collect contraction information;
[0028] S3: The flowchart file CFG is converted into a single assignment statement text SSA using the contract information, modeling and analyzing the single assignment statement text SSA is performed, and contract attribute information is traversed and collected;
[0029] S4: Integrate the contract attribute information as input, perform vulnerability detection strategy search, and generate vulnerability type and vulnerability location;
[0030] S5: Use the vulnerability type and the vulnerability location as input to the symbolic analysis engine, query the basic block where the vulnerability is located, and the symbolic analysis engine analyzes the vulnerability type and the vulnerability location, traces the execution path of the vulnerability, and uses the vulnerability location as the end point of the problem path until the result of the problem path is found. The analysis of the problem path ends, and the verification and screening of the generated vulnerability type and vulnerability location are completed. The input value refers to the input parameter set according to the type analysis set by the code. If the code requires an integer parameter, the input value of the symbolic analysis is an integer number. If the code requires a string, the input value of the symbolic analysis is a string. If the result is found, it is determined that the vulnerability exists. If the result is not found, it is determined that the vulnerability is a false alarm, and the vulnerability location is eliminated. The vulnerability detection work is performed by combining static analysis with symbolic analysis. Compared with the traditional use of single static analysis or symbolic analysis, it has higher scalability and coverage. In order to solve the problems such as the rapid iteration of contract language and the generation of new vulnerabilities leading to reduced vulnerability detection efficiency, modular design can be used to upgrade and iterate on the original basic framework without affecting the original function, thereby enhancing the coverage of contract detection. In the multiple conversions of the static analysis contract source code, key information reflecting the vulnerability will be collected. Combined with the characteristics of the contract attribute information, the contract will be modeled and analyzed to maximize the approximate structure and attributes of the real contract, achieve a more fine-grained detection accuracy, and integrate the detection strategies of each vulnerability detection mode to achieve accurate vulnerability scanning. Static analysis has the advantages of fast speed and wide detection range in the vulnerability detection, but the traditional static analysis has a high false positive rate of the vulnerability false alarm during contract detection. The invention combines static analysis with symbolic analysis, further performs symbolic analysis on the basis of the results of static analysis, completes the verification and screening of the vulnerability, and greatly gives play to the characteristics and advantages of each technology, and improves the detection effect and accuracy of the vulnerability.
[0031] Specifically, in S1, the static detection file includes an abstract syntax tree file AST in Json format.
[0032] Specifically, in S2, the contract information includes the contract storage status, data dependency, whether to inherit and authority definition. The flowchart file CFG is converted into a single assignment statement text SSA using the contract storage status, the data dependency, whether to inherit and the authority definition.
[0033] Specifically, in S3, the contract attribute information includes the flowchart file CFG, function jump relationship, contract storage status, data dependency, inheritance and permission definition. In the multiple conversions of the static analysis contract source code, key information reflecting the vulnerability will be collected, and the contract will be modeled and analyzed based on the characteristics of the flowchart file CFG, function jump relationship, contract storage status, data dependency, inheritance and permission definition, to maximize the approximation of the real structure and properties of the contract and achieve more fine-grained detection accuracy.
[0034] Specifically, in S4, the vulnerability detection strategy includes that the developer needs to design the detection mode in combination with the current status of a specific vulnerability principle or contract language update, complete the writing and updating of the vulnerability detection, detect the contract attribute information according to the design of the detection mode and the implementation of the code, and generate the vulnerability type and the vulnerability location. The vulnerability can be an integer overflow, a reentrancy attack, or a short address attack.
[0035] Specifically, in S5, the result is the input value obtained by constraint solving or exceeds the predetermined time. If the input value is found, the vulnerability is determined to exist. If the input value is not found, that is, exceeds the predetermined time, the smart contract is determined to be a false alarm, and the vulnerability location is removed.
[0036] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principle of the present invention should be included in the protection scope of the present invention.
Claims
1. A smart contract security audit method based on symbolic abstract analysis, It is characterized in that The steps include: S1: Input the contract source code to be tested and generate a static test file through the contract compiler; S2: traverse the static detection file to generate a control flow graph file CFG and collect contraction information; S3: The flowchart file CFG is converted into a single assignment statement text SSA using the contract information, the single assignment statement text SSA is modeled and analyzed, and contract attribute information is traversed and collected. The contract attribute information includes the flowchart file CFG, function jump relationship, contract storage status, data dependency, inheritance and authority definition; S4: Integrate the contract attribute information as input, execute vulnerability detection strategy search, generate vulnerability type and vulnerability location, the vulnerability detection strategy includes that the developer needs to combine the current status of a specific vulnerability principle or contract language update, implement the design of the detection mode, complete the writing and updating of the vulnerability detection, detect the contract attribute information according to the design of the detection mode and the implementation of the code, and generate the vulnerability type and the vulnerability location; S5: Use the vulnerability type and the vulnerability location as input to the symbolic analysis engine, query the basic block where the vulnerability is located, the symbolic analysis engine analyzes the vulnerability type and the vulnerability location, traces the execution path of the vulnerability, and uses the vulnerability location as the end point of the problem path until the result of the problem path is found. End the analysis of the problem path and complete the verification and screening of the generated vulnerability type and vulnerability location. The input value refers to the input parameter set according to the type analysis set by the code. If the code requires an integer parameter, then the input value of the symbolic analysis is an integer number. If the code requires a string, then the input value of the symbolic analysis is a string.
2. According to claim 1, a smart contract security audit method based on symbolic abstract analysis, It is characterized in that In S1, the static detection file includes an abstract syntax tree file AST in Json format.
3. According to claim 1, a smart contract security audit method based on symbolic abstract analysis, It is characterized in that In S2, the contract information includes contract storage status, data dependency, whether it is inherited and authority definition.
4. According to claim 1, a smart contract security audit method based on symbolic abstract analysis, It is characterized in that In S5, the result is an input value obtained by constraint solving or exceeds a predetermined time.
