The contract has a vulnerability where it fails to check whether a strategy exists before attempting to withdraw liquidity from it. This can cause the contract to interact with non-existent or removed strategies, leading to transaction failures and potential denial of service (DoS) scenarios.
In the _withdrawLiquidity function, the contract iterates over the strategies array in reverse order, attempting to withdraw liquidity from each strategy. However, it doesn't verify whether the strategy at each index still exists or is valid before calling the withdraw() function on it. If a strategy has been removed or is invalid, the contract will try to withdraw from a non-existent strategy, causing the transaction to revert. This vulnerability can lead to a denial of service (DoS), preventing users from withdrawing their liquidity.
Code Snippet from _withdrawLiquidity:
The function does not perform a validity check on each strategy address before calling its methods.
PoC:
Consider a scenario where the strategies array initially holds valid strategy contracts. Later, due to changes in governance or contract upgrades, one or more strategies are removed from the pool, and their entries in the strategies array are deleted. The contract then attempts to withdraw liquidity without checking whether the strategy exists. This can cause the withdrawal process to revert, locking users’ liquidity.
In Hardhat, you can simulate the vulnerability with this test:
This test shows that the withdrawLiquidity function will revert because the contract tries to interact with the removed strategy, which no longer exists.
If a strategy has been removed from the pool, attempting to withdraw liquidity will fail due to an invalid strategy reference. This leads to transactions reverting, effectively blocking users from withdrawing their funds.
Repeated failures to withdraw from invalid strategies could cause a denial of service, where the liquidity pool cannot function properly, impacting user trust and liquidity.
Manual review.
To mitigate this vulnerability, add a check to ensure that a strategy exists and is valid before attempting to interact with it. One way to achieve this is by modifying the _withdrawLiquidity function to check for valid strategy references before invoking any methods.
Fix:
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.