The vulnerability allows users to repeatedly withdraw funds without updating their balance, posing a significant risk of draining the entire pool.
The vulnerability lies in the `withdraw` function, where the
user's claimable amount is retrieved using the following mapping:
2. However, this mapping is not updated to zero after the user withdraws their funds.
3. As a result, the user's balance remains unchanged, leading to a potential re-entrancy attack for ETH withdrawals and continuous claiming of the same amount for ERC20 tokens.
4. This loophole allows a malicious user to drain the entire capital pool.
A single user could repeatedly withdraw funds, effectively draining the pool.
- Manual code review
To mitigate this vulnerability, it is recommended to set the user's balance to zero immediately after retrieving their claimable amount. This can be done by updating the mapping as follows:
This ensures that once a user withdraws their funds, their balance is correctly updated, preventing any re-entrancy attacks or multiple claims on the same balance.
Valid critical severity finding, the lack of clearance of the `userTokenBalanceMap` mapping allows complete draining of the CapitalPool contract. Note: This would require the approval issues highlighted in other issues to be fixed first (i.e. wrong approval address within `_transfer` and lack of approvals within `_safe_transfer_from` during ERC20 withdrawals)
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.