Introduction
We express our gratitude to the Venus team for the collaborative engagement that enabled the execution of this Smart Contract Security Assessment.
Venus is a decentralized finance (DeFi) algorithmic money market protocol on BNB Chain. Decentralized lending pools are very similar to traditional lending services offered by banks, except that they are offered by P2P decentralized platforms. Users can leverage assets by borrowing and lending assets listed in a pool. Lending pools help crypto holders earn a substantial income through interest paid on their supplied assets and access assets they don't currently own without selling any of their portfolio.
title | content |
---|---|
Platform | EVM |
Language | Solidity |
Tags | Lending/Borrowing |
Timeline | 17/05/2023 - 28/06/2023 |
Methodology | https://hackenio.cc/sc_methodology→ |
Review Scope | |
---|---|
Repository | https://github.com/VenusProtocol/venus-protocol→ |
Commit | cf6b8cb0735cf0ded3435161c6ea2e2d6c4b48e4 |
Review Scope
- Commit
- cf6b8cb0735cf0ded3435161c6ea2e2d6c4b48e4
Audit Summary
10/10
67.02%
10/10
10/10
The system users should acknowledge all the risks summed up in the risks section of the report
Document Information
This report may contain confidential information about IT systems and the intellectual property of the Customer, as well as information about potential vulnerabilities and methods of their exploitation.
The report can be disclosed publicly after prior consent by another Party. Any subsequent publication of this report shall be without mandatory consent.
Document | |
---|---|
Name | Smart Contract Code Review and Security Analysis Report for Venus |
Audited By | Hacken |
Website | https://venus.io/→ |
Changelog | 24/05/2023 - Initial Review |
28/06/2023 - Second Review |
Document
- Name
- Smart Contract Code Review and Security Analysis Report for Venus
- Audited By
- Hacken
- Website
- https://venus.io/→
- Changelog
- 24/05/2023 - Initial Review
- 28/06/2023 - Second Review
System Overview
Venus Protocol (“Venus”) is an algorithmic-based money market system designed to bring a complete decentralized finance-based lending and credit system.
Venus enables users to utilize their cryptocurrencies by supplying collateral to the network that may be borrowed by pledging over-collateralized cryptocurrencies. This creates a secure lending environment where the lender receives a compounded interest rate annually (APY) paid per block, while the borrower pays interest on the borrowed cryptocurrency.
The Venus Protocol has been designed to give platform users a decentralized and secure marketplace to take out loans, earn an interest, and mint synthetic stablecoins.
The files in the scope:
RouterHelper.sol - The Abstract contract facilitates various token swaps, either for tokens supporting fees or not, and provides library functions to determine transaction specifics.
IRouterHelper.sol - The interface of RouterHelper.
SwapRouter.sol - The contract contains various functions for token swaps, including supporting multiple swap routes. Users can swap tokens and, in the same transaction, supply to any market of Venus or repay their debt in any market of Venus.
CustomErrors.sol - The error handling contract.
PancakeLibrary.sol - The library contract provides the necessary functionality for the swap operation. It manages token sorting, pair address calculation, and token amount conversions.
TransferHelper.sol - The library contract provides methods for interacting with ERC20 and ETH tokens, as well as for safely sending them.
InterfaceComptroller.sol - The interface of Comptroller contract.
IPancakePair.sol - The interface of PancakePair contract.
IPancakeSwapV2Factory.sol - The interface of PancakeSwapV2Factory contract.
IPancakeSwapV2Router.sol - The interface of IPancakeSwapV2Router contract.
IVBNB.sol - The interface of VBep20 contract.
IVtoken.sol - The interface of VToken contract.
IWBNB.sol - The interface of VBep20 contract.
Privileged roles
SwapRouter.sol:
onlyOwner privilege roles:
sweepToken()
method caller: can withdraw ERC20 token from the contract.setVBNBAddress()
: set the VBNB token address.
Executive Summary
Documentation quality
The total Documentation quality score is 10 out of 10.
Functional requirements are provided.
Technical description is provided.
NatSpecs are very good.
Code quality
The total Code quality score is 10 out of 10.
The development environment is configured.
The order of the functions does not follow the style guide perfectly, but the exceptions make sense.
Test coverage
Code coverage of the project is 67.02%.
Deployment and basic user interactions are covered with tests.
Negative cases coverage is missed.
Some functions are not tested.
Interactions by several users are not tested thoroughly
Security score
Upon auditing, the code was found to contain 0 critical, 1 high, 2 medium, and 3 low severity issues. Out of these, 5 issues have been addressed and resolved, leading to a Security score of 10 out of 10.
All identified issues are detailed in the “Findings” section of this report.
Summary
The comprehensive audit of the customer's smart contract yields an overall score of 8.7. This score reflects the combined evaluation of documentation, code quality, test coverage, and security aspects of the project.
Risks
The protocol provides the possibility to repay a loan from the Venus market and to supply tokens to the Venus market. By doing that, the system interacts with other contracts that are out of the scope of this audit.
Findings
Code ― | Title | Status | Severity | |
---|---|---|---|---|
F-2023-0792 | Missing Swap Path Validation | fixed | High | |
F-2023-0794 | Unverifiable Logic | mitigated | Medium | |
F-2023-0793 | Mishandled Edge Case | fixed | Medium | |
F-2023-0797 | Redundant Check | fixed | Low | |
F-2023-0796 | Boolean Equality | fixed | Low | |
F-2023-0795 | Missing Zero Address Validation | fixed | Low | |
I-2023-0202 | Copy of Well-Known Contract | unfixed | Observation | |
I-2023-0201 | Public Functions That Should Be External | fixed | Observation | |
I-2023-0200 | Floating Pragma | fixed | Observation | |
I-2023-0199 | SPDX License Identifier Not Provided | fixed | Observation |
Identify vulnerabilities in your smart contracts.
Appendix 1. Severity Definitions
When auditing smart contracts, Hacken is using a risk-based approach that considers Likelihood, Impact, Exploitability and Complexity metrics to evaluate findings and score severities.
Reference on how risk scoring is done is available through the repository in our Github organization:
Severity | Description |
---|---|
Critical | Critical vulnerabilities are usually straightforward to exploit and can lead to the loss of user funds or contract state manipulation. |
High | High vulnerabilities are usually harder to exploit, requiring specific conditions, or have a more limited scope, but can still lead to the loss of user funds or contract state manipulation. |
Medium | Medium vulnerabilities are usually limited to state manipulations and, in most cases, cannot lead to asset loss. Contradictions and requirements violations. Major deviations from best practices are also in this category. |
Low | Major deviations from best practices or major Gas inefficiency. These issues will not have a significant impact on code execution, do not affect security score but can affect code quality score. |
Severity
- Critical
Description
- Critical vulnerabilities are usually straightforward to exploit and can lead to the loss of user funds or contract state manipulation.
Severity
- High
Description
- High vulnerabilities are usually harder to exploit, requiring specific conditions, or have a more limited scope, but can still lead to the loss of user funds or contract state manipulation.
Severity
- Medium
Description
- Medium vulnerabilities are usually limited to state manipulations and, in most cases, cannot lead to asset loss. Contradictions and requirements violations. Major deviations from best practices are also in this category.
Severity
- Low
Description
- Major deviations from best practices or major Gas inefficiency. These issues will not have a significant impact on code execution, do not affect security score but can affect code quality score.
Appendix 2. Scope
The scope of the project includes the following smart contracts from the provided repository:
Scope Details | |
---|---|
Repository | https://github.com/VenusProtocol/venus-protocol→ |
Commit | cf6b8cb0735cf0ded3435161c6ea2e2d6c4b48e4 |
Whitepaper | Provided→ |
Requirements | Not provided |
Technical Requirements | Provided→ |