You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
DuplicateA valid issue that is a duplicate of an issue with `Has Duplicates` labelHighA valid High severity issueRewardA payout will be made for this issueWill FixThe sponsor confirmed this issue will be fixed
This function is used to deposit stETH to SophonFarming, however it doesn't take into account that stETH is a special token when it comes to it's transfer logic, navigating to lido's official docs, where during transfers the amount that actually gets sent is actually a bit less than what has been specified in the transaction. More can be read on the "1-2 wei corner case" issue from here.
In Sophon's case, this then means that the wrong amount of assets ends up being deposited for the transaction in _depositPredefinedAsset(). This would mean that protocol would then overvalue the amount of assets that get transferred in, so if a user then tries to boost a pool exactly by the amount they passed into depositETH with, which would make protocol over-evaluate the value to boost and the if (_boostAmount > _depositAmount) to be useless since in this case we can boost more than was deposited via depositStEth()
// booster purchase proceeds
heldProceeds[_pid] = heldProceeds[_pid] + _boostAmount;
// deposit amount is reduced by amount of the deposit to boost
_depositAmount = _depositAmount - _boostAmount;
// set deposit amount
user.depositAmount = user.depositAmount + _depositAmount;
pool.depositAmount = pool.depositAmount + _depositAmount;
// apply the boost multiplier
_boostAmount = _boostAmount * boosterMultiplier /1e18;
user.boostAmount = user.boostAmount + _boostAmount;
pool.boostAmount = pool.boostAmount + _boostAmount;
// userAmount is increased by remaining deposit amount + full boosted amount
userAmount = userAmount + _depositAmount + _boostAmount;
user.amount = userAmount;
pool.amount = pool.amount + _depositAmount + _boostAmount;
Users debt is also going to be more inflated with sequential deposits.
Impact
As already hinted in the Vulnerability Details, protocol would be put in an unwanted state for not considering the corner case problem with stETH, a few noteworthy mentions:
Protocol integrates with the wrong deposit amount.
Protocol inflates the amount of boosts ~~ and extensively the multiplier
Alternatively, since the stETH ends up being converted to WSTETH from depositStEth() anyways, then advisably just directly integrate WSTETH as has been suggested by even the lido official docs for Defi protocols.
This report is valid and could have been deduped under #63.
mystery0x
added
Duplicate
A valid issue that is a duplicate of an issue with `Has Duplicates` label
High
A valid High severity issue
labels
May 31, 2024
sherlock-admin3
changed the title
Odd Flint Fly - SophonFarming#depositStEth()'s implemetation in regards to recevied stETH tokens should be similar to SophonFarming#_ethTOstEth()
Bauchibred - SophonFarming#depositStEth()'s implemetation in regards to recevied stETH tokens should be similar to SophonFarming#_ethTOstEth()Jun 1, 2024
sherlock-admin3
added
Reward
A payout will be made for this issue
Will Fix
The sponsor confirmed this issue will be fixed
and removed
Excluded
Excluded by the judge without consulting the protocol or the senior
labels
Jun 1, 2024
DuplicateA valid issue that is a duplicate of an issue with `Has Duplicates` labelHighA valid High severity issueRewardA payout will be made for this issueWill FixThe sponsor confirmed this issue will be fixed
Bauchibred
medium
SophonFarming#depositStEth()
's implemetation in regards to receviedstETH
tokens should be similar toSophonFarming#_ethTOstEth()
Summary
Protocol wrongly assumes the amount specified in a stETH transfer is what gets sent
Vulnerability Detail
See SophonFarming#depositStEth()
This function is used to deposit stETH to SophonFarming, however it doesn't take into account that
stETH
is a special token when it comes to it's transfer logic, navigating to lido's official docs, where during transfers the amount that actually gets sent is actually a bit less than what has been specified in the transaction. More can be read on the "1-2 wei corner case" issue from here.In Sophon's case, this then means that the wrong amount of assets ends up being deposited for the transaction in
_depositPredefinedAsset()
. This would mean that protocol would then overvalue the amount of assets that get transferred in, so if a user then tries to boost a pool exactly by the amount they passed into depositETH with, which would make protocol over-evaluate the value to boost and theif (_boostAmount > _depositAmount)
to be useless since in this case we can boost more than was deposited viadepositStEth()
Additionally this then makes all the below snippet from the final
_deposit()
that gets called to integrate wrong data since both the boost/deposit amount would be inflated https://github.com/sherlock-audit/2024-05-sophon/blob/05059e53755f24ae9e3a3bb2996de15df0289a6c/farming-contracts/contracts/farm/SophonFarming.sol#L598-L619Users debt is also going to be more inflated with sequential deposits.
Impact
As already hinted in the Vulnerability Details, protocol would be put in an unwanted state for not considering the corner case problem with stETH, a few noteworthy mentions:
Code Snippet
https://github.com/sherlock-audit/2024-05-sophon/blob/05059e53755f24ae9e3a3bb2996de15df0289a6c/farming-contracts/contracts/farm/SophonFarming.sol#L732-L733
https://github.com/sherlock-audit/2024-05-sophon/blob/05059e53755f24ae9e3a3bb2996de15df0289a6c/farming-contracts/contracts/farm/SophonFarming.sol#L598-L619
Tool used
Manual Review
Recommendation
Apply the balance check as has been done in
_ethTOstEth()
Alternatively, since the stETH ends up being converted to WSTETH from
depositStEth()
anyways, then advisably just directly integrate WSTETH as has been suggested by even the lido official docs for Defi protocols.Duplicate of #63
The text was updated successfully, but these errors were encountered: