code-423n4 / 2024-06-renzo-mitigation-findings

0 stars 0 forks source link

Honest users can lose funds when calling the `claim()` function. #39

Closed c4-bot-8 closed 4 weeks ago

c4-bot-8 commented 4 weeks ago

Lines of code

https://github.com/Renzo-Protocol/Contracts/blob/c5d62fc0319fca154f6e0e1c16c6c532f861e1c7/contracts/Withdraw/WithdrawQueue.sol#L290-L293

Vulnerability details

Original Issue Summary

In the original issue, three scenarios are explained where MEV and/or malicious actors can exploit the fact that the withdrawal amount is calculated at withdrawal request submission time instead of at withdrawal claim time. Any small deviation of the amount from withdraw to claim can be exploited by MEV.

Mitigation

This mitigation proposes calculating the redeem value at the withdraw() function and at the claim() function.

Comments

This mitigation introduces another issue that harms honest users, which we will describe in the next few paragraphs.

Newly Introduced Vulnerability Description

The mitigation proposes the creation of the following function:

    function _calculateAmountToRedeem(
        uint256 _amount,
        address _assetOut
    ) internal view returns (uint256 _amountToRedeem) {
        // calculate totalTVL
        (, , uint256 totalTVL) = restakeManager.calculateTVLs();

        // Calculate amount to Redeem in ETH
        _amountToRedeem = renzoOracle.calculateRedeemAmount(_amount, ezETH.totalSupply(), totalTVL);

        // update amount in claim asset, if claim asset is not ETH
        if (_assetOut != IS_NATIVE) {
            // Get ERC20 asset equivalent amount
            _amountToRedeem = renzoOracle.lookupTokenAmountFromValue(
                IERC20(_assetOut),
                _amountToRedeem
            );
        }

and calling this function twice instead of once. _calculateAmountToRedeem() is called once during the withdraw() call and once during the claim() call. This mitigation aims to mitigate MEV/large arb opportunties.

However, this mitigation will introduce a problem which will impact honest users and make them lose (a portion of) their funds.

Proof of Concept

Assume Alice is a honest user.

Tools used

Manual Review

Recommended Mitigation Steps

Do not allow huge fluctuation that negatively impact honest users.

Assessed type

Timing

c4-judge commented 4 weeks ago

alcueca marked the issue as duplicate of #27

c4-judge commented 3 weeks ago

alcueca marked the issue as unsatisfactory: Invalid