-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
sl1 - Lack of slippage protection during withdrawal in SuperPool and Pool contracts. #356
Comments
Slippage protection cannot circumvent bad debt |
Escalate, |
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. |
This should be invalid and not a duplicate of #245 because the title and description are not coherent. While the title talks about slippage during withdraw / deposits (which is a separate issue), the description talks about funds lost due to a bad debt liquidation which has nothing to do with slippage |
For slippage to occur, the totalAssets of the pool must reduce and exchange rate worsen, this can happen during bad debt liquidation. Otherwise there won't be any slippage as the exchange rate will stay 1:1 and there won't be a need for slippage protection at all. |
Watson has identified an edge case where the user could receive fewer shares than expected during a bad debt liquidation. In the event of a bad debt liquidation, the pool's total assets decrease, causing the exchange rate to worsen. If a user attempts to withdraw or redeem during this period, they can burn more shares or receive fewer assets than anticipated. I am planning to accept the escalation and make this issue Medium. |
@cvetanovv, hello, could #292 be considered a duplicate? It is for a different functionality in a different part of the code but the root cause is the same and the impact is very similar. |
I can't duplicate them because they have nothing in common. The problem here is that a user can get fewer tokens when using There is nothing like that mentioned in #292. Usually, bots liquidate, and even if a user does it, he is not obliged to do it. Therefore, I will not duplicate them, and my previous decision will remain. |
Result: |
Escalations have been resolved successfully! Escalation status:
|
sl1
Medium
Lack of slippage protection during withdrawal in SuperPool and Pool contracts.
Summary
Lack of slippage protection in the SuperPool and Pool could lead to loss of user funds in an event of bad debt liquidation.
Vulnerability Detail
When a user who has deposited assets in one of the pools of the Pool.sol contract wishes to withdraw them, they can do so by calling
withdraw()
. Under normal conditions, user expects to receive the full deposited amount back or more if the interest accrues in the underlying pool. However, if the pool experiences bad debt liquidation, the totalAssets of the pool are reduced by the amount of bad debt liquidated and the exchange rate worsens.Pool.sol#L542-L547
When a user withdraws, if the pool experiences bad debt liquidation, while the transaction is pending in the mempool, they will burn more shares than they expected.
Consider the following scenario:
totalAssets
drops to 1500.500 * 2000 / 1500 = 666.66
shares.The same issue is present in the SuperPool contract, as the
totalAssets()
of the SuperPool is dependant on the total amount of assets in the underlying pools a SuperPool has deposited into.SuperPool.sol#L180-L189
Pool.sol#L218-L227
When redeeming in the SuperPool, a user will either burn more shares when using
withdraw()
or receive less assets when usingredeem()
.Impact
withdraw()
in the Pool.sol and bothredeem
/withdraw
in the SuperPool lack slippage protection, which can lead to users loosing funds in the even of bad debt liquidation.Code Snippet
https://github.com/sherlock-audit/2024-08-sentiment-v2/blob/0b472f4bffdb2c7432a5d21f1636139cc01561a5/protocol-v2/src/Pool.sol#L339-L372
https://github.com/sherlock-audit/2024-08-sentiment-v2/blob/0b472f4bffdb2c7432a5d21f1636139cc01561a5/protocol-v2/src/SuperPool.sol#L281-L286
https://github.com/sherlock-audit/2024-08-sentiment-v2/blob/0b472f4bffdb2c7432a5d21f1636139cc01561a5/protocol-v2/src/SuperPool.sol#L293-L298
Tool used
Manual Review
Recommendation
Introduce minimum amount out for
redeem()
function and maximum shares in forwithdraw()
function as means for slippage protection.The text was updated successfully, but these errors were encountered: