Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sweepERC20() does not fill up withdrawal buffer #322

Closed
howlbot-integration bot opened this issue May 9, 2024 · 8 comments
Closed

sweepERC20() does not fill up withdrawal buffer #322

howlbot-integration bot opened this issue May 9, 2024 · 8 comments
Labels
bug Something isn't working downgraded by judge Judge downgraded the risk level of this issue grade-b primary issue Highest quality submission among a set of duplicates QA (Quality Assurance) Assets are not at risk. State handling, function incorrect as to spec, issues with clarity, syntax 🤖_primary AI based primary recommendation 🤖_99_group AI based duplicate group recommendation sponsor confirmed Sponsor agrees this is a problem and intends to fix it (OK to use w/ "disagree with severity") sufficient quality report This report is of sufficient quality

Comments

@howlbot-integration
Copy link

Lines of code

https://github.com/code-423n4/2024-04-renzo/blob/519e518f2d8dec9acf6482b84a181e403070d22d/contracts/Deposits/DepositQueue.sol#L254-L277

Vulnerability details

Impact

DepositQueue.sweepERC20() fails to call WithdrawQueue.getBufferDeficit() and DepositQueue.fillERC20withdrawBuffer() to fill up withdraw buffer deficit with available tokens before calling restakeManager.depositTokenRewardsFromProtocol() to deposit into Eigenlayer through the Operator Delegator contract.

The protocol usually fill withdraw buffer deficit for both 4th and Erc20 tokens as observed in; RM.deposit(), DQ.depositEthFromProtocol and DQ.forwardFullWithdrawalEth(). This is done to make Eth/tokens available for withdrawal by user.

However, when the sweep function was called, no call was made to fill any withdraw buffer deficit.

Having a withdraw deficit unfilled will reduce the amount of tokens that ought to be available for withdrawal.

// revert if amount to redeem is greater than withdrawBufferTarget
        if (amountToRedeem > getAvailableToWithdraw(_assetOut)) revert NotEnoughWithdrawBuffer();

Proof of Concept

  /// @dev Sweeps any accumulated ERC20 tokens in this contract to the RestakeManager
    /// Only callable by a permissioned account
    function sweepERC20(IERC20 token) external onlyERC20RewardsAdmin {
        uint256 balance = IERC20(token).balanceOf(address(this));
        if (balance > 0) {
            uint256 feeAmount = 0;

            // Sweep fees if configured
            if (feeAddress != address(0x0) && feeBasisPoints > 0) {
                feeAmount = (balance * feeBasisPoints) / 10000;
                IERC20(token).safeTransfer(feeAddress, feeAmount);

                emit ProtocolFeesPaid(token, feeAmount, feeAddress);
            }

            // Approve and deposit the rewards
            token.approve(address(restakeManager), balance - feeAmount);
            restakeManager.depositTokenRewardsFromProtocol(token, balance - feeAmount);

            // Add to the total earned
            totalEarned[address(token)] = totalEarned[address(token)] + balance - feeAmount;

            // Emit the rewards event
            emit RewardsDeposited(IERC20(address(token)), balance - feeAmount);
        }
    }

Also, no call in RM.depositTokenRewardsFromProtocol to check if there's a buffer deficit and to fill it.

Tools Used

Manual review.

Recommended Mitigation Steps

Include a withdrawal buffer deficit check and fill it if required.

Assessed type

Context

@howlbot-integration howlbot-integration bot added 2 (Med Risk) Assets not at direct risk, but function/availability of the protocol could be impacted or leak value 🤖_99_group AI based duplicate group recommendation 🤖_primary AI based primary recommendation bug Something isn't working sufficient quality report This report is of sufficient quality labels May 9, 2024
howlbot-integration bot added a commit that referenced this issue May 9, 2024
@jatinj615 jatinj615 added the sponsor confirmed Sponsor agrees this is a problem and intends to fix it (OK to use w/ "disagree with severity") label May 14, 2024
@C4-Staff
Copy link

CloudEllie marked the issue as primary issue

@C4-Staff C4-Staff added the primary issue Highest quality submission among a set of duplicates label May 15, 2024
@c4-judge c4-judge added downgraded by judge Judge downgraded the risk level of this issue QA (Quality Assurance) Assets are not at risk. State handling, function incorrect as to spec, issues with clarity, syntax and removed 2 (Med Risk) Assets not at direct risk, but function/availability of the protocol could be impacted or leak value labels May 20, 2024
@c4-judge
Copy link
Contributor

alcueca changed the severity to QA (Quality Assurance)

@c4-judge
Copy link
Contributor

alcueca marked the issue as grade-a

@alcueca
Copy link

alcueca commented May 20, 2024

Useful suggestion, but hardly a Medium severity.

@c4-judge c4-judge added grade-b and removed grade-a labels May 24, 2024
@c4-judge
Copy link
Contributor

alcueca marked the issue as grade-b

@lanrebayode
Copy link

@alcueca Thanks for Judging ,

Considering the fact that, this discrepancy will make withdrawal unavailable to users when there should be, it temporarily DOS core functionality which IMO makes it a valid medium.

In this case, tokens that should be available for withdraw is being sent EL.

Please take a second look at this.

@s1n1st3r01
Copy link

s1n1st3r01 commented May 25, 2024

@lanrebayode As mentioned in a comment in another report, sponsor pointed out numerous times that DepositQueue isn't supposed to be holding or receiving any ERC20 tokens. So what this report really is saying is "If some people donate ERC20 to the protocol, those ERC20 won't fill the withdraw buffer". This isn't a vulnerability but rather a great QA suggestion.

Therefore this claim:

this discrepancy will make withdrawal unavailable to users when there should be

is not true. The protocol doesn't rely on ERC20 donations to fill the withdraw buffer and make funds available to users for withdrawal by any means.

@alcueca
Copy link

alcueca commented May 27, 2024

s1n1st3r0 is right, while filling the withdraw buffer in depositTokenRewardsFromProtocol is a valid suggestion, there is no risk of lost assets or significant DoS by its absence.

@C4-Staff C4-Staff closed this as completed Jun 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working downgraded by judge Judge downgraded the risk level of this issue grade-b primary issue Highest quality submission among a set of duplicates QA (Quality Assurance) Assets are not at risk. State handling, function incorrect as to spec, issues with clarity, syntax 🤖_primary AI based primary recommendation 🤖_99_group AI based duplicate group recommendation sponsor confirmed Sponsor agrees this is a problem and intends to fix it (OK to use w/ "disagree with severity") sufficient quality report This report is of sufficient quality
Projects
None yet
Development

No branches or pull requests

6 participants