xKeywordx - [H-1] DepositWrapper::deposit
function will revert because it will be off by 1-2 wei in the case of stETH
deposits.
#74
Labels
Non-Reward
This issue will not receive a payout
Sponsor Disputed
The sponsor disputed this issue's validity
xKeywordx
High
[H-1]
DepositWrapper::deposit
function will revert because it will be off by 1-2 wei in the case ofstETH
deposits.Summary
According to Lido's official docs, there is a known issue called the 1-2 wei corner case. Internally,
stETH
transfers are converted to shares so if a user transfers 1e18 of stETH, the actual amount received by the protocol will be0.99e18
. You can see a description of the issue here.Vulnerability Detail
The
DepositWrapper::deposit
function assumes that theamount
parameter passed in by the function caller will be the actual amounts deposited in the protocol. In the case ofstETH
this will generally not be true because of the rounding that takes place during transfers.Impact
The transaction will revert when the internal
_stethToWsteth
function will call thewrap
function because the balance of the contract will beamount - 1
instead ofamount
.When the function caller transfers
stETH
from him to the contract, the actual amount will beamount - 1
, and when theDepositWrapper
contract calls thewrap
function, it will attempt to transferamount
from the contract to Lido, and it will revert because it has fewer tokens in it.Code Snippet
Tool used
Manual Review
Recommendation
Check the actual balance before and after
stETH
transfer in order to make sure that the protocol registers the right amount.Duplicate of #299
The text was updated successfully, but these errors were encountered: