Platform: Code4rena
Start Date: 08/05/2023
Pot Size: $90,500 USDC
Total HM: 17
Participants: 102
Period: 7 days
Judge: 0xean
Total Solo HM: 4
Id: 236
League: ETH
Rank: 4/102
Findings: 2
Award: $5,287.96
🌟 Selected for report: 1
🚀 Solo Findings: 1
🌟 Selected for report: Team_Rocket
Also found by: 0xkazim, BPZ, Bauchibred, BoltzmannBrain, Brenzee, DeliChainSec, Franfran, Lilyjjo, MohammedRizwan, SaeedAlipoor01988, Yardi256, ast3ros, berlin-101, carlitox477, fs0c, peritoflores, sashik_eth, sces60107, thekmj, volodya, zzykxx
66.5871 USDC - $66.59
https://github.com/code-423n4/2023-05-venus/blob/main/contracts/BaseJumpRateModelV2.sol#L23 https://github.com/code-423n4/2023-05-venus/blob/main/contracts/WhitePaperInterestRateModel.sol#L17
Blocks per year calculations in WhitePaperInterestRateModel
improperly assume 15 seconds block time, while on Binance Smart Chain it’s ~3 seconds. This has grave consequences, because it is used in calculating borrower’s interest rate and liquidity provider supply rate.
WhitePaperInterestRateModel uses following calculations to get blocks per year:
(365*24*60*60)/15 = 2102400
contract WhitePaperInterestRateModel is InterestRateModel { uint256 private constant BASE = 1e18; /** * @notice The approximate number of blocks per year that is assumed by the interest rate model */ uint256 public constant blocksPerYear = 2102400;
However proper calculations are:
(365*24*60*60)/3 = 10512000
, which is properly set in BaseJumpRateModelV2:
abstract contract BaseJumpRateModelV2 is InterestRateModel { uint256 private constant BASE = 1e18; ... /** * @notice The approximate number of blocks per year that is assumed by the interest rate model */ uint256 public constant blocksPerYear = 10512000;
Borrowers pay only 20% for borrows, and liquidity providers loose 80% yield for providing assets to the pool. This disincentivizes users from participating in the pools using WhitePaperInterestRateModel
. Additionally, this leads to an undesired situation, where users borrow from 5x less expensive markets and provide liquidity using the borrowed funds, leading to market discrepancies (overly exploited whitepaper rate pools, and overly supplied jump rate based pools). Because whitepaper interest rate don’t increase borrow rate together with utilization, it reaches 100%, disallowing LPs to unstake their borrowed assets, effectively locking them in the protocol.
Manual analysis
Update blocksPerYear
constant to 10512000:
uint256 public constant blocksPerYear = 10512000;
Other
#0 - c4-judge
2023-05-16T09:19:17Z
0xean marked the issue as primary issue
#1 - c4-judge
2023-05-16T09:21:19Z
0xean marked the issue as duplicate of #559
#2 - c4-judge
2023-06-05T14:02:52Z
0xean marked the issue as satisfactory
#3 - c4-judge
2023-06-05T14:38:22Z
0xean changed the severity to 2 (Med Risk)
#4 - c4-judge
2023-06-05T14:38:32Z
0xean changed the severity to 3 (High Risk)
🌟 Selected for report: DeliChainSec
5221.3704 USDC - $5,221.37
https://github.com/code-423n4/2023-05-venus/blob/main/contracts/Shortfall/Shortfall.sol#L158-L202 https://github.com/code-423n4/2023-05-venus/blob/main/contracts/Shortfall/Shortfall.sol#L467-L470 https://github.com/code-423n4/2023-05-venus/blob/main/contracts/Shortfall/Shortfall.sol#L213
When protocol’s bad debt is auctioned off with 10% incentive at the beginning. A user who gives the best bid, wins. The auction ends when at least one account placed a bid, and current block number is bigger than nextBidderBlockLimit
:
function closeAuction(address comptroller) external nonReentrant { Auction storage auction = auctions[comptroller]; require(_isStarted(auction), "no on-going auction"); require( block.number > auction.highestBidBlock + nextBidderBlockLimit && auction.highestBidder != address(0), "waiting for next bidder. cannot close auction" );
nextBidderBlockLimit
is set to 10 in the initializer, which means that other users have only 30 seconds to place better bid. Now, this is a serious problem, because stuffing whole block with dummy transactions is very cheap on Binance Smart Chain. According to https://www.cryptoneur.xyz/en/gas-fees-calculator 15M gas - whole block - costs 14$~15$ on BSC. This makes a malicious user occasion to cheaply prohibit other users to overbid them, winning the auction at the least favorable price for the protocol. Because BSC is centralized blockchain, there are no private mempools and bribes directly to the miners (like in FlashBots), hence other users are very limited concerning the prohibitive actions.
The protocol overpays for bad debt, loosing value
Manual analysis
There are at least three options to resolve this issue:
Other
#0 - c4-sponsor
2023-05-23T21:41:47Z
chechu marked the issue as sponsor confirmed
#1 - c4-judge
2023-06-05T14:28:34Z
0xean marked the issue as satisfactory