In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Network Security >
Share
Shulou(Shulou.com)06/01 Report--
Write at the beginning
When I am writing this article, it has been three days since the EOS loophole was exposed, and the hot spots in the blockchain industry come and go quickly, and whenever there are security-related problems, it will bring shock to the whole industry. Since I began to pay attention to the blockchain industry, security incidents have increased unabated, and trading platforms, intelligent contracts, consensus mechanisms and so on have all become the center of security incidents.
But in recent years, smart contracts have obviously been targeted. From THE DAO the year before last to BEC this year. At the same time, there are many different voices on the Internet. Some people applaud the ingenuity of smart contracts, while others say bad things about the security of smart contracts. This article will not discuss the advantages and disadvantages of the intelligent contract itself, but only focus on how to ensure the safety of the intelligent contract. Welcome to leave a message for discussion.
Part one: the basic principles of intelligent contract
The essence of intelligent contract is a piece of code running in the blockchain network, which completes the business logic given by the user. Popularly speaking, it is equivalent to an "unchangeable" and "fair"middleman". For example, I'll make a bet with you that if it rains tomorrow, I win. If it doesn't rain tomorrow, you win. Then when we bet, we put the money into an account controlled by the intelligent contract. The next day passed, and after the result of the intelligent contract came out, the intelligent contract could automatically judge whether to win or lose according to the instructions received and transfer the money. This process is efficient and transparent, and does not require the intervention of third parties such as justice.
For example, we are familiar with Ethernet Square, whose intelligent contract business logic is tokens issuing and trading. At the beginning of its design, Ethernet Square designed the smart contract to be a pattern that cannot be modified once deployed. This design is designed to improve the credibility of smart contracts. But as long as the program is written by people, there will inevitably be loopholes. Therefore, when there is a loophole, want to recover the loss is very big.
Part II: intelligent contract security
As mentioned earlier, a smart contract is essentially a piece of code that cannot be modified after release. If a serious loophole is found after the release, the new contract can only be redeployed, which is too costly for the manufacturer. So if you want this piece of code to be safe, you must audit the smart contract before it is released. In addition to requiring third-party code audits, teams also have ways to improve the security of smart contracts during the development process.
1. The code must be tested!
two。 The code must be review!
Don't underestimate these two simple points, the vast majority of code problems can be found in the process. Below I put the White Hat Security Institute's advice on how to avoid developing business layer code security issues. If necessary, you can do a review of your code one by one.
1. Try to avoid external calls to
two。 Carefully weigh the code logic when another important operation occurs to avoid logic pitfalls
3. Handle external call error
4. Don't assume that you know the control flow of external calls.
5. Mark untrusted business content
6. Correct use of assertion
7. Be careful of rounding for integer division
8. Do not assume that the balance is zero when the business is created
9. Remember that the data on the chain is public
10. In business applications in which two or more parties participate, participants may not return after being "offline"
11. Clearly indicate the visibility of functions and state variables
twelve。 Lock a program to a specific compiler version
13. Be careful that the denominator is zero
14. Distinguish between function and event
15. Avoid endless cycle
16. Upgrade the problematic business layer code
In addition to your own review of the code, it is also necessary to ask a third-party security organization to review it. Strictly speaking, intelligent contract audit should have a very standardized process. In half of the cases, at least the following four points are reviewed:
1. Function visibility audit
two。 Contract restrictions bypass audit
3. Call stack exhaustion audit
4. Denial of service audit
Through the examination of these four points, at least the problems of privacy disclosure, transaction overflow and exception, contract failure and denial of service can be solved. Greatly reduce the security risks brought by smart contracts.
Part III: third-party intelligent contract audit
At present, there are not many security companies that provide intelligent contract audit and code audit. I have collected from some newsletters I usually read, listing several well-known security manufacturers that are doing intelligent contract audit for your reference.
Know Chuangyu: provide contract code review service and cloud defense service for Firecoin and Bit-Z.
Slow Fog Technology: provide node security deployment and security audit for EOS.
It is reported that after the EOS vulnerability was exposed, it began to participate in the code audit.
White hat: I don't know who to cooperate with at present.
Write at the end
This paper only makes a very superficial analysis of intelligent contract and intelligent contract audit. And block chain industry security issues are involved in all aspects. Smart contracts are only a small part of it. We will continue to write about other security issues in the blockchain industry. Welcome to discuss them together.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.