views
With DeFi smart contracts leading the cat of blockchain hacks in 2021, over $1.3 billion worth of cryptocurrencies have been lost to exploits, scams, and hacks. These massive losses can be attributed to unverified contracts, hasty forks, outright scams, and more. But according to the Certik DeFi security report, smart contract audit services the majority of operated projects are unaudited.
In this article, we are going to look at what smart contracts are, how to protect them from bad market players.
We will also look at some smart contract auditing companies and their areas of interest.
Smart contract attacks
Smart contracts are self-executing lines of code that obey instructions defined on the blockchain network. These contracts allow users to conduct trustless and transparent transactions on the blockchain without the need for a central authority or any legal system.
Due to their utility, they have become the building blocks of complex decentralized applications, such as in DeFi and DExs, ICOs, voting protocols, and supply chain management.
As clever as they may seem, they can lead to huge losses if any security flaws or bugs are found in the code.
In general, the smart contract can perform the functions for which it was designed, but the presence of a flaw allows hackers to create codes that can interact with the smart contract to embezzle funds.
- A good example is the recent Qubit Finance attack, where the hacker exploited its cross-chain bridge and stole 206,809 BNB tokens, or around $80 million.
- Another historical example is the DAO hack in 2016, which resulted in a loss of $50 million.
Known or Standard Smart Contract Vulnerabilities
Race Conditions : When events do not occur in the expected order. In Smart Contracts, Race Conditions can occur when external contracts take control of the control flow.
Reentrancy : In this case, smart contract audit a function is called repeatedly before the first invocation of the function is completed. One of the crucial solutions is to block concurrent calls in certain functions, especially when reviewing external calls.
Cross-function Race Conditions : describes a similar attack of two functions sharing the same state, with the same solutions.
Trade Order Dependency (TOD) / Forward Run: is another race condition that affects the order of transactions in a block. By manipulating the order of transactions, one user benefits at the expense of another.
Oracle Manipulation : This type of attack is associated with smart contracts that rely on external data as input. If the input data is incorrect, it is still entered and executed automatically. Protocols relying on oracles that have been hacked, deprecated, or have malicious intent could have disastrous effects on any processes that rely on them.
Attack by short address/parameter: This type of attack is associated with EVM. It occurs when the smart contract accepts incorrectly populated arguments. Thus, attackers can exploit poorly encoded clients by using specially crafted addresses to trick them into encoding arguments incorrectly before including them in transactions.
Smart contract audit
As with ordinary code auditing, the security of a smart contract is directly proportional to the robustness and quality of the deployed code. It involves an in-depth examination and analysis of the code of a smart contract. To do this, smart contract auditors check for common errors, known host platform errors, and simulate attacks on the code. Developers (usually external smart contract auditors) are then able to identify errors, potential bugs, or security vulnerabilities in the project’s smart contract.
This service is of paramount importance in the blockchain industry, as deployed contracts cannot be changed or are irrevocable. Any defect will most likely render the contract dysfunctional or subject to security breaches which could lead to irrecoverable losses. These days, obtaining audit validation is an asset to gaining the trust of users.
Steps of auditing smart contracts.
1. Review the consistency between code functionality and the project white paper.
2. Check standard vulnerabilities;
3. Symbolic Analysis
4. Automated Analysis by Automated Tools (Approach 1): Tools like Truffle and Populus are used for automated code testing. This approach takes a very short time and has more sophisticated penetration compared to manual code checking. Although it also has limits of false identification and missed vulnerability.
5. Manual code and code quality review (approach 2): In this case, the code is manually reviewed by experienced developers. Although automated checks are faster, manual checks account for false identifications and missed vulnerabilities.
6. Gas usage analysis;
7. Performance optimization
8. Report preparation.
Smart Contract Audit Companies
1. CertiK : Certik was founded in 2018 and it is one of the favorites in the blockchain niche due to their transparency verification tools and proof engine which ensures top notch scalability and security. That is, their approach is primarily mathematical. The company claims to have detected over 31,000 vulnerabilities in smart contract code, verified 1,737 projects, and secured over $211 billion in digital assets.
2. Hacken: Another business offering audit services for blockchain systems like Ethereum, Tron, and EOS is Hacken. Although they don’t only offer blockchain solutions, bsc smart contract audit Hacken also offers security goods to IT businesses.
3.Quantestamp : Quantstamp is a blockchain security company with developers from major IT companies like Facebook, Google, and Apple. Quanstamp has a wide range of blockchain security tools and services including; a decentralized security network for auditing smart contracts. According to their claims, Quantstamp has protected over $200 billion in digital assets, and they have over 200 foundations and startups that have pledged their products.
4. ConsenSys: Founded in 2014, ConsenSys is a robust team of software developers, business experts, lawyers, security vendors. Its platform is based on the Ethereum ecosystem and aims to provide blockchain solutions such as product security and protection, financial infrastructure. The company has a smart contract security analysis product. ConsenSys Diligence; which provides crypto-economic analysis and automated smart contract analysis for the Ethereum chain.
5. Chain Security: provides products and services securing blockchain protocols and smart contracts. Chainsecurity is trusted by over 85 blockchains and has secured over $17 billion in digital assets. They have also partnered with PWC Switzerland to perform security reviews, build solutions that evaluate smart contracts, test and run performance metrics for smart contracts.
6. Verification of execution: Runtime verification uses the method based on runtime verification, which has increased standards compliance, wide coverage during runtime, to perform security audits on virtual machines. Runtime products and services include Smart Contract Verification, Protocol Verification, Advisory Service, Firefly, ERC20 Token Verifier, and IELE.