Audinarey - DepositWrapper::deposit(...)
will revert for stETH
#202
Labels
Non-Reward
This issue will not receive a payout
Sponsor Disputed
The sponsor disputed this issue's validity
Audinarey
High
DepositWrapper::deposit(...)
will revert forstETH
Summary
User calls
DepositWrapper::deposit(...)
to deposit specified tokens into the vault, converting them to the required format if necessary. If the user specifiesstETh
as the token to deposit, thestETh
is transfered into theDepositWrapper
and the_stethToWsteth(...)
is called to convert thestETH
intowstETH
The problem is that the protocol always assumes that the amount of
stETh
tokens received is equal to the amount of tokens transferred into theDepositWrapper
.This is not the case for rebasing tokens, such as stETH, because internally it transfers shares which generally results in the received amount of tokens being lower than the requested one by 1-2 wei because of roundings.
For instance transferring 1e18 eETH tokens from Alice to
DepositWrapper
, will result inDepositWrapper
receiving 0.99...e18 eETH tokens.Lido acknowledges this issue here and it is discussed extensively [here](lido-dao/issues/442
Vulnerability Detail
DepositWrapper::deposit(...)
specifyingtoken
=stETh
andamount
= 1 etherDepositWrapper
onL56
but due to rounding issueDepositWrapper
receives 1 ether. minus 1wei (1 ether - 1
)DepositWrapper
now has less than 1 etherstethToWsteth(amount)
is now called onL57
to wrap the exact 1 ether which will attempt to transfer 1 ether from theDepositWrapper
DepositWrapper
now has less than 1 ether to be transfered outImpact
This breaks accounting as well as well as a denial of service
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
Modify the
DepositWrapper::deposit(...)
function as shown belowDuplicate of #299
The text was updated successfully, but these errors were encountered: