The withdraw function is implemented incorrectly, and it allows two types of issue to occur
Rentrancy becuase the function as no nonrentrant modifier nor does it reset the claimableAmount
to zero before performing the external call to the user making it vulnerable to the exploit
Becuase it does not reset the claimble amount for that particular _tokenBalanceType
users can just keep withdrawing until they drain the capitalPool.
As shown in the snippet above no reentrancy modifier and no update of claimable amount which allows user to both perform a reentrancy attack or keep withdrawing until the protocol is drained
The capitalPool is the backbone of the protocol, that holds all funds that users trade with and collateral, and also the platform fees itself, draining it will make the protocol insolvent and cause loss of funds for both users and the protocol
Manual Review
implement a nonRentrant modifier on the function from openZepplin libraries and also additional security to reset the claimable amount for that tokenAddress
to zero, since it withdrawals all amount automatically, this will also prevent the infinite withdrawal bug.
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.