Part of Quantstamp’s series
Quantstamp reviewed Venus Protocol (Venus Income Allocation) on 12 Oct 2023: 12 findings, 0 critical; 2 marked fixed, 10 acknowledged; 2 more marked mitigated.
Report hosted on certificate.quantstamp.com.
Trustblock does not review code.
Statuses are the security firm’s own, from its report.
| Severity | Open | Acknowledged | Fixed | Mitigated |
|---|---|---|---|---|
| Critical | 0 | 0 | 0 | 0 |
| High | 0 | 0 | 0 | 0 |
| Medium | 0 | 2 | 0 | 0 |
| Low | 0 | 8 | 2 | 2 |
During the `_releaseFund()` function call, `DistributionConfig`s are iterated over, and the funds are divided between the provided addresses via an ERC20 transfer. After the ERC20 token transfer, the `updateAssetsState()` method of `IIncomeDestination` is invoked, so that the tokens are accounted for correctly. The issue arises from the fact that the method is called on an arbitrary contract at the address `_config.destination`, which is added to the array. Therefore, if an address is added that does not have the `updateAssetsState()` method implemented, this call will revert; hence, every call to `_releaseFund()` will revert, and the contract will not be usable, as it is not possible to remove items from the distribution array.
`updateAssetsState()` function is usually called when a transfer of ERC20 assets has been made to the contract. It can also be called by any user of the platform. The idea behind this function is to account for newly transferred ERC20 tokens by taking the difference between the current balance of the contract and the accounted balance of the contract. It is assumed that there should be no case where the `currentBalance` will be less than the already accounted `assetReserve`. This is not strictly the case, as if the asset is a rebasing token such as Ampelforth, the number of tokens in the contract balance will vary depending on the current market conditions and the underlying peg-keeping algorithm. These types of balance changes are also common in other types of non-standard tokens. When `releaseFunds()` is called with the correct parameters, the income of such rebasing token would be distributed based on the last `updateAssetsState()` balance, which might not be the same as the current contract balance and could be potentially lower than the `schemaBalances` accounted balance. Leading to an issue where the last transfer will fail due to insufficient funds in the contract.
The contract has a function with `setProtocolShareReserve()` functionality that allows to set a new address for the `protocolShareReserve` contract. There are similar implementations of setters in the contract, but the main difference is that the new address is verified by a call to a `is<ExpectedContract>()` call, where Expected Contract is, for example, Comptroller. This is not the case for the `protocolShareReserve` contract. Hence, it is possible for the new address not to be the expected contract and not to have an `updateAssetsState()` method implemented. This would lead to `_reduceReservesFresh()` failing on every call in the `VToken` context and hence the DoS of the usability of the contract, as the method would not exist and revert. In the context of `vBNBAdmin`, the function failing would be `reduceReserves()`. This issue affects both the `VToken` contract implementations and the `vBNBAdmin` contract.
During the `_releaseFund()` call, the correct distribution patterns are applied to the collected ERC20 Income. The income is divided as a percentage between previously allocated addresses. The `transferAmount` is calculated via the following formula: ``` uint256 transferAmount = (schemaBalances[uint256(_config.schema)] * _config.percentage) / MAX_PERCENT ``` The division operator could lead to rounding errors, and hence, it is possible that the total transfer amount might not add up to the exactly expected `totalBalance`. These leftover ERC20 tokens will be returned to the `assetsReserves` and reallocated at the next round, but potentially under a different allocation scheme. Hence, the users entitled to them might not receive them in the next allocation.
The idea of the `ProtocolShareReserve` contract is to accumulate income from ERC20 tokens and distribute it in the expected patterns between different addresses. It is not expected for the contract to receive native tokens, hence the absence of `payable` functions or the `receive()` method. The EVM currently still supports the `SELFDESTRUCT` opcode. It is used to terminate a contract, remove the bytecode from the blockchain, and send any contract funds to a specified address. This transfer cannot be rejected, so if another contract self-destructs and points to `ProtocolShareReserve` as the recipient, then the contract will be funded from an unexpected source. This issue is also applicable to the `vBNBAdmin` contract, as the specifications of the contract state that BNB tokens should only be received from the associated `vBNB` contract. Currently, the `receive()` function is protected with a required statement that only accepts funds from the `vBNB` contract. But with the issue described above, it is still possible to receive native tokens not from the expected source.
During the `addOrUpdateDistributionConfigs()` function, it is possible to add a distribution config with a zero percentage. This would mean that no funds would be sent to that address, but the address would still be iterated over, hence wasting gas.
The `_ensureMaxLoops()` check is only used once in `addOrUpdateDistributionConfigs()` to limit the number of iterations through the distribution targets. It is not used to check other loops in the contract, such as the number of configs being added or updated, the number of assets used in `releaseFunds()`, the number of markets in `_accrueAndReleaseFundsToPrime()` and `_accruePrimeInterest()`, and the number of schemas or distribution targets in `_releaseFund()`. The absence of these checks could lead to a potential gas issue and the transaction failing.
In both `VToken` contracts, the values for `reduceReservesBlockDelta` and `protocolShareReserve` are not set during initialization. This could cause unintended behavior at the time of deployment.
The core pool's `VToken._reduceReservesFresh()` function can return a non-zero error code to indicate any failures during its execution. However, in the `accrueInterest()` function, when `_reduceReservesFresh()` is called, the returned error code is unhandled. Therefore, even though an error occurs during the execution of `reduceReservesFresh()`, the `accrueInterest()` function continues to execute, returning a `uint(Error.NO_ERROR)` to indicate that no errors have occurred. External contracts may incorrectly assume that `_reduceReservesFresh()` has executed successfully based on the `Error.NO_ERROR` return value.
Some of the contracts audited are upgradeable, and their functionality may be changed by privileged roles in the future.
The report names a repository or files. Open the report to see its scope.
Repository and files the report names (3)
240 projects reviewed · 338 reports · latest Nov 2026
See Quantstamp’s auditsSomething wrong on this page? A missing report, a wrong date, a finding that was fixed since. Tell us and we check it against its source.
Tell us