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

0xboriskataa - stEth deposits will result in a revert #271

Closed
sherlock-admin2 opened this issue Jun 27, 2024 · 0 comments
Closed

0xboriskataa - stEth deposits will result in a revert #271

sherlock-admin2 opened this issue Jun 27, 2024 · 0 comments
Labels
Non-Reward This issue will not receive a payout Sponsor Disputed The sponsor disputed this issue's validity

Comments

@sherlock-admin2
Copy link

sherlock-admin2 commented Jun 27, 2024

0xboriskataa

High

stEth deposits will result in a revert

Summary

The protocol assumes that the amount of tokens received is equal to the amount of tokens transferred.
This is not the case for the stETH token.

Vulnerability Detail

stETH is a special token when it comes to its transfer logic and it is known that the amount it transfers is 1-2 wei less than the amount specified in the transfer function. More can be read on the "1-2 wei corner case" issue here.
Mellow deals with this token in DepositWrapper: deposit():

    if (token == steth) {
        IERC20(steth).safeTransferFrom(sender, wrapper, amount);
        amount = _stethToWsteth(amount);

After transfering the token it calls _stethToWsteth() which will revert:

    function _stethToWsteth(uint256 amount) private returns (uint256) {
        IERC20(steth).safeIncreaseAllowance(wsteth, amount);
        IWSteth(wsteth).wrap(amount);
        return IERC20(wsteth).balanceOf(address(this));
    }

The reason for the revert is that an amount - 1 will be transfered and there won't be enough stETH in the contract to call wrap().

Impact

DOS for stETH deposits. This issue has also been considered high in previous contests.

Code Snippet

https://github.com/sherlock-audit/2024-06-mellow/blob/main/mellow-lrt/src/utils/DepositWrapper.sol#L55-L57

Tool used

Manual Review

Recommendation

The simplest way to mitigate this issue is to check how much has been transfered:

    if (token == steth) {
+      uint256 balanceBefore = IERC20(steth).balanceOf(address(this));
       IERC20(steth).safeTransferFrom(sender, wrapper, amount);
+      uint256 receivedAmount =  (IERC20(steth).balanceOf(address(this)) - balanceBefore);     
-      amount = _stethToWsteth(amount); 
+      amount = _stethToWsteth(receivedAmount); 

Duplicate of #299

@sherlock-admin2 sherlock-admin2 changed the title Teeny Holographic Bobcat - Call to stETH.submit inside DepositWrapper without checking staking rate limits lead do DOS of deposits stEth deposits will result in a revert Jun 28, 2024
@sherlock-admin3 sherlock-admin3 added the Sponsor Disputed The sponsor disputed this issue's validity label Jun 30, 2024
@github-actions github-actions bot changed the title stEth deposits will result in a revert Expert Glossy Bull - stEth deposits will result in a revert Jul 6, 2024
@github-actions github-actions bot closed this as completed Jul 6, 2024
@github-actions github-actions bot added the Duplicate A valid issue that is a duplicate of an issue with `Has Duplicates` label label Jul 6, 2024
@sherlock-admin3 sherlock-admin3 changed the title Expert Glossy Bull - stEth deposits will result in a revert 0xboriskataa - stEth deposits will result in a revert Jul 15, 2024
@sherlock-admin3 sherlock-admin3 added Non-Reward This issue will not receive a payout and removed Duplicate A valid issue that is a duplicate of an issue with `Has Duplicates` label labels Jul 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Non-Reward This issue will not receive a payout Sponsor Disputed The sponsor disputed this issue's validity
Projects
None yet
Development

No branches or pull requests

2 participants