Venus - RiskFund & Shortfall

CertiKFiles named in the report

Audit

Part of CertiK’s series

CertiK reviewed Venus Protocol (Venus - RiskFund & Shortfall) on 24 Aug 2023: 13 findings, 0 critical; 7 marked fixed, 6 open.

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

Report hosted on skynet.certik.com.

Trustblock does not review code.

Findings13

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

SeverityOpenAcknowledgedFixed
Critical000
High200
Medium001
Low406
HighCentralization Related RisksOpen

### Shortfall.sol In the contract `Shortfall`, the role `onlyOwner()` has the authority over the function `updatePoolRegistry()`. Any compromise to the `onlyOwner` account may allow the hacker to take advantage of this authority and update the `poolRegistry` contract address. In addition, the role `DEFAULT_ADMIN_ROLE` can grant addresses the privilege to call the following functions in the contract `Shortfall`: - `updateNextBidderBlockLimit()` - `updateIncentiveBps()` - `updateMinimumPoolBadDebt()` - `updateWaitForFirstBidder()` - `pauseAuctions()` - `resumeAuctions()` Any compromise to the `DEFAULT_ADMIN_ROLE` or these privileged functions may allow the hacker to take advantage of this authority and do the following: - Update the time a bidder has to make the next bid before an auction can be closed. This can be used to win an auction for a low bid; - Update the incentive BPS to allow them to potentially gain more funds from the auction; - Update the minimum pool debt needed to start the auction; - Update the time needed for the first bid before the auction will need to be restarted; - Pause auctions, which prevents auctions from being started or restarted; - Resume auctions, which allows auctions to be started or restarted; ### ProtocolShareReserve.sol In the contract `ProtocolShareReserve` the role `onlyOwner` has authority over the function `setPoolRegistry()`. Any compromise to the `onlyOwner` account may allow the hacker to take advantage of this authority and change the `poolRegistry` address. ### RiskFund.sol In the contract `RiskFund` the role `onlyOwner` has authority over the following functions: - `setPoolRegistry()` - `setShortfallContractAddress()` - `setPancakeSwapRouter()` - `setMaxLoopsLimit()` Any compromise to the `onlyOwner` account may allow the hacker to take advantage of this authority and do the following: - Set the `poolRegistry` address to a contract they control; - Set the `shortfall` contract address to an address they control to steal any reserve that is supposed to be transferred for auction; - Set the PancakeSwap router to a malicious contract to steal any tokens that are intended to be swapped; - Change the max loops, which limits the amount of `markets` that can be input into `swapPoolsAssets()`; In the contract `RiskFund` the role `shortfall` has authority over the function `transferReserveForAuction()`. Any compromise to the `shortfall` account may allow the hacker to take advantage of this authority and steal all reserves from the contract. The role `DEFAULT_ADMIN_ROLE` can grant addresses the privilege to call the following functions in the contract `RiskFund`. - `swapPoolsAssets()` - `setMinAmountToConvert()` Any compromise to the `DEFAULT_ADMIN_ROLE` or these privileged functions may allow the hacker to take advantage of this authority and do the following: - Swap a pools assets to the convertible base asset as well as set the minimum output amounts. If a hacker gained access to this, they can set a low minimum output amount and manipulate the pool to steal assets; - Set the minimum amount that must be converted in order to swap assets. ### ReserveHelpers.sol In the contract `ReserveHelpers` the role `owner` has authority over the function `sweepToken()`. Any compromise to the `owner` account may allow the hacker to take advantage of this authority and remove any token in excess of its recorded `assetsReserves` mapping value. In particular, if the attacker has control over the `owner` address and the `protocolIncome` address of `protocolShareReserve`, then it is possible to use reentrancy in the `releaseFunds()` function to call into function `sweepToken()` before the state update in `releaseFunds()` is complete, potentially allowing for the removal of more tokens than intended by the protocol.

HighCentralized Control of Contract UpgradeOpen

In the contracts `Shortfall`, `RiskFund`, `ReserveHelpers`, and `ProtocolShareReserve` are upgradeable contracts and the `admin` of the proxy has the ability to update the implementation contract behind the proxy contract. Any compromise to the `admin` account may allow a hacker to take advantage of this authority and change the implementation contract which is pointed by proxy and steal all tokens held by the contracts or implement and execute other potentially malicious functionality.

LowCustom Errors Can Be UsedOpen

From Solidity `v0.8.4`, there are more gas-efficient ways to explain to users why an operation failed than through strings. Using custom errors can significantly reduce the size of the deployed bytecode and reduce the gas cost when calls revert.

LowPotential To Fill Blocks To Stop Others Bids To WOpen

An auction can be closed once the `nextBidderBlockLimit` amount of blocks passes between bids and at least one bid has been placed. A user could make a low first bid and then submit transactions that will fill an entire block. In addition, they pay a high enough gas price to ensure their transaction will be chosen over other transactions. They do this for the `nextBidderBlockLimit` amount of blocks to ensure that no other user can bid and then close the auction. For example, the block gas limit is ~140 million. The average gas price is 3 gwei, so let's assume 10 gwei would be sufficient to ensure their transaction is chosen. With these assumptions it would cost 1.4 BNB per block they wish to fill. Thus if the `nextBidderBlockLimit = 100`, then it would cost them 140 BNB, which if the price of BNB is 250 USD is about 35,000 USD. If the auction is for 50,000 USD worth of assets, then such an attack could be profitable. Note that even if the amount of assets is worth 35,000 USD or less, the attacker would not make a profit and possibly incur a small loss, but they may still wish to execute the attack to cause damage to the protocol. Thus it should be ensured that the amount of assets for auction is significantly less than the cost of such an attack. Note that the example is a very rough estimate. It should be carefully considered what the minimum gas price an attacker could use to execute such an attack would be in order to have a proper estimate of the potential cost.

LowUnchecked Blocks Can Optimize ContractOpen

The `totalTokenDebt[token]` is the sum of all `tokenDebt[token][user]`, so that `totalTokenDebt[token] >= tokenDebt[token][user]` for any user. This allows for unchecked blocks to be used in places where overflow or underflow is not possible. - In the function `claimTokenDebt()`, the check that reverts if `amount > owedAmount` ensures that `tokenDebt[token][msg.sender] = owedAmount - amount` will not underflow, which is why it is placed in an unchecked block. However, this also ensures that `totalTokenDebt[token] -= amount` will not underflow as `totalTokenDebt[token] >= tokenDebt[token][msg.sender] = owedAmount`, so that it can be placed in an unchecked block. - In the function `_transferOutOrTrackDebtSkippingBalanceCheck()`, if `totalTokenDebt[token] += amount` does not overflow, then `tokenDebt[token][to] += amount` cannot overflow as `totalTokenDebt[token] >= tokenDebt[token][user]` and they are both `uint256`. Thus `totalTokenDebt[token]` can be incremented first which will be checked for overflow and then in an unchecked block `tokenDebt[token][to]` can be incremented as it cannot overflow.

LowUnnecessary Update to `marketDebt` in `_startAuctOpen

In function `_startAuction()`, each `vToken` that was a recorded market in the specified `comptroller` is updated in mapping `auction.marketDebt` to a value of 0 before a new list of markets is read from the `comptroller` and used to update the mapping with new values for `auction.marketDebt`. Currently, markets can only be added to a `comptroller` and not removed. As a consequence, the `allmarkets` array in the `comptroller` is monotonically increasing, and retains all old markets. This being the case, there is no need to zero out the entries of the `auction.marketDebt` mapping for the previous markets, because old markets will be retained and their entries are guaranteed to be updated.

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 (8)

  • contracts/lib/TokenDebtTracker.sol
  • contracts/Shortfall/Shortfall.sol
  • contracts/RiskFund/ReserveHelpers.sol
  • contracts/Shortfall/IShortfall.sol
  • contracts/RiskFund/RiskFund.sol
  • contracts/RiskFund/IProtocolShareReserve.sol
  • contracts/RiskFund/IRiskFund.sol
  • contracts/RiskFund/ProtocolShareReserve.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