Ironsidesec - Many cases stEth.transferFrom
will transfer 1-2 less way, which would result in revert in consequent functions, because of not enough balance
#82
Labels
Non-Reward
This issue will not receive a payout
Sponsor Disputed
The sponsor disputed this issue's validity
Ironsidesec
Medium
Many cases
stEth.transferFrom
will transfer 1-2 less way, which would result in revert in consequent functions, because of not enough balanceSummary
This issue is about 1 or 2 wei less transferred on
steth.safeTransferfrom
.Also, there is another issue on
steth.submit
andwsteth.wrap
which has a different impact and root cause than this.This issue's root cause and fix are on
steth.transferFrom
and balance before/after checks.Previous issues :
stEth::transferFrom
will transfer 1-2 less way, which would result in revert in consequent functions, because of not enough balance 2024-05-sophon-judging#63stETH
balance getting lower on 1 or 2 wei due to rounding down integer math lidofinance/core#442Vulnerability Detail
The issue occurs in 2 functions with different impacts.
Issue on
DepositWrapper.deposit
, when converting from stETH to wstETH in L64-L65 below, if 1 eth istransferFrom
called, it will pull 1eth - 1 or 2 wei less. And when the code block goes into_stethToWsteth
which further calls wstETH.wrap which will revert due to less amount. That is, calling wrap(1 steth) but we have 1 steth - 1wei, so it reverts when wrapping. Look at https://github.com/lidofinance/lido-dao/blob/5fcedc6e9a9f3ec154e69cff47c2b9e25503a78a/contracts/0.6.12/WstETH.sol#L57The second issue on
Vault.deposit()
, which callsstETH.transferfrom
, which pulls 1 or 2 wei less amount which will deflate the share value on every deposit and messes the accounting. The currentdepositcallback
doesn't care about theactualAmounts
array which holds the 1 steth values instead of 1steth - 1 wei actual value. If deposit callbacks does any accounting on thisactualAmounts
, then the impact will increase.https://github.com/sherlock-audit/2024-06-mellow/blob/26aa0445ec405a4ad637bddeeedec4efe1eba8d2/mellow-lrt/src/utils/DepositWrapper.sol#L56
https://github.com/sherlock-audit/2024-06-mellow/blob/26aa0445ec405a4ad637bddeeedec4efe1eba8d2/mellow-lrt/src/Vault.sol#L329-L332
Impact
Reverts on
DepositWrapper.deposit
. so DOS most times. Also wrong accounting onVault.deposit()
messing the share value, i.e, mints 1 mellowToken for 1 wsteth - 2 wei deposit.Code Snippet
https://github.com/sherlock-audit/2024-06-mellow/blob/26aa0445ec405a4ad637bddeeedec4efe1eba8d2/mellow-lrt/src/utils/DepositWrapper.sol#L56
https://github.com/sherlock-audit/2024-06-mellow/blob/26aa0445ec405a4ad637bddeeedec4efe1eba8d2/mellow-lrt/src/Vault.sol#L329-L332
Tool used
Manual Review
Recommendation
Use lido recommendation to utilize transferShares function, so the amount is realistic, or implement Fee on transfer approach, which compares the balance before and after the transfer.
Duplicate of #299
The text was updated successfully, but these errors were encountered: