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: 73/102
Findings: 1
Award: $56.63
🌟 Selected for report: 0
🚀 Solo Findings: 0
🌟 Selected for report: brgltd
Also found by: 0x73696d616f, 0xAce, 0xSmartContract, 0xWaitress, 0xkazim, 0xnev, Aymen0909, BGSecurity, Bauchibred, Cayo, ChrisTina, Franfran, IceBear, Infect3d, Kose, Lilyjjo, PNS, RaymondFam, Sathish9098, Team_Rocket, Udsen, YakuzaKiawe, YoungWolves, berlin-101, bin2chen, btk, codeslide, fatherOfBlocks, frazerch, kodyvim, koxuan, lfzkoala, lukris02, matrix_0wl, nadin, naman1778, sashik_eth, tnevler, volodya, wonjun, yjrwkk
56.6347 USDC - $56.63
https://github.com/code-423n4/2023-05-venus/blob/main/contracts/VToken.sol#L524
Two address tokens exists in the blockchain. For example, Synthetix's ProxyERC20 contract is such a token which exists in many forms (sUSD, sBTC...). Tokens if such are used as underlying, the owner/governance could sweep them even if they are used as underlying by providing the other address to the sweepToken function. The only check in this function is that address(token) != underlying
, which is irrelevant in the case of two address tokens.
Recommedation:
check that the balance of the underlying token remains the same before and after the sweep.
deadline
for swap operationshttps://github.com/code-423n4/2023-05-venus/blob/main/contracts/RiskFund/RiskFund.sol#L265 Swap can be done with a bad price in riskfund which may not be able to payoff the bad debt.
if an authorised user makes a swap transaction with a low transaction fees this be could be pending for hours, days, or weeks until transaction fees gets low for miners to be interested with the transaction.
When the transaction get mined even though the user get the amountOutMin
the price of the assets could have dropped drastically since the user made the swap.
swapPoolsAssets
interact with AMM pools but do not have a deadline parameter, it's passing block.timestamp in _swapAsset
to a pool, which means that whenever the miner decides to include the txn in a block, it will be valid at that time, since block.timestamp will be the current timestamp.
Recommedation:
Add a deadline line parameter to swapPoolsAssets
that should be passed to _swapAsset
.
preLiquidateHook
checks if Action.LIQUIDATE
is in paused state but does not check if Action.REPAY
for the borrowed token is in paused state.
The Action.REPAY
for a borrowed token could be in paused state where a user cannot repay his/her borrow and the Action.LIQUIDATE
may not be in a paused state, in this case users who borrowed token would be liquidated unfairly since the cannot repay their borrow.
Also check if Action.REPAY
is also in paused state if the token market is not deprecated.
getUnderlyingPrice
for priceError.https://github.com/code-423n4/2023-05-venus/blob/main/contracts/RiskFund/RiskFund.sol#L240 check the price returned for errors.
uint256 underlyingAssetPrice = ComptrollerViewInterface(comptroller).oracle().getUnderlyingPrice( address(vToken) );
https://github.com/code-423n4/2023-05-venus/blob/main/contracts/Pool/PoolRegistry.sol#L397
move _ensureValidName(name)
to the first line of the function.
https://github.com/code-423n4/2023-05-venus/blob/main/contracts/Comptroller.sol#L1215
can be refactored to _ensureMaxLoops(marketsCount + 1)
and placed at #L1207
initialize markets.length
at the start and use throughout the function.
https://github.com/code-423n4/2023-05-venus/blob/main/contracts/RiskFund/RiskFund.sol#L162
uint256 marketsCount = markets.length;
https://github.com/code-423n4/2023-05-venus/blob/main/contracts/VToken.sol#L250 https://github.com/code-423n4/2023-05-venus/blob/main/contracts/VToken.sol#L927 state the exact intent of the code in comments uint256 cannot be -1
- * @param repayAmount The amount to repay, or -1 for the full outstanding amount + * @param repayAmount The amount to repay, or type(uint256).max for the full outstanding amount
#0 - c4-judge
2023-05-18T18:50:23Z
0xean marked the issue as grade-b