header-langage
简体中文
繁體中文
English
Tiếng Việt
Scan to Download the APP
Partnered With:

IOSG Ventures: Is there an opportunity to commercialize smart contract security analysis tools?

Read this article in 31 Minutes
For the DeFi project side, the insurance business of DAO or personal service may become the next blue ocean.
Original title: "IOSG Weekly Brief | Is there an opportunity for the commercialization of smart contract security analysis tools?" #151"
Original author: Ray Xiao, Sally Gu, IOSG Ventures  


Foreword:< /h4>


At the end of September, Paradigm officially announced the completion of the lead investment of the blockchain security project Blowfish, which once again aroused widespread attention in the field of smart contract security analysis. But in fact, the Paradigm team has done a lot of practice in the direction of smart contract security testing before this. In March this year, Paradigm CTO Georgios announced the Foundry smart contract test suite developed by them (the Runtime Verification team is also an important contributor). Blockchain security analysis is also developing towards a more detailed division of labor.


image


From the perspective of financing trends and market reactions in recent months, primary market capital At present, there is a strong interest in the field of security monitoring, which focuses on the timeliness of security information, risk coverage, and lightweight technology, and firewalls (this is very different from most capital investment in the audit field in the past).


According to relevant reports from CertiK and SlowMist, the loss of crypto assets due to security attacks in the first and second quarters of 2022 alone will reach as high as $2 billion. Flash loan attacks alone resulted in a total of $300 million in asset losses in Q2. And this month has become the largest month of hacking activities in history. In two weeks, there have been more than 12 attacks on DeFi protocols alone, and the amount stolen has exceeded 700 million US dollars.


imageSource: https://twitter.com/chainalysis/status/1580312145451180032?s=2 0&t= QfqOMqMKjHd3EtX_0O-QjA


If we regard smart contracts on the chain from development>>deployment to blockchain network>>running as a complete life In terms of cycles, the security analysis of smart contracts is divided into: analysis before contract deployment (before the blockchain network is officially launched), and analysis after contract deployment, which roughly covers three categories: testing, auditing, and monitoring , there are various types of analysis methods and corresponding tools under each category (as shown in the figure below). PS: The audit coverage of smart contracts will be from pre-deployment to post-deployment (contract upgrade audit)


image


1. Security analysis before smart contract deployment: testing + audit


1.1 Testing


Contract testing is the work that developers and auditors need to spend the most energy on, which is different from traditional developers. Because of the non-tamperable nature of the blockchain, once the smart contract is deployed on the EVM virtual machine, it is difficult to change it. Therefore, most of the work of security analysis and making up for security loopholes is spent on "pre-analysis" - the security test of the smart contract before deployment.


Before accepting the formal audit, the contract developer/auditor needs to conduct some basic tests on the code of the contract. The higher the coverage of the initial test, the better Avoid some simple bugs from entering the formal audit stage (generally, it is reasonable for a smart contract to reach 85%-90% code coverage by tests; the coverage rate for core modules needs to be above 95%).


Common basic tests include unit tests (tests that focus on a single function) and integration tests (to ensure that the combination of various parts of the code can also run normally). Commonly used tools at this stage include Hardhat, Truffle test framework, etc. Common test content includes: status check, event trigger, transaction reset, function calculation, and full functional test.


image

Source: https://betterprogramming.pub/how-to-test-ethereum -smart-contracts-35abc8fa199d

 

1.2 Auditing


image


"Testing is effective in finding bugs in a program, but it cannot prove that a program is not buggy." - Edsger Wybe Dijkstra (Computer Scientist, 1972 Turing Award Winner)


According to the definition of Ethereum official documents, auditing is a detailed evaluation of each line of source code of a smart contract. Uncover possible points of failure, security holes, and poor development practices. The audit phase roughly includes: static analysis, dynamic analysis (fuzzing test, symbolic execution), manual analysis, and formal verification. As Dijkstra mentioned in the above figure, testing alone cannot completely believe that the program is free from faults. Auditing and formal verification are more about getting closer to the goal of having no defects in the program.


image


Money cost

< p>

According to data from smart contract security company Hacken, the industry average cost of smart contract audit services is between $5,000 and $30,000 (small and medium-sized projects). For large projects, costs can sometimes reach $500,000 or more. The cost of a smart contract audit is directly dependent on the code complexity and the agreed scope of work. Other factors that affect the price include the urgency, the size of the smart contract (how many lines of code), the number of engineering hours required to complete the process, the availability of documentation related to the project, etc.


Time Cost


Initial Audit Average Required 2 to 14 days, also depending on project complexity, smart contract size and urgency. For large projects or agreements, the initial review may take up to 1 month. After the initial review is complete, the client receives recommendations on which modifications to introduce.


Manpower cost


according to IOSG in the district Feedback from Runtime Verification, a leading investment project in the field of blockchain formal verification, the labor cost of auditing depends on the complexity of the protocol. For most leading security audit companies with senior industry experience and academic experience, it is basically not too difficult to understand the business logic and token economics of crypto customer projects. Generally, it takes about 1 to 2 weeks for two professional engineers Complete the initial steps.


But the next part will depend on the specific needs of the customer. Some customers only need a manual audit of the basic business logic of the audited project (looking at their code and manually reviewing whether it meets the required business logic), which is the cheapest service. Some customers want to model business logic and token economics and then manually perform mathematical proofs to ensure certain important results, such as security, liveness, consistency, etc. Some big customers like MakerDAO, Ethereum Foundation, etc. hope to go a step further and perform formal verification of the code (Formal Verification).


One more word about formal verification here, formal verification is to use mathematical methods to verify the correctness of the program - the realization of the program and the intention of the programmer It matches, and finally proves that the system of the project is Bug Free. Or in other words, formal verification is like a more comprehensive "testing", which theoretically includes all possible inputs and states, which is impossible for testing (as shown in the example below, there is an overflow bug in the transfer contract , if testing is used, the tester needs to enter a very large value to find out, but the formal verifier will find out the overflow bug through the mathematical logic of "total amount of the token = sum of the balance of all addresses")


image


In terms of actual large-scale application, formal verification is more scalable than traditional test solutions Relatively slow in use. For most crypto projects, it is enough to complete the smart contract audit. In terms of cost input and potential benefits, it is not necessary for small projects (or the cost of proving that the program is bug-free is relatively high), the core The reason is that formal verification requires the participation of professional formal talents, because it is very complicated to create a formal specification for the project code, which needs to cover the attributes of the contract code and define the behavior of the contract in different situations. Professional personnel are required to participate. (For interested readers, please refer to our previous article "Why We Lead the Runtime Verification" https://mp.weixin.qq.com/s/VWVgn4k9k0XqbM-O7-TVXg)


< /p>

image


Smart contract auditing is still a labour-intensive industry and has high technical requirements for talents. Although there are more than a dozen popular audit tools on the market (mostly developed by mainstream security audit companies or academic researchers), the purpose of these audit tools is to find common vulnerabilities. For example: transaction order dependency, random number, timestamp, callstack depth, Reentrancy, dangerous delegate call, etc.). Therefore, it is more difficult to rely on these tools to complete the audit work, and many loopholes related to business logic may be missed. Usually, reviewing smart contracts requires a combination of automated tools and manual code review, and case by case manual review is required depending on the customer's smart contract business logic and Token model.


Smart contract security analysis and audit is often to verify the correctness of the program, that is, the implementation of the program is consistent with the programmer's intention. Because the bugs in the program are actually caused by the difference between the implementation of the program and the intention of the programmer. The formal semantics mentioned in the article we shared our investment in Runtime Verification before is actually a language framework that allows developers to precisely match their development intentions (that is, "semantics") and implementation (that is, the "grammar" of programming languages), so that Reduce the occurrence of bugs.


In the field of smart contract security auditing, although there are many tools on the market, and most of them are open source, very few of them have been successfully commercialized. The root cause will be analyzed later. In short, at present, it still relies on the security service provider's own automation tools + manual reading of each line of code or modeling, and it is basically impossible to obtain large-scale commercial income by directly selling automated audit tools.


image


PS: According to the feedback from Hexens, which we led recently, some static analysis Testing Slither and MythX are their commonly used open source tools, although the results did not make them very satisfied. For higher-level testing, they mainly use fuzzers such as Echidna, Forge+built in fuzzer


2. Security analysis after smart contract deployment - Monitoring (Monitoring )


Currently among the 10 most common blockchain network security attacks, Scam has the highest frequency of occurrence, and directly causes the highest asset loss to users. According to Peckshield's data, in 2021, crypto's on-chain economic losses due to various scams will reach 12 billion US dollars, which is 6.7 times higher than the losses caused by direct attacks by hackers.


image


Common scam attacks:


Phishing (common phishing technique is sending emails/websites asking users to reset their passwords/recover their accounts. Once users log into these fake websites, they steal private keys )


Case: Alice logs in to a trading platform and links to the MetaMask wallet, and receives a pop-up window indicating that the wallet is faulty and needs to be restored with mnemonic words. After restoration, the assets in the wallet are deleted All stolen.


Impersonation/Impersonation (persons claiming to be employees or representatives of certain dapps/institutions may Media contacts users. They will steal funds from users by sending fake free mint/airdrop sites. Or manipulate victims by impersonating to extract funds or sensitive data)


Case: The Ukrainian government accepts cryptocurrency donations and announces an airdrop of NFT. The impostor pretends to be the Ukrainian government and issues a fake token airdrop to defraud.


Discord Admin Identity Hijacking (An attacker controls a bot trusted by the community to post false announcements, scam links, or spoof Victims give up their cryptocurrency or NFT)


Case: Hackers send wrong links to members in batches by controlling blue-chip NFTs such as discord official servers such as Bored Ape Yacht Club , the asset will be irreversibly stolen after the user clicks


BGP hijacking (by falsely claiming to have an IP prefix that is not actually controlled , and add it to the routing table in the Internet BGP router, the attacker can hijack the traffic of this IP address, in this case, once the user tries to log in, it will be redirected to the trap address set by the attacker)


Case: Celer was attacked by BGP hijacking, affecting 32 users and $235,000 in losses (2022.08)


Code Backdoor & Trap (The attacker hides a piece of malicious code with special functions in a normal program, such as destroying and deleting files, sending passwords, recording keystrokes and DDoS attacks and other special function backdoor programs to steal users’ personal information)


Case: Bob mint an NFT on a certain website, and found that it disappeared two days later. Because the attacker implants certain features in the NFT code, he can authorize others to conduct NFT transactions or destroy other people's NFTs, and cannot place orders, etc.


image


Front-end malicious code (The attacker will Malicious code is implanted into the front end of websites such as trading platforms, such as the tab management system of user browsers, so that false approvals are generated through this string of malicious codes, allowing user assets to be transferred to the attacker's address)

< br>

Case: KyberSwap lost 2.56 million US dollars due to the malicious front-end planted by hackers (2022.09)


Common tools:


Compared with smart contract security audit, the business content involved in providing monitor&firewall service is more complicated and detailed.


Focus upgrades smart contract code security audits before and after contract deployment, often through various types of tests (static analysis, dynamic analysis) to input a series of value to see if the output value and status of the contract are running normally. For example, for a common chain transfer logic (as shown in the figure below), common testers will do: transfer zero ether, transfer all the ether, transfer slightly more than all the ether, transfer the largest possible amount of ether, transfer an account's value to itself and other things to see whether the contract can do what the programmer expected to do and achieve the results.


Focus' monitor/firewall service for safety analysis in the event has more complicated problems to deal with. And at present, it seems that the security services provided by such projects pay more attention to breadth (covering as many problematic asset contracts on the chain as possible, the latest addresses contract phishing URLs suspected of fraudulent behavior, etc.), they are compared with the security services of contract auditing More lightweight. It involves many security risks other than checking code correctness, such as various types of fraud and phishing-related attacks. In addition to relying on contract analysis capabilities, the monitoring of these vulnerabilities also requires constant updating of the risk database of data such as suspicious addresses, suspicious contract logic, and suspicious asset lists.


image


Through our recent exchanges with practitioners in the industry, It is found that the positioning of different Monitor services is actually different. For example, GoPlus pays more attention to providing data API services to project parties and even some front-end firewalls; Harpie and Blowfish pay more attention to providing front-end services. When a user performs a transaction or completes a transaction Simulate this transaction before authorizing to find problems and prevent users from transactions with security risks; Tenderly pays more attention to the needs of developers and provides services such as operation monitoring for smart contract developers. Of course, this field is still relatively new at present, although large companies like Opensea The trading platform has already carried out substantive commercial cooperation with some projects, but we believe that the path of commercialization in the future is still unclear and there will be considerable competition in the same industry (because the technical threshold will be lower compared to code auditing).


3. Business development opportunities and challenges of smart contract security analysis tools


1) Currently Many people in the industry think that the business boundary between monitoring&firewall and security auditing is still relatively blurred (now they all belong to 2B services, and most of the customers are various crypto project parties). It is more in line with business development logic for professional security audit companies that have been deeply involved in the security field for many years to directly provide monitoring services, and even develop B2C and 2C products that directly benefit end users. However, since the monitoring track has just started, the charging model and profit model are still unclear ( At present, it is seen that 2B extracts service fees or project transaction fees), if the market picks up, the security audit market will still be in supply > demand, and the state of endless orders may not have time to take care of this emerging market. This time window will be for A new company that specializes in monitor/firewall is a great opportunity.


2) There are already many automated tools for smart contract auditing on the market. Common There are more than a dozen kinds of open source. The business model of selling tools to charge in this direction has not yet worked out. The core reason is:


The game relationship between hackers and security defenders It is an arms race and the attack is always a moving target. The magic height is one foot high. Once the security tool is released, hackers will try to bypass it and develop new attack forms. Therefore, security tools can only be updated iteratively Raise the threshold of attack; the threshold of most tools is not low, and there are few people who can use professional security analysis tool products, so the market size is limited (although Runtime Verification has Firefly, which is being promoted to ordinary developers, and ConsenSys Dilligence also has MythX; security Analysis tools can only cover mainstream vulnerabilities, and different customers based on the economic model of the protocol business logic prefer that the audit team manually provide customized services.


The team subjectively also hopes that an audit company authorized by the market will provide a more in-depth customized audit service and stamp it. Therefore, providing monitoring service will be a good opportunity for professional security teams to enter scalable products.    


3) As a defi project party, the insurance business of DAO or personal service may become the next blue ocean. Considering that the current market does not have good defenses or solutions for hackers directly stealing private keys and other attack methods, the insurance business for the purpose of risk avoidance and asset protection is likely to be more favored in the future.


Of course, considering the complexity of encrypted assets and multiple uncertainties in compliance, underwriters tend to bear greater risks, so in solving this Before the problem, it is foreseeable that the development of the insurance industry will still face certain bottlenecks. It is expected that with the increase in the overall volume of encrypted assets and the entry of more traditional institutional users, the insurance business can achieve more institutional improvements before the next cycle.

 

Reference:
https://www.paradigm.xyz/2022/03/foundry-02
https ://www.coindesk.com/business/2022/09/30/paradigm-leads-118m-funding-round-into-web3-firewall-blowfish/
https://ethereum.org/ en/developers/docs/smart-contracts/testing/
https://docs.openzeppelin.com/learn/writing-automated-tests
https://iamdefinitelyahuman.medium .com/an-in-depth-guide-to-testing-ethereum-smart-contracts-2e41b2770297
https://betterprogramming.pub/how-to-test-ethereum-smart-contracts-35abc8fa199d


Original link


Welcome to join the official BlockBeats community:

Telegram Subscription Group: https://t.me/theblockbeats

Telegram Discussion Group: https://t.me/BlockBeats_App

Official Twitter Account: https://twitter.com/BlockBeatsAsia

举报 Correction/Report
Choose Library
Add Library
Cancel
Finish
Add Library
Visible to myself only
Public
Save
Correction/Report
Submit