RestakeManager.calculateTVLs
function does not increase totalTVL
by value of DepositQueue
contract's collateral tokens
#401
Labels
bug
Something isn't working
downgraded by judge
Judge downgraded the risk level of this issue
grade-b
Q-36
QA (Quality Assurance)
Assets are not at risk. State handling, function incorrect as to spec, issues with clarity, syntax
🤖_56_group
AI based duplicate group recommendation
sufficient quality report
This report is of sufficient quality
Lines of code
https://github.com/code-423n4/2024-04-renzo/blob/549f774626b71dd13a427561d4743535a9cc0dca/contracts/Deposits/DepositQueue.sol#L254-L277
https://github.com/code-423n4/2024-04-renzo/blob/549f774626b71dd13a427561d4743535a9cc0dca/contracts/RestakeManager.sol#L647-L668
https://github.com/code-423n4/2024-04-renzo/blob/549f774626b71dd13a427561d4743535a9cc0dca/contracts/RestakeManager.sol#L274-L358
https://github.com/code-423n4/2024-04-renzo/blob/549f774626b71dd13a427561d4743535a9cc0dca/contracts/RestakeManager.sol#L592-L616
https://github.com/code-423n4/2024-04-renzo/blob/549f774626b71dd13a427561d4743535a9cc0dca/contracts/Withdraw/WithdrawQueue.sol#L206-L263
Vulnerability details
Impact
It is possible that collateral tokens are sent to the
DepositQueue
contract as rewards. To ensure that these tokens are properly used, the followingDepositQueue.sweepERC20
function is implemented for depositing these tokens into EigenLayer through calling theRestakeManager.depositTokenRewardsFromProtocol
function below.https://github.com/code-423n4/2024-04-renzo/blob/549f774626b71dd13a427561d4743535a9cc0dca/contracts/Deposits/DepositQueue.sol#L254-L277
https://github.com/code-423n4/2024-04-renzo/blob/549f774626b71dd13a427561d4743535a9cc0dca/contracts/RestakeManager.sol#L647-L668
Since there is no guarantee that the
DepositQueue.sweepERC20
function would be called in the timely manner, these collateral tokens can stay in theDepositQueue
contract temporarily. Yet, because these collateral tokens of theDepositQueue
contract can be eventually deposited into EigenLayer, the value of these tokens should count towards the total TVL. However, the followingRestakeManager.calculateTVLs
function only executestotalTVL += address(depositQueue).balance
so the total TVL is not increased by the value of the collateral tokens that stay in theDepositQueue
contract temporally. In this case, the total TVL becomes lower than what it should be.https://github.com/code-423n4/2024-04-renzo/blob/549f774626b71dd13a427561d4743535a9cc0dca/contracts/RestakeManager.sol#L274-L358
When the
totalTVL
returned by theRestakeManager.calculateTVLs
function is lower than what it should be, functions likeRestakeManager.depositETH
andWithdrawQueue.withdraw
that call theRestakeManager.calculateTVLs
function would operate inaccurately. For instance, when calling theWithdrawQueue.withdraw
function below,amountToRedeem
that equalsrenzoOracle.calculateRedeemAmount(_amount, ezETH.totalSupply(), totalTVL)
would be less than what it should be, which forces the user to redeem a collateral token amount that is less than what the user deserves for giving up the same amount of ezETH; hence, such user loses the collateral token amount difference that the user is entitled to.https://github.com/code-423n4/2024-04-renzo/blob/549f774626b71dd13a427561d4743535a9cc0dca/contracts/RestakeManager.sol#L592-L616
https://github.com/code-423n4/2024-04-renzo/blob/549f774626b71dd13a427561d4743535a9cc0dca/contracts/Withdraw/WithdrawQueue.sol#L206-L263
Proof of Concept
Please add the following test file. Using
forge
, thistest_totalTVLThatIsNotIncreasedByValueOfDepositQueueCollateralTokens
andtest_totalTVLThatIsIncreasedByValueOfDepositQueueCollateralTokens
tests will pass to demonstrate the described scenario.Tools Used
Manual Review
Recommended Mitigation Steps
https://github.com/code-423n4/2024-04-renzo/blob/549f774626b71dd13a427561d4743535a9cc0dca/contracts/RestakeManager.sol#L283 can be updated to the following code.
https://github.com/code-423n4/2024-04-renzo/blob/549f774626b71dd13a427561d4743535a9cc0dca/contracts/RestakeManager.sol#L287 can be updated to the following code.
https://github.com/code-423n4/2024-04-renzo/blob/549f774626b71dd13a427561d4743535a9cc0dca/contracts/RestakeManager.sol#L323-L325 can be updated to the following code.
https://github.com/code-423n4/2024-04-renzo/blob/549f774626b71dd13a427561d4743535a9cc0dca/contracts/RestakeManager.sol#L344 can be updated to the following code.
https://github.com/code-423n4/2024-04-renzo/blob/549f774626b71dd13a427561d4743535a9cc0dca/contracts/RestakeManager.sol#L352 can be updated to the following code.
Assessed type
Context
The text was updated successfully, but these errors were encountered: