Open sherlock-admin2 opened 11 months ago
Hello,
Thanks a lot for your attention.
After an in-depth review, we have to consider your issue as Confirmed.
Not only users can get sandwiched but in most cases this exchange directly on the pool level would rarely succeed as get_dy
returns the exact amount the user could get. We will add a slippage that users will setup.
Regards, Convergence Team
This issue has been solved here :
https://github.com/Cvg-Finance/sherlock-cvg/pull/4
Follow the comment : https://github.com/Cvg-Finance/sherlock-cvg/pull/4#discussion_r1457486906 https://github.com/Cvg-Finance/sherlock-cvg/pull/4#discussion_r1457489632
Fix looks good. User can now specify a min out parameter
0x52
medium
SdtRewardReceiver#_withdrawRewards has incorrect slippage protection and withdraws can be sandwiched
Summary
The _min_dy parameter of poolCvgSDT.exchange is set via the poolCvgSDT.get_dy method. The problem with this is that get_dy is a relative output that is executed at runtime. This means that no matter the state of the pool, this slippage check will never work.
Vulnerability Detail
SdtRewardReceiver.sol#L229-L236
When swapping from SDT to cvgSDT, get_dy is used to set _min_dy inside exchange. The issue is that get_dy is the CURRENT amount that would be received when swapping as shown below:
The return value is EXACTLY the result of a regular swap, which is where the problem is. There is no way that the exchange call can ever revert. Assume the user is swapping because the current exchange ratio is 1:1.5. Now assume their withdraw is sandwich attacked. The ratio is change to 1:0.5 which is much lower than expected. When get_dy is called it will simulate the swap and return a ratio of 1:0.5. This in turn doesn't protect the user at all and their swap will execute at the poor price.
Impact
SDT rewards will be sandwiched and can lose the entire balance
Code Snippet
SdtRewardReceiver.sol#L213-L245
Tool used
Manual Review
Recommendation
Allow the user to set _min_dy directly so they can guarantee they get the amount they want