Venus - Allocation of Income

CertiKFiles named in the report

Audit

Part of CertiK’s series

CertiK reviewed Venus Protocol (Venus - Allocation of Income) on 12 Sep 2023: 19 findings, 0 critical; 16 marked fixed, 3 open.

No open critical findings
Open the reportOpen Venus Protocol’s security record

Report hosted on skynet.certik.com.

Trustblock does not review code.

Findings19

Statuses are the security firm’s own, from its report.

SeverityOpenAcknowledgedFixed
Critical000
High200
Medium000
Low1016
LowAccess Check Does Not Follow ConventionFixed

The function `addOrUpdateDistributionConfigs()`, takes an array of `DistributionConfig` structs as input. However, the access check does not include brackets for the input, which is the convention used if an input is an array.

LowCan Use Strict Inequality To Save GasFixed

In the function `ensurePercentages()`, the for loop iterates provided `schemaValue <= totalSchemas - 1`. However, this can instead check that the `schemaValue` is strictly less than `totalSchemas` to save gas.

LowCheck Can Optimize `_reduceReservesFresh()`Fixed

The function `_reduceReservesFresh()` is now called psuedo-automatically after the `reduceReservesBlockDelta` of blocks has passed. This may be called frequently enough so that the input `reduceAmount` is 0. Thus a check if the input `reduceAmount` is 0 that will simply return can be added to avoid executing unnecessary logic.

LowCode Does Not Follow SpecificationFixed

In the documentation provided it states the following for `VBNBAdmin`: Storage attributes: - `ProtocolShareReserve` address. Upgradable only by the admin - `vBNB` address. Upgradable only by the admin However, there is no setter function for `vBNB` and the setter function for `protocolShareReserve` is restricted via the `accessControlManager`.

LowEmitted Events Can Be OptimizedFixed

### In the contract `ProtocolShareReserve`: In the function `setPoolRegistry()`, the event `PoolRegistryUpdated` uses `poolRegistry` when `_poolRegistry` can be used in its place to save gas. Alternatively, the event can be emitted before setting `poolRegistry` to `_poolRegistry` and the temporary variable `oldPoolRegistry` can be removed. The latter is slightly more gas efficient, but may not be consistent with the typical convention used throughout the codebase. Similarly, in the function `setPrime()`, the event `PrimeUpdated` uses `prime` when `_prime` can be used in its place to save gas. Alternatively, the event can be emitted before setting `prime` to `_prime` and the temporary variable `oldPrime` removed. The latter is slightly more gas efficient, but may not be consistent with the typical convention used throughout the codebase. In the function `addOrUpdateDistributionConfigs()`, the event `DistributionConfigUpdated` can use `_config.destination` and `_config.schema` as that are checked to be the same as `config.destination` and `config.schema`. ### In the contract `VBNBAdmin`: In the function `setProtocolShareReserve()`, the event `ProtocolShareReserveUpdated` uses `protocolShareReserve` when `protocolShareReserve_` can be used in its place to save gas. Alternatively, the event can be emitted before setting `protocolShareReserve` to `protocolShareReserve_` and the temporary variable `oldProtocolShareReserve` can be removed. The latter is slightly more gas efficient, but may not be consistent with the typical convention used throughout the codebase. ### In the contract `VToken` in `isolated-pools`: In the function `setReduceReservesBlockDelta()`, the event `NewReduceReservesBlockDelta` can be emitted before setting `reduceReservesBlockDelta` to `_newReduceReservesBlockDelta` and the temporary variable `oldReduceReservesBlockDelta_` can be removed. This is slightly more gas efficient, but may not be consistent with the typical convention used throughout the codebase.

LowIncomplete NatSpec CommentsFixed

Some of the NatSpec comments are missing parameters and many functions do not have any NatSpec comments.

LowIncorrect `ReservesReduced` EventFixed

In both the `venus-protocol` and `isolated-pools` repository it defines the event `ReservesReduced` ```solidity /** * @notice Event emitted when the reserves are reduced */ event ReservesReduced(address admin, uint reduceAmount, uint newTotalReserves); ``` Where the `admin` indicated the address that funds were sent to. However, both now send the funds to the protocol share reserve. In addition, in `venus-protocol`, the input `msg.sender` is used instead of `protocolShareReserve`.

LowMissing Zero Address ValidationFixed

Addresses are not validated before assignment or external calls, potentially allowing the use of zero addresses and leading to unexpected behavior or vulnerabilities. For example, transferring tokens to a zero address can result in a permanent loss of those tokens. ### In the contract `VToken`: - `protcolShareReserve_` is not zero-checked before being used in the function `setProtocolShareReserve()`. ### In the contract `VBNBAdmin`: - `_vBNB`, `_protocolShareReserve`, and `_WBNB` are not zero-checked before being used in the function `initialize()`.

LowPotential Out-of-Gas ExceptionFixed

When a loop allows an arbitrary number of iterations or accesses state variables in its body, the function may run out of gas and revert the transaction. ```solidity=167 for (uint i = 0; i < configs.length; ++i) { ``` Function `ProtocolShareReserve.addOrUpdateDistributionConfigs` contains a loop and its loop condition depends on parameters: `configs`. --- ```solidity=172 for (uint j = 0; j < distributionTargets.length; ++j) { ``` Function `ProtocolShareReserve.addOrUpdateDistributionConfigs` contains a loop and its loop condition depends on state variables: `distributionTargets`. --- ```solidity=204 for (uint i = 0; i < assets.length; ++i) { ``` Function `ProtocolShareReserve.releaseFunds` contains a loop and its loop condition depends on parameters: `assets`. --- ```solidity=222 for (uint i = 0; i < distributionTargets.length; ++i) { ``` Function `ProtocolShareReserve.getUnreleasedFunds` contains a loop and its loop condition depends on state variables: `distributionTargets`. --- ```solidity=277 for (uint i = 0; i < markets.length; ++i) { ``` Function `ProtocolShareReserve._accrueAndReleaseFundsToPrime` contains a loop and its loop condition depends on external calls: `IPrime(prime).allMarkets`. --- ```solidity=290 for (uint i = 0; i < markets.length; ++i) { ``` Function `ProtocolShareReserve._accruePrimeInterest` contains a loop and its loop condition depends on external calls: `IPrime(prime).allMarkets`. --- ```solidity=312 for (uint i = 0; i < distributionTargets.length; ++i) { ``` Function `ProtocolShareReserve._releaseFund` contains a loop and its loop condition depends on state variables: `distributionTargets`. --- ```solidity=357 for (uint i = 0; i < distributionTargets.length; ++i) { ``` Function `ProtocolShareReserve._ensurePercentages` contains a loop and its loop condition depends on state variables: `distributionTargets`.

LowPotential ReentrancyFixed

The function `releaseFunds()` is callable by anyone and will eventually call `safeTransfer()`. The token contract that is called may implement hooks or make other external calls, allowing for reentrancy. In addition, it will make a call to `prime`, which is out of scope of this audit, but which may also make other external calls potentially allowing reentrancy.

Show 6 more
LowTypos and InconsistenciesFixed

### In the contract `ProtocolShareReserve`: - The comment above the `enum Schema` states the first schema is for spread income from prime markets in the core protocol. However, the first entry is `DEFAULT` which should be the schema for all the other sources of income. ### In the contract `VToken` of `venus-protocol`: - The comment above the function `_setInterestRateModel()` states: "Admin function to accrue interest and update the interest rate model". However, it is no longer an admin function and access is given by the access control manager. - The comment above the functions `setReduceReservesBlockDelta()` and `setProtocolShareReserve()` use "A admin", which should be "An admin". - The comment above the function `accrueInterest()` does not reflect the added functionality of psuedo-automatically reducing the reserves. - The comment above the function `_reduceReserves()` states: "Accrues interest and reduces reserves by transferring to admin", however they are now transferred to the protocol share reserve contract. - The `setReduceReservesBlockDelta()` was changed so that access must be granted through the ACM. However, the comment still refers to it as an admin function as opposed to a governance function. ### In the contract `VBep20` of `venus-protocol`: - In the function `doTransferOut()`, "complaint" is misspelled and should be "compliant". ### In the contract `VBNBAdmin` - The `onlyOwner` modifier is used for the `fallback()` function, however, a require statement is used for the `setProtocolShareReserve()` function instead of the `onlyOwner` modifier. ### Inconsistency Between Repos - The check for `reduceReservesBlockDelta` is inconsistent between `isolated-pools` and `venus-protocol`. The check in `isolated-pools` uses greater than, while `venus-protocol` uses greater than or equal to.

LowUnchecked Blocks Can Optimize ContractFixed

In general, the counter in a for loop can be incremented or decremented in an unchecked block.

LowUnnecessary Storage Read Access in For LoopFixed

The for loop contains repeated storage read access in the condition check. Given that the ending condition does not change in the for loop, the repeated storage read is unnecessary, and its associated high gas cost can be eliminated. ```solidity=185 for (uint256 j = 0; j < distributionTargets.length; ) { ``` Loop condition `j < distributionTargets.length` accesses the `length` field of a storage array. --- ```solidity=249 for (uint256 i = 0; i < distributionTargets.length; ) { ``` Loop condition `i < distributionTargets.length` accesses the `length` field of a storage array. --- ```solidity=276 for (uint256 i = 0; i < distributionTargets.length; ) { ``` Loop condition `i < distributionTargets.length` accesses the `length` field of a storage array. --- ```solidity=442 for (uint256 i = 0; i < distributionTargets.length; ) { ``` Loop condition `i < distributionTargets.length` accesses the `length` field of a storage array.

LowUnprotected InitializerFixed

`VBNBAdmin` does not protect its initializer. An attacker can call the initializer and assume ownership of the logic contract, whereby they can perform privileged operations that trick unsuspecting users into believing that they are the owner of the upgradeable contract.

LowUsing both `uint` and `uint256`Fixed

Although `uint` and `uint256` are the same, we recommend keeping the consistancy of the code style and using the explicit version of `uint`.

LowVariables That Could Be Declared as ImmutableFixed

Both `vBNB` and `WBNB` will be known prior to deployment and are only assigned when initializing the contract. These can be made immutable variables and instead initialized in the constructor.

Contracts in scope

No deployed address is recorded for this audit.

The report names a repository or files. Open the report to see its scope.

Repository and files the report names (15)

  • contracts/Interfaces/IPrime.sol
  • contracts/Interfaces/ComptrollerInterface.sol
  • contracts/Tokens/VTokens/VToken.sol
  • contracts/Interfaces/IVToken.sol
  • contracts/Tokens/VTokens/VTokenInterfaces.sol
  • contracts/Tokens/VTokens/VBep20.sol
  • contracts/VTokenInterfaces.sol
  • contracts/Interfaces/IProtocolShareReserve.sol
  • contracts/Interfaces/PoolRegistryInterface.sol
  • contracts/Admin/VBNBAdmin.sol
  • contracts/Utils/ErrorReporter.sol
  • contracts/VToken.sol
  • contracts/Admin/VBNBAdminStorage.sol
  • contracts/ProtocolReserve/ProtocolShareReserve.sol
  • contracts/Interfaces/IIncomeDestination.sol

Part of Venus Protocol’s security record

Venus Protocol
Audits67 audits by 7 firmsLast audit Sep 2025, by Quantstamp.
Critical findingsNo open critical findingsAcross the 67 reports, 4 critical findings were reported. Each is marked fixed by the firm that reported it.
IncidentIncident 12 May 2022Source: De.Fi incident database.
Open Venus Protocol’s security record

Security firm

CertiK

1,045 projects reviewed · 1,376 reports · latest May 2025

See CertiK’s audits

Something 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