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

blackhole - stETH.transferFrom will transfer 1~2 wei less than the amount specified, leading to reverted transactions #56

Closed
sherlock-admin3 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-admin3
Copy link
Contributor

sherlock-admin3 commented Jun 27, 2024

blackhole

High

stETH.transferFrom will transfer 1~2 wei less than the amount specified, leading to reverted transactions

Summary

When the DepositWrapper.deposit function is called, the stETH token is transferred to the contract using the transferFrom function.
The transferred amount of stETH tokens from the sender may be 1-2 wei less than the amount due to rounding error.
However, the _stethToWsteth function uses the originally specified amount instead of the actual transferred amount.
This discrepancy can lead to reverted transactions because of not enough amount.

Vulnerability Detail

The issue of the account's stETH balance getting lower was reported here: lidofinance/lido-dao#442
stETH is using shares for tracking balances and it is a known issue that due to rounding error, transferred shares may be 1-2 wei less than _amount passed.
So when calling the wrap function, the revert will happen because the stETH balance is lower than the amount passed.

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

Impact

the deposit function may revert if the deposit token is not wstETH.

Code Snippet

https://github.com/sherlock-audit/2024-06-mellow/blob/main/mellow-lrt/src/utils/DepositWrapper.sol#L56
https://github.com/sherlock-audit/2024-06-mellow/blob/main/mellow-lrt/src/modules/obol/StakingModule.sol#L81

Tool used

Manual Review

Recommendation

Use Lido's recommendation to utilize the transferShares function so the _amount is accurate, or implement FoT approach, which compares the balance before and after the transfer to determine the actual transferred amount.

Duplicate of #299

@sherlock-admin2 sherlock-admin2 changed the title Active Corduroy Dragonfly - Deposits will use the wrong price if the price of a token is outside the min/max range of a Chainlink Oracle stETH.transferFrom will transfer 1~2 wei less than the amount specified, leading to reverted transactions 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.transferFrom will transfer 1~2 wei less than the amount specified, leading to reverted transactions Sparkly Inky Elk - stETH.transferFrom will transfer 1~2 wei less than the amount specified, leading to reverted transactions 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 Sparkly Inky Elk - stETH.transferFrom will transfer 1~2 wei less than the amount specified, leading to reverted transactions blackhole - stETH.transferFrom will transfer 1~2 wei less than the amount specified, leading to reverted transactions 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

1 participant