Open sherlock-admin opened 6 months ago
Escalate
Issues #51, #96 and #157 are missing the crucial second step of swapping back to actually drain the pool, and thus describe a low impact. They should be unduplicated from this issue
You've deleted an escalation for this issue.
@CergyK those are not duplicates, I have removed them already. You might want to remove the escalation.
@CergyK those are not duplicates, I have removed them already. You might want to remove the escalation.
Thank you, escalation removed
We have fixed this bug at this PR: https://github.com/DODOEX/dodo-gassaving-pool/pull/15
We have fixed this bug at this PR: DODOEX/dodo-gassaving-pool#15
Fix LGTM
mstpr-brainbot
high
Pool can be drained if there are no LP_FEES
Summary
The pool can be depleted because swaps allow the withdrawal of the entire balance, resulting in a reserve of 0 for a specific asset. When an asset's balance reaches 0, the PMMPricing algorithm incorrectly estimates the calculation of output amounts. Consequently, the entire pool can be exploited using a flash loan by depleting one of the tokens to 0 and then swapping back to the pool whatever is received.
Vulnerability Detail
Firstly, as indicated in the summary, selling quote/base tokens can lead to draining the opposite token in the pool, potentially resulting in a reserve of 0. Consequently, the swapping mechanism permits someone to entirely deplete the token balance within the pool. In such cases, the calculations within the pool mechanism become inaccurate. Therefore, swapping back to whatever has been initially purchased will result in acquiring more tokens, further exacerbating the depletion of the pool.
Allow me to provide a PoC to illustrate this scenario:
Test results and logs:
Impact
Pool can be drained, funds are lost. Hence, high. Though, this can only happen when there are no "LP_FEES". However, when we check the default settings of the deployment, we see here that the LP_FEE is set to 0. So, it is ok to assume that the LP_FEES can be 0.
Code Snippet
https://github.com/sherlock-audit/2023-12-dodo-gsp/blob/af43d39f6a89e5084843e196fc0185abffe6304d/dodo-gassaving-pool/contracts/GasSavingPool/impl/GSPTrader.sol#L40-L113
Tool used
Manual Review
Recommendation
Do not allow the pools balance to be 0 or do not let LP_FEE to be 0 in anytime.