-
Notifications
You must be signed in to change notification settings - Fork 6
p0wd3r - The quantity is calculated incorrectly when depositing ETH to weETH. #4
Comments
1 comment(s) were left on this issue during the judging contest. 0xmystery commented:
|
Escalate As I mentioned in the report, this vulnerability can cause asset loss or deposit DoS, so it should be classified as high risk. |
You've created a valid escalation! To remove the escalation from consideration: Delete your comment. You may delete or edit your escalation comment anytime before the 48-hour escalation window closes. After that, the escalation becomes final. |
Agreed that this should be upgraded to |
Agree with the escalation, planning to accept and update to High severity. |
The protocol team fixed this issue in the following PRs/commits: |
Result: |
Escalations have been resolved successfully! Escalation status:
|
The Lead Senior Watson signed off on the fix. |
p0wd3r
high
The quantity is calculated incorrectly when depositing ETH to weETH.
Summary
The quantity is calculated incorrectly when depositing ETH to weETH.
The code treats the quantity of eETH shares returned by Etherfi
LiquidityPool.deposit
as the actual quantity of eETH, but these two quantities are not equal.The Etherfi
LiquidityPool.deposit
andstETH.submit
functions have the same behavior, both returning shares instead of the actual token amount. The protocol handles stETH correctly, but it doesn't handle eETH correctly.Vulnerability Detail
In
depositEth
, if_predefinedPool == PredefinedPool.weETH
,_ethTOeEth
will be called to get thefinalAmount
.https://github.com/sherlock-audit/2024-05-sophon/blob/main/farming-contracts/contracts/farm/SophonFarming.sol#L503-L516
_ethTOeEth
will call EtherfiLiquidityPool.deposit
.https://github.com/sherlock-audit/2024-05-sophon/blob/main/farming-contracts/contracts/farm/SophonFarming.sol#L832-L835
The comment in
_ethTOeEth
states that the return value is the amount of eETH, but in reality Etherfi usesmintShare
and returns the amount of shares.https://github.com/etherfi-protocol/smart-contracts/blob/master/src/LiquidityPool.sol#L523-L533
_depositPredefinedAsset
is called indepositEth
, which in turn called_eethTOweEth
, and the parameter is the share quantity of eETH returned by_ethTOeEth
.https://github.com/sherlock-audit/2024-05-sophon/blob/main/farming-contracts/contracts/farm/SophonFarming.sol#L556-L557
https://github.com/sherlock-audit/2024-05-sophon/blob/main/farming-contracts/contracts/farm/SophonFarming.sol#L843-L846
However, in
weETH.wrap
, the parameter should be the actual amount of eETH rather than the amount of shares, as there is a conversion relationship between the actual amount and the amount of shares, they are not equal.https://github.com/etherfi-protocol/smart-contracts/blob/master/src/WeETH.sol#L49-L55
eETH.transferFrom
is to convert amount to share and thentransferShare
.https://github.com/etherfi-protocol/smart-contracts/blob/master/src/EETH.sol#L111-L119
https://github.com/etherfi-protocol/smart-contracts/blob/master/src/EETH.sol#L143-L147
As for why the current test cases pass, it is because
MockEETHLiquidityPool.deposit
useseEth.mint(msg.sender, mintAmount);
, which directly increases the amount of eETH and returns that amount directly, rather than returning the number of shares as in Etherfi.https://github.com/sherlock-audit/2024-05-sophon/blob/main/farming-contracts/contracts/mocks/MockeETHLiquidityPool.sol#L18-L26
Impact
As there is a conversion rate between the amount of eETH and the number of shares, which are not equal, the following situations may occur:
weETH.wrap(90)
is executed, 10 eETH cannot be deposited into the pool, and the user loses assets.weETH.wrap(110)
is executed. Since there are only 100 eETH, the transaction will revert and the user will not be able to deposit assets.Code Snippet
Tool used
Manual Review
Recommendation
Like
_ethTOstEth
, return the difference of eETH balance instead of directly returning the result ofLiquidityPool.deposit
.https://github.com/sherlock-audit/2024-05-sophon/blob/main/farming-contracts/contracts/farm/SophonFarming.sol#L808-L813
The text was updated successfully, but these errors were encountered: