Platform: Code4rena
Start Date: 30/04/2024
Pot Size: $112,500 USDC
Total HM: 22
Participants: 122
Period: 8 days
Judge: alcueca
Total Solo HM: 1
Id: 372
League: ETH
Rank: 102/122
Findings: 1
Award: $0.00
🌟 Selected for report: 0
🚀 Solo Findings: 0
🌟 Selected for report: pauliax
Also found by: 0rpse, 0x73696d616f, 0xAadi, 0xCiphky, 0xPwned, 0xhacksmithh, 0xnev, 0xnightfall, 0xordersol, 14si2o_Flint, Aamir, Aymen0909, BiasedMerc, DanielArmstrong, Fassi_Security, FastChecker, GoatedAudits, Greed, KupiaSec, LessDupes, Maroutis, NentoR, OMEN, SBSecurity, Stefanov, TheFabled, adam-idarrha, ak1, aman, araj, aslanbek, b0g0, baz1ka, bigtone, blutorque, carlitox477, carrotsmuggler, crypticdefense, eeshenggoh, fyamf, gesha17, gjaldon, grearlake, guhu95, honey-k12, hunter_w3b, ilchovski, josephdara, kinda_very_good, lanrebayode77, m_Rassska, maxim371, mt030d, mussucal, oakcobalt, p0wd3r, peanuts, rbserver, shui, siguint, t0x1c, tapir, twcctop, ustazz, xg, zhaojohnson, zigtur, zzykxx
0.0026 USDC - $0.00
During the calculation of the total TVL, the function initiates a loop over the operatorDelegators
array using i
as the index, followed by a nested loop over the collateralTokens
array using j
as the index. The issue arises when computing the token values in the withdrawQueue, where i
is incorrectly used as the index instead of j
. Consequently, the function consistently references the first collateral token for calculating token values in the withdrawQueue, resulting in an inaccurate total TVL calculation.
An inaccurate calculation of the total TVL poses several critical risks within the system. Given that the minting or redeeming of ezETH is contingent upon the total TVL, any miscalculation could lead to erroneous minting or redemption actions. This, in turn, jeopardizes the fair distribution of rewards among users and potentially results in financial losses.
Moreover, the totalTVL serves as a pivotal factor in determining the exchange rate between ezETH and ETH within the BalancerRateProvider contract. Any inaccuracies in its calculation could profoundly impact this rate, disrupting the balance and fairness of exchanges between the two assets.
Furthermore, the withdraw function relies on the accurate determination of the totalTVL to calculate the amount of ETH to redeem. An erroneous total TVL calculation here could lead to incorrect redemption amounts, thereby causing financial losses either to the user or the protocol itself.
withdraw function in WithdrawQueue.sol:
File: contracts/Withdraw/WithdrawQueue.sol #1 216 // calculate totalTVL 217 (, , uint256 totalTVL) = restakeManager.calculateTVLs(); 218 219 // Calculate amount to Redeem in ETH 220 uint256 amountToRedeem = renzoOracle.calculateRedeemAmount( 221 _amount, 222 ezETH.totalSupply(), 223 totalTVL 224 );
getRate function in BalancerRateProvider.sol:
File: contracts/RateProvider/BalancerRateProvider.sol #2 29 function getRate() external view returns (uint256) { 30 // Get the total TVL priced in ETH from restakeManager 31 (, , uint256 totalTVL) = restakeManager.calculateTVLs(); 32 33 // Get the total supply of the ezETH token 34 uint256 totalSupply = ezETHToken.totalSupply(); 35 36 // Sanity check 37 if (totalSupply == 0 || totalTVL == 0) revert InvalidZeroInput(); 38 39 // Return the rate 40 return (10 ** 18 * totalTVL) / totalSupply; 41 }
To resolve this issue, the function should use the j
index to reference the correct collateral token in the collateralTokens
array when calculating the token values in the withdrawQueue. This can be achieved by replacing collateralTokens[i]
with collateralTokens[j]
in RestakeManager.sol
if (!withdrawQueueTokenBalanceRecorded) { totalWithdrawalQueueValue += renzoOracle.lookupTokenValue( -- collateralTokens[i], ++ collateralTokens[j], collateralTokens[j].balanceOf(withdrawQueue) ); }
Loop
#0 - c4-judge
2024-05-16T10:34:00Z
alcueca marked the issue as satisfactory
#1 - c4-judge
2024-05-16T10:38:47Z
alcueca changed the severity to 2 (Med Risk)
#2 - c4-judge
2024-05-16T10:39:08Z
alcueca changed the severity to 3 (High Risk)
#3 - c4-judge
2024-05-20T04:26:26Z
alcueca changed the severity to 2 (Med Risk)
#4 - c4-judge
2024-05-23T13:47:21Z
alcueca changed the severity to 3 (High Risk)